[cse491] reading complete requests

C. Titus Brown ctb at msu.edu
Sat Oct 3 05:49:14 PDT 2009


On Fri, Oct 02, 2009 at 05:58:41PM -0400, Tim Miller wrote:
> Titus,
> 
> In the assignment for hw4 you specify:
> 
> The server should respond to both GET and POST requests, and should
> read and ignore any GET query strings and POST data.
> 
> However in your example code you have a line that looks like this:
> 
> if '\r\n\r\n' in data_so_far:  # complete GET request - respond & close
> 
> If I understand correctly, the server would stop receiving after the
> first '\r\n\r\n' and would not read the POST data, so how do I read
> until the request is complete, assuming there is no Content-Length
> header?  Also, how are GET query strings specified again?  I can't
> seem to find it anywhere.

There's only one way to find out how much POST data there is, and that's with
the Content-Length header.  To get that, you have to wait until all the headers
have been received.

If you write a test for POSTs I'm sure people would appreciate having you send
it to the mailing list ;)

GET query strings are on the end of the URL in the request line,

	GET|POST /some/url?query_string

(Note that POST commands can also have query strings.)

--t
-- 
C. Titus Brown, ctb at msu.edu



More information about the cse491-fall-2009 mailing list