请问一下putrequest和request的区别

请问一下putrequest和request的区别

最近学习http连接,碰到一个问题,如下代码
# -*- coding:utf-8 -*-

import httplib

conn = httplib.HTTPConnection("www.python.org")
conn.putrequest("GET","/index.html")
ret = conn.getresponse()
print ret.status,ret.reason
filetmp = file("test.html","wb+")
while True:
    f = ret.read()
    filetmp.write(f)
    if len(f) == 0:
        break
会raise一个异常
raise ResponseNotReady()
ResponseNotReady    如果用request 就不会,为什么啊,难道要加那个putheader?  request和putrequest到底有什么区别呢,新人学习,谢谢高手解答。
request( method, url[, body[, headers]])

This will send a request to the server using the HTTP request method method and the selector url. If the body argument is present, it should be a string of data to send after the headers are finished. The header Content-Length is automatically set to the correct value. The headers argument should be a mapping of extra HTTP headers to send with the request.

putrequest( request, selector[, skip_host[, skip_accept_encoding]])

This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the request string, the selector string, and the HTTP version (HTTP/1.1). To disable automatic sending of Host: or Accept-Encoding: headers (for example to accept additional content encodings), specify skip_host or skip_accept_encoding with non-False values. Changed in version 2.4: skip_accept_encoding argument added.

貌似应该是putrequest不会自动发送header部分,request是自动的,你可以看下官方docs
谢谢。doc和help我都看过了,写得很笼统。如果真是“貌似应该是putrequest不会自动发送header部分,request是自动的”的话大致明白了。不过我更想知道的是为什么要加header,那个header有啥用呢
>>> import httplib
>>> con = httplib.HTTPConnection('www.163.com')
>>> con.putrequest('GET','/index.html')
>>> con.putheader('Accept','text/html')
>>> con.endheaders()
>>> ret=con.getresponse()
>>> ret.status
200
>>> aa=ret.read()
>>> aa[:10]
'<!DOCTYPE '

我试了下,如果不发送header过去的话就会有异常。con.putheader('Accept','text/html')这个可以没有,但是要调用endheaders这个。就OK了
嗯,谢谢了。我还以为putheader和endheader都必须要.
刚看了下putrequest和requeset这两个函数的源代码,大致明白了,确实request的header是默认发送的,发送了一个空的header: def request(self, method, url, body=None, headers={}):
request是自动发送了,putrequest要手动下。