12
votes
having trouble validating request line in server.c
I have come up with my own solution after doing some research on pointer math.
I used the strchr command to find the first single space in the line (handling a 400 error if that could not be found). ...
6
votes
Accepted
pset6 (server.c) content length
After your content type line, try adding another \r\n to finish up.
5
votes
How to start with load function in server.c?
When I hit my road block here, I went back to the source code and re-watched the walkthrough videos, specifically this one: https://www.youtube.com/watch?v=OnAItxJhS70
There are subtle hints ...
5
votes
Accepted
PSET 6 Keeps Stopping Server
The Stopping server message comes from the stop() function defined here:
/**
* Stop server, deallocating any resources.
*/
void stop(void)
{
// preserve errno across this function's library ...
4
votes
Accepted
Pset 6 Web Server
Don't look at it like a mountain and get so overwhelmed. It's just another pset, maybe a little more difficult than the previous ones.
Start from the beginning, watch all the lectures and short ...
4
votes
my server pset throws up "505 HTTP Version Not Supported" but i think it should not
First, recall what the spec says about the request-line:
Per 3.1.1 of https://www.rfc-editor.org/rfc/rfc7230, a request-line is
defined as
method SP request-target SP HTTP-version CRLF
wherein SP ...
4
votes
Accepted
PSET6 Server - Parse function (requesting two files in a row)
I just completed this pset successfully.. I had the same issue and i moved on implementing the next function because if you see in the sandbox link you will find under that error written TODO..which ...
4
votes
Accepted
PSET7: web server permissions problem
403 Forbidden / permissions / chmod: the Definitive Guide
TL;DR:
PHP files and config.json need to be set to chmod 640 despite what it says in the Problem Specification.
Hope this helps!
4
votes
Accepted
Pset6 load returns length zero for php files
You would need to use debug50 or gdb to "stop the program and inspect", not check50.
Since you are asking for help with debugging, my comments are intentionally cryptic.
If load returns false, you ...
3
votes
Accepted
Pset6 Server.c: 404 Error only when submitting query on hello.html, everything else works
According to your terminal output, abs_path is wrong. Unless you have a file named hello.php?name=gege019, 404 is the right answer. abs_path should not include the ? or anything that follows.
3
votes
PSET6 | server.c | access()
On a high level I believe it is used to test whether a file exists and/or how it can be manipulated. But how exactly does it do this?
According to the man pages:
The check is done using the ...
3
votes
Accepted
PSET6: Port 8080 already in use?
Have you tried to kill the server process before trying those commands?
killall server
Also you can kill the apache process, if it's running:
sudo killall apache2
2
votes
Accepted
Two questions about "respond to client(browser)"
The keyword continue simply skips the current iteration of the loop. Of course you don't wanna continue the process of responding to the client if part of this process failed.
do we have to call ...
2
votes
Accepted
problems about "respond to client" and "concatenate root and absolute-path" in server.c
when you look a few lines above you see how the code is responding to a php page request. Just do the same - and add a dprintf for Content-Type.
// respond to client
if (dprintf(cfd, "...
2
votes
Accepted
To ensure the file is readable
This can be done by using "access", as suggested in the pset sheet.
e.g.
use
access(path, R_OK)
to check if the file is readable, and it'll return 0 if readable and return -1 if not.
consult ...
2
votes
Accepted
why does my server only work when requesting php files from Chrome?
per the specs:
Complete the implementation of support for static content in such a
way that, after loading a file into memory via load, main responds to
a browser with these lines
HTTP/1.1 ...
2
votes
Accepted
why doesn't strcmp return 0 even though the strings look identical in gdb?
method is 3 chars long and you need at least 4 characters to store the string "GET" {'G', 'E', 'T', '\0'}. so technically your variable method is not actually a string (it doesn't terminate with a '\0'...
2
votes
Accepted
strcat: what am i doing wrong?
You don't have to predeclare the length of croot and apath, and then copy the values in there. That way you spend away valuable space in memory. Also your use of the strcat() function is wrong. Here ...
2
votes
Accepted
Variable optimized out eventhough it will be used later
This is a bug in clang, which has been fixed in version 3.5. The CS50 team is working on getting an update out with update50.
2
votes
PSET 6 Segmentation Fault at strstr
Your true proble is that you declare all your buffers as constants. See here:
const char* buffestbuffer = NULL;
const char* extrabuffer = NULL;
const char* secondneedle = "?";
A variable declared as ...
2
votes
How do i check my own implementation of server.c
"When all else fails, read the directions."
All of this is described in the pset instructions, including how to start the server and how to test it. You just need to go through it and do what it ...
2
votes
Accepted
Does the Staff's server.c solution have a small bug?
The staff version has this test:
Ensure that path actually exists. Respond to the browser with 404 Not Found if not!
before the test for the . in the absolute-path so because /cat doesn't exist ...
2
votes
Accepted
pset6: strncopy result: sizeof not equal to strlen
Needed the terminating null on reqTarget...
// grab the request-target from the line
printf("reqTargetStart = %d\n", reqTargetStart);
printf("reqTargetEnd = %d\n", ...
2
votes
Accepted
I mistakenly uploaded my problem set 1 files onto the Final Project section. How do I retract?
Assignments are all assessed by computer. If you have uploaded to the wrong place, or uploaded the wrong pset, or even want to resubmit one, all you need to do is resubmit the new version to the ...
2
votes
Accepted
Why is the pset6 server loop causing failure after success
Because you didn't initialise your first two booleans:
bool validReqTargetPath;
bool validReqTargetFile;
when you refresh the page, it is likely that you will be given the same memory on the stack ...
2
votes
Accepted
Is it possible to code lookup function without malloc?
Well, here is the thing: I don't think you really have to allocate memory on the heap at all. Besides, you are never making use of the allocated memory and it is not recommended per the pset ...
2
votes
Accepted
Server.c 200 but nothing appears
Per the spec respond to client (the bolds are mine):
Complete the implementation of support for static content in such a
way that, after loading a file into memory via load, main responds
to a ...
2
votes
can't wrap my head around extracting a request from request-line
I'll comment it up for you. It is quite confusing at first, but you'll get your head around it :)
// place the request in a char pointer called haystack
const char* haystack = request;
// in a ...
2
votes
strcat doesn't work
Belu, I tried this code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char* abs_path = "/hello.php";
char* root = "/home/jharvard/Dropbox/CS50/pset6/public";
char ...
2
votes
Accepted
PSET6 - No Data Received AND No Errors
Try mimicking what the distribution code used to generate the responses for the error messages and dynamic content:
if (dprintf(cfd, "HTTP/1.1 200 OK\r\n") < 0)
{
continue;
}
// respond with ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
server × 246pset6 × 212
parse × 32
load × 30
indexes × 19
check50 × 18
error × 13
lookup × 11
cs50x × 9
c × 9
webserver × 9
segmentation-fault × 8
web × 6
recover × 4
query × 4
error-404 × 4
hello.php × 4
appliance × 3
valgrind × 3
realloc × 3
pset7 × 2
flask × 2
html × 2
fails-check50-but-works × 2
function × 2