Commented: (MODPYTHON-71) Support the HEAD method properly
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Commented: (MODPYTHON-71) Support the HEAD method properly




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Commented: (MODPYTHON-71) Support the HEAD method properly  
Jim Gallacher (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:47 PM

[ http://issues.apache.org/jira/brows...2318
388 ]

Jim Gallacher commented on MODPYTHON-71:
----------------------------------------

Apache may already be doing the right thing for us. Using netcat as the clie
nt I ran the some tests using the the following as the handler:

/mp/mptest.py
from mod_python import Session
def handler(req):
req.content_type = 'text/plain'
sess = Session.Session(req)
sess.do_cleanup()
try:
sess['hits'] += 1
except:
sess['hits'] = 0

req.write('mptest.py\n')
req.write('hits: %d\n' % (sess['hits']))
req.write('Blah blah blah blah blah\n')
sess.save()
return apache.OK

Note that the host name has been obscured in these tests.

Test 1.
=======
Request
-------
GET /mp/mptest.py HTTP/1.1
Host: example.com
Connection: close

Response
--------
HTTP/1.1 200 OK
Date: Wed, 10 Aug 2005 18:58:49 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) mod_python/3.2.0-dev-20050809 Pytho
n/2.3.5
Cache-Control: no-cache="set-cookie"
Set-Cookie: pysid=0a81c130420c736c10e196e48603cb96; path=/mp
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

a
mptest.py

8
hits: 0

19
Blah blah blah blah blah

0

Comments
--------
Netcat just dumps out whatever it receives. The stray a, 8, 19 and 0 are par
t of the chunked transfer scheme and can be ignored.


Test 2.
=======
Request
-------
HEAD /mp/mptest.py HTTP/1.1
Host: example.com
Connection: close

Response
--------
HTTP/1.1 200 OK
Date: Wed, 10 Aug 2005 18:59:04 GMT
Server: Apache/2.0.54 (Debian GNU/Linux) mod_python/3.2.0-dev-20050809 Pytho
n/2.3.5
Cache-Control: no-cache="set-cookie"
Set-Cookie: pysid=2cc812f1426e5580aaf86904ee41fa3d; path=/mp
Connection: close
Content-Type: text/plain


Comments
--------
Looks like mod_python is doing the right thing. The body of the request is n
ot being sent to the client.

As long as any publisher methods we create stuff HEAD into the allowed metho
ds we should be ok wrt the RFC. I'd say that the change Nicolas made in publ
isher.py is correct, although

if req.method!='HEAD':
req.write(result)

may not be required if the apache ap_rwrite() call is taking care of it. I'l
l dig into the apache code later tonight to confirm this.

> Support the HEAD method properly
> --------------------------------
>
>          Key: MODPYTHON-71
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-71
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.3, 2.7.10, 3.2.0, 3.1.4
>     Reporter: Nicolas Lehuen
>     Priority: Minor

>
> RFC 2616, 9.4 HEAD :
> 8<---8<---8<---8<---8<---
>  The HEAD method is identical to GET except that the server MUST NOT retur
n
>  a message-body in the response. The metainformation contained in the HTTP
>  headers in response to a HEAD request SHOULD be identical to the
>  information sent in response to a GET request.
> 8<---8<---8<---8<---8<---
> Could we make sure that nothing is returned to the client ? Perhaps by making sure
 that req.write does nothing whenever the request method is HEAD ?






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:29 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register