From: Allister L. S. <all...@gm...> - 2008-09-09 22:05:23
|
Hi folks, I've created a new python server that provides all the headers (as defined in RFC 2616). I created a handler based on CGIHTTPRequestHandler (which already provides HEAD, POST, and GET). I've also placed methods for PUT, DELETE, TRACE, etc., although for the moment all they do is return a 405 error. Once I get to reading the HTTP specs, I might have a better idea on how to implement them. But if you know what to do, go ahead and try your python kungfu on the methods I've prepared. :-) The new server is in server/http_test_server.py and it is now called from server/http_test_server.cpp. In server/cgi-bin/requestinfo.py, I also added sample code on how to get these headers -- although it should be pretty obvious ;-) Cheers, Allister On Tue, Sep 9, 2008 at 1:29 PM, Kim Gräsman <kim...@gm...> wrote: > Hi Dean, > > On Tue, Sep 9, 2008 at 11:22, Dean Michael Berris > <mik...@gm...> wrote: > >> So, as far as I can see there's no reliable way to dump all request > >> headers to the response from a CGI script, via the Python server. The > >> ones that make it through are listed in the run_cgi method in Python's > >> CGIHTTPServer.py. Content-Length and Content-Type are among them, so I > >> thought I had it working for a while :-/ > > > > Is there no way to define which headers (or if all headers) should be > preserved? > > Not as far as I can tell... I think maybe this problem is part of the > CGI concept as well; since it uses environment vars to pass on > selected headers, there's a risk that custom headers overwrite env > vars that the shell depends upon. Unless you jump through hoops to > escape them, etc, or encode all headers into one long string, somehow. > But then it's no longer CGI per se. > > > That should be alright... We may find a better way to go about things > > if we write our own HTTPServer extension which does what we want > > instead of relying on the CGIHTTPServer that Python defines. > > > > I don't have enough Python kung fu to be able to pull it off yet > > though so if you find other ways, I'm all ears. ;-) > > Me neither, I'm just guessing my way ahead :) > > We could potentially derive from one of the requesthandlers and > implement our own, but then we'd have to figure out a good way to get > all the request data from the web server to the handler script, > essentially reinventing CGI. Unless we want to do it all in one > mega-script, in-process. > > Oh well... > > - Kim > > |