[cse491] reading complete requests
Joe Amenta
amentajo at msu.edu
Sun Oct 4 19:39:27 PDT 2009
On Sat, Oct 3, 2009 at 8:49 AM, C. Titus Brown <ctb at msu.edu> wrote:
> 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.
>
> If you write a test for POSTs I'm sure people would appreciate having you
> send
> it to the mailing list ;)
>
> --t
> --
> C. Titus Brown, ctb at msu.edu
Attached is a test module that sends POST requests to a server with
randomly-generated content of a randomly-generated length (the length of the
randomly-generated content is always equal to the length specified in
Content-Length... hack around with it if you want to test in other cases)
and tests that the response would be valid. If this test ever fails when it
should not, then please reply with the response your server sent. This
should only be tested on a webserver written for hw #4; it just waste your
time if you test it on other webservers.
Usage:
python test_post.py host port [iterations]
e.g.,
python test_post.py localhost 5000 # this will connect to port 5000 on
localhost and try the default 100 random POST requests.
python test_post.py arctic.cse.msu.edu 24558 10 # this will connect to port
24558 on arctic and try just 10 random POST requests (for time's sake)
No output means that all runs of the test succeeded. If there is a mismatch
between expected response and received response, the response your HTTP
server sent will be displayed on the screen, repr()'d.
--Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/cse491-fall-2009/attachments/20091004/72e4cf11/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_post.py
Type: text/x-python
Size: 1374 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/cse491-fall-2009/attachments/20091004/72e4cf11/attachment.py>
More information about the cse491-fall-2009
mailing list