As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

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 ...
Peter's user avatar
  • 1,412
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 ...
hotwebmatter's user avatar
  • 3,046
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 ...
curiouskiwi's user avatar
  • 18.5k
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 ...
ChrisG's user avatar
  • 7,366
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 ...
Muhammad Shahzad Bajwa's user avatar
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!
hotwebmatter's user avatar
  • 3,046
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 ...
DinoCoderSaurus's user avatar
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.
DinoCoderSaurus's user avatar
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 ...
ChrisG's user avatar
  • 7,366
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
Yuri Laguardia's user avatar
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 ...
kzidane's user avatar
  • 17.6k
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'...
kzidane's user avatar
  • 17.6k
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 ...
ChrisG's user avatar
  • 7,366
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 ...
Cliff B's user avatar
  • 67.4k
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 ...
curiouskiwi's user avatar
  • 18.5k
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 ...
ChrisG's user avatar
  • 7,366
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 ...
Cliff B's user avatar
  • 67.4k
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 ...
curiouskiwi's user avatar
  • 18.5k
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", ...
Stef Joynson's user avatar
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 ...
ChrisG's user avatar
  • 7,366
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 ...
Sean's user avatar
  • 264
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 ...
Sam Gerber's user avatar
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 ...
Sam Gerber's user avatar
2 votes
Accepted

How to test own code pset6 server 2016?

I created a separate file called servertest.c to use while working through parse, the stage I just finished. I used a simple main like this to test various inputs to parse: int main(void) { char* ...
Peter's user avatar
  • 1,412
2 votes
Accepted

server.c indexes - what is to be done?

If it exists, you simply have to return its path, as a string. For example, if the input is the string /gifs/cats, and there is indeed a file named index.html in the /gifs/cats directory, then you ...
Levi Roth's user avatar
  • 188
2 votes
Accepted

Server.c Non-existant file and cat.exe question

This is bad abs_path = malloc(sizeof(LimitRequestLine + 1)); (and query too). Remember, parse receives a pointer to abs_path, which is already allocated on the stack (implicitly) in main. The malloc ...
DinoCoderSaurus's user avatar
2 votes
Accepted

Server.c pset6 issues

At least part of your problem is in parse. abs_path is not null terminated. That would cause the behaviour you describe (I get cat.jpg correctly only the first time the server is ever asked:) query, ...
DinoCoderSaurus's user avatar
2 votes

Debugging Webserver in C

GDB should be a very useful tool for debugging server. The waiting is the hardest part. Remember server will be waiting for input from a browser/curl to process something or waiting for gdb to ...
DinoCoderSaurus's user avatar
2 votes
Accepted

In pset6 server.c, does using realloc() reset the file pointer for fread()?

per fread's man page: size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); The function fread() reads nmemb elements of data, each size bytes long, from the stream pointed to by ...
kzidane's user avatar
  • 17.6k
2 votes

Load function correct?

The biggest problem is that you need to null terminate *content before returning the function. I think it would be better to do this with buffer so you maintain your "*content = &buffer[0]" ...
Brendan Rafferty's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible