Graham Dumpleton
graham.dumpleton at gmail.com
Mon Apr 28 17:09:36 EDT 2008
Sorry, one mistake I did make, was that you need earlier handler than PythonFixupHandler if you want to affect access, authentication, authorisation phases. Point is though that you can't do it in a mod_python input filter as they only get triggered when content is being read and after headers have been processed. There are input filters that can process headers, but mod_python doesn't provide access to writing them. Graham 2008/4/29 Graham Dumpleton <graham.dumpleton at gmail.com>: > 2008/4/28 Emyr Thomas <emyr.thomas at gmail.com>: > > > Graham, out of interest, has this always been the case with mod_python, or > > was this behavious introduced in a particular release? > > This is nothing to do with mod_python, it is how underlying Apache C > APIs work. It has always been this way. If you have seen it behave any > other way, it would have been by luck due to calling sequences and not > guaranteed. > > Suggest you dig through: > > http://www.fmc-modeling.org/category/projects/apache/amp/Apache_Modeling_Project.html > > to get a better understanding of how Apache works internally. > > Graham > > > > > "Graham Dumpleton" > > <graham.dumpleton at gmail.com> wrote in message > > news:88e286470704191453o5b0b3c08u77b14064c1f58950 at mail.gmail.com... > > > > > > > You can't use a mod_python input filter to modify incoming headers. If > > > the changes to the headers aren't intended to influence the behaviour > > > of what Apache does during access, authentication, authorisation and > > > type checking phases, use a PythonFixupHandler to update any headers > > > to then be used by the actual response handler. > > > > > > Note, provided you are using mod_python 3.3, you can actually use > > > mod_python to trigger the proxying as well. See: > > > > > > http://issues.apache.org/jira/browse/MODPYTHON-141 > > > > > > Graham > > > > > > On 20/04/07, indyone ;o) <indyone at gmail.com> > > > wrote: > > >> Hi list, > > >> > > >> I'm trying to get the headers_in from the client, and after > > >> changing/adding > > >> some headers i would like to pass them to the backend server. > > >> I'm using Apache/2.0.55 (Win32) mod_python/3.1.3 Python/2.3.5 > > >> The problem is that the headers are sent to the backend unchanged when > > >> using > > >> this simple input filter: > > >> > > >> def inputfilter(filter): > > >> > > >> filter.req.headers_in['X-MyHeader'] = 'Test' > > >> if filter.req.main is not None: > > >> filter.pass_on() > > >> return > > >> > > >> filter.req.log_error('Start %s' % filter.req.uri) > > >> s = filter.read() > > >> while s: > > >> filter.write(s) > > >> s = filter.read() > > >> if s is None: > > >> filter.close() > > >> filter.req.log_error('End %s' % filter.req.uri) > > >> > > >> filter.req.log_error('%s' % filter.req.headers_in) > > >> > > >> and Apache logs: > > >> > > >> [Thu Apr 19 18:17:28 2007] [error] [client 127.0.0.1] Start /, referer: > > >> http://localhost/ > > >> [Thu Apr 19 18:17:28 2007] [error] [client 127.0.0.1] End /, referer: > > >> http://localhost/ > > >> [Thu Apr 19 18:17:28 2007] [error] [client 127.0.0.1] {'X-MyHeader': > > >> 'Test', > > >> 'X-Forwarded-Server': 'luna', 'X-Forwarded-Host': 'localhost', > > >> 'X-Forwarded-For': ' 127.0.0.1', 'Max-Forwards': '10', 'Cookie': > > >> 'wstyle=; > > >> __ac="YWRtaW46bWF0cml4"; > > >> tree-s="eJzT0MgpMOQKVneEAKcAN19bda4CI67EkgJjLj0AegYHmA"', > > >> 'Referer': ' http://localhost/', 'Accept-Charset': > > >> 'ISO-8859-7,utf-8;q=0.7,*;q=0.7', 'Accept-Encoding': 'gzip,deflate', > > >> 'Accept-Language': 'el,en-us;q=0.7 ,en;q=0.3', 'Accept': > > >> 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', > > >> 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: > > >> 1.8.0.8) > > >> Gecko/20061030 SeaMonkey/1.0.6', 'Host': 'localhost'}, referer: > > >> http://localhost/ > > >> ...(multiple times)... > > >> > > >> Which is right i think... But my backend server gets this request: > > >> > > >> GET > > >> /VirtualHostBase/http/localhost:80/Editorial/VirtualHostRoot/ > > >> HTTP/1.1 > > >> Host: localhost:8081 > > >> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) > > >> Gecko/20061030 SeaMonkey/1.0.6 > > >> Accept: > > >> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 > > >> Accept-Language: el,en-us;q=0.7,en;q=0.3 > > >> Accept-Encoding: gzip,deflate > > >> Accept-Charset: ISO-8859-7,utf-8;q= 0.7,*;q=0.7 > > >> Referer: http://localhost/ > > >> Cookie: wstyle=; __ac="YWRtaW46bWF0cml4"; > > >> tree-s="eJzT0MgpMOQKVneEAKcAN19bda4CI67EkgJjLj0AegYHmA" > > >> Max-Forwards: 10 > > >> X-Forwarded-For: 127.0.0.1 > > >> X-Forwarded-Host: localhost > > >> X-Forwarded-Server: luna > > >> > > >> Thank you in advance, > > >> > > >> Ioannis Stavrinos > > >> > > >> _______________________________________________ > > >> Mod_python mailing list > > >> Mod_python at modpython.org > > >> http://mailman.modpython.org/mailman/listinfo/mod_python > > >> > > >> > > > > > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > >
|