I've been trying to solve the "validate request-line" in pset6, but there are some things that I don't understand well. Here is how I am interpreting the problem and the "what to do" explanations:

First, I need to work with all the request line and:

1 - check if the absolute path starts with '/';

2 - check if the request line doesn't contain ' " ' (or is it just the query, not all the request line?)

If either one or both of these are false, then return "400 bad request".

Then come the individual requests and one of them is:

3 - if request-target does not begin with '/', respond with 501 Not Implemented

Here is another thing I don't get. What is the difference of checks 1 and 3? Are they not the same error? Isn't the request target the absolute path + the query, so am I not analysing the same thing? Why two different errors?

And one more thing, am I thinking correctly to first analyze the request line to check for the 400 bad request and then move on to the individual requests? Or should I deal with this problem in a more integrated way?

Thanks for all the help!


  • Small update: I've been messing around with telnet and the CS50 implementation of server.c and when I type in telnet the following command: GET cat.html HTTP/1.1, the CS50 server.c implementation returns 501 Not Implemented. Shouldn't it return 400 Bad Request?
    – José
    Oct 22, 2015 at 15:51

1 Answer 1

  • The absolute path is a part of the request-target, so in a way yes 1 and 3 are the same one.
  • There are many ways to think about this, and your way is not any more incorrect or correct than others. You can group several requirements into error cases like you do, or you could also just check each requirement separately.
  • Thanks for the reassurance. After a lot of testing with the CS50 implementation and telnet, I came to understand how things should work, so I am done with the error checking :)
    – José
    Oct 28, 2015 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .