From: Dean M. B. <mik...@gm...> - 2008-08-10 17:36:05
|
Hi Divye On Sun, Aug 10, 2008 at 7:41 PM, Divye Kapoor <div...@gm...> wrote: > Hi Dean, > Response inline. > > On Sat, Aug 9, 2008 at 7:14 PM, Dean Michael Berris <mik...@gm...> > wrote: >> >> Hi Guys, >> >> I've just checked in revision 48 which fixes the Python CGI script >> that returns incomplete headers. I had to make it print the http >> status line (which I'm not sure is required) and add the correct line >> endings to the printed header: instead of just '\n', I made it print >> "\r\n\r\n" in the end to signify that it was the last header responded >> to. > > I tested the python server using LiveHTTPHeaders addon to Firefox. The > current output from the script (after your commit) is: (for > http://localhost:8000/cgi-bin/requestinfo.py?q=1111) > > Content-type: text/plain; charset=us-ascii > > > Query string: q=1111 > GET parameters: q - ['1111'] ; > POST parameters: > > Clearly, the Content-type header is being shifted to the body. Please verify > this if you can. I have changed the print statement to use sys.stdout.write > to write unformatted strings, the print statement interprets the \n on > windows to be \r\n - thus causing this issue. Hopefully it should be fixed. > What was causing the CGI Test to fail initially? Was it the missing HTTP > header? > The CGI test caused the localhost_test to fail because without the '\r\n\r\n' combination from the HTTP response (that delimits the end of the headers section), client.get(...) throws an 'end of file' exception in boost::asio::read_until(..., "\r\n\r\n"). I added the HTTP headers thinking it must be missing or the culprit, but apparently just adding '\r\n\r\n' instead of '\n' to the Content-type header should suffice. I'm not sure if it's a bug in the Python CGI Server implementation, or has something to do with Windows now handling the end-of-line delimiters correctly. I'm not sure also how to fix this, so I'm leaving it up to you. I just did an update now and I see that the localhost_test fails in Windows again, with the client throwing the same end-of-file exception. >> >> Divye, please make sure that this is the correct way to do CGI scripts >> in Python -- I really have no idea how to do that, and I only hacked >> the script to make it not fail in just the CGI case. I haven't tried >> this in Windows yet, but I'm thinking it should be do-able. > > Hopefully this should be fixed. > I think it's fixed now too. Thanks. :) >> >> Another thing: maybe we should put the startup/shutdown of the server >> in a global fixture in the test suite for localhost_test? Has anybody >> done this with Boost.Test before? That way when we start the server, >> we should be able to stop it as well at the end of the whole test. > > That's a good idea. I just learnt about them. I'll try my hand at it. > Hope to see your check-in soon. :) BTW, I'm thinking of using fixtures in our unit tests so that we cut down on repetitive code. I'll add more tests to the message framework to show what I mean later. For the meantime, I'm going to implement the head function call to support HEAD queries from the client side. HTH -- Dean Michael C. Berris Software Engineer, Friendster, Inc. |