From: Allister L. S. <all...@gm...> - 2008-09-23 23:20:45
|
Hi, Just a quick comment on the errors... Yes, they do. Let me paste the log of the errors below: > > gcc.compile.c++ bin/gcc-4.2.3/debug/link-static/localhost_tests.o > gcc.link bin/gcc-4.2.3/debug/link-static/localhost_tests > testing.unit-test bin/gcc-4.2.3/debug/link-static/localhost_tests.passed > localhost - - [24/Sep/2008 06:04:28] "GET / HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET / HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET /boost.jpg HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET /test.xml HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET /test.xml HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET /boost.jpg HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET > /cgi-bin/requestinfo.py?query=1 HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "GET > /cgi-bin/multiline-header.py?query=1 HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] code 404, message File not found > localhost - - [24/Sep/2008 06:04:28] "GET /file_not_found HTTP/1.0" 404 - > localhost - - [24/Sep/2008 06:04:28] "HEAD /test.xml HTTP/1.0" 200 - > localhost - - [24/Sep/2008 06:04:28] "POST /cgi-bin/echo_headers.py > HTTP/1.0" 200 - > Traceback (most recent call last): > File > "/home/dean/Source/C++/cpp-netlib-http_integration/libs/network/test/server/cgi-bin/echo_headers.py", > line 17, in <module> > hdrs = cgisupport.http_headers(os.environ.get('HTTP_ALL_HEADERS')) > File > "/home/dean/Source/C++/cpp-netlib-http_integration/libs/network/test/server/cgi-bin/cgisupport.py", > line 11, in __init__ > self.parse(header_str) > File > "/home/dean/Source/C++/cpp-netlib-http_integration/libs/network/test/server/cgi-bin/cgisupport.py", > line 24, in parse > self.headers = self.__parse_headers(header_str) > File > "/home/dean/Source/C++/cpp-netlib-http_integration/libs/network/test/server/cgi-bin/cgisupport.py", > line 31, in __parse_headers > lines = str.split('\n') > AttributeError: 'NoneType' object has no attribute 'split' Apparently, the parsing of the headers from HTTP_ALL_HEADERS is not yet perfect. I hope I can find time this week to improve cgisupport.py > localhost - - [24/Sep/2008 06:04:28] CGI script exit status 0x100 > Running 15 test cases... > localhost_tests.cpp(272): error in "post_with_explicit_headers": check > headers["content-length"] == content_length failed [ != 5] Obviously, HTTP_ALL_HEADERS does not give you the proper content length through this method. In fact, HTTP_ALL_HEADERS doesn't contain the string "content-length". But you can still get it with os.environ["CONTENT_LENGTH"]. > localhost_tests.cpp(273): error in "post_with_explicit_headers": check > headers["content-type"] == content_type failed [ != > application/x-www-form-urlencoded] Same with content length, use os.environ["CONTENT_TYPE"]. The rest of the errors are of the same type of error. So basically we'll need better parsing of headers in cgisupport.py. Basically, it would be best to try to understand how the parsing is done in CGIHTTPRequestHandler. There one will see that it's not as straightforward as splitting lines with colons as a line could contain more than one colon. I tried inserting these lines into http_test_server.py (line 20, at the beginning of run_cgi function): print '********DEBUG self.headers!!!' print self.headers print '********END DEBUG' The server's console output when I use Firefox to access the server is: ********DEBUG self.headers!!! Host: localhost:8000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive ********END DEBUG So, as we can see, Content-Type and Content-Length are obtained differently by CGIHTTPRequestHandler. It'd also help if one understands how the headers are parsed in $PYTHON_HOME/Lib/rfc822.py. Unfortunately, I'm rather pressed these days so maybe Kim or someone else can do the improvements based on these observations. Cheers, Allister |