Message91491
I tried to use the following to change the buffersize for a download:
from base64 import encodestring
from httplib import HTTPResponse,HTTPConnection,HTTPSConnection,_UNKNOWN
from datetime import datetime
class FHTTPResponse(HTTPResponse):
def __init__(self, sock, debuglevel=0, strict=0, method=None):
print "creating response"
self.fp = sock.makefile('rb',4096)
self.debuglevel = debuglevel
self.strict = strict
self._method = method
self.msg = None
# from the Status-Line of the response
self.version = _UNKNOWN # HTTP-Version
self.status = _UNKNOWN # Status-Code
self.reason = _UNKNOWN # Reason-Phrase
self.chunked = _UNKNOWN # is "chunked" being used?
self.chunk_left = _UNKNOWN # bytes left to read in current
chunk
self.length = _UNKNOWN # number of bytes left in
response
self.will_close = _UNKNOWN # conn will close at end of
respons
class FHTTPConnection(HTTPConnection):
response_class = FHTTPResponse
class FHTTPSConnection(HTTPSConnection):
response_class = FHTTPResponse
conn = FHTTPSConnection('localhost')
headers = {}
auth = 'Basic '+encodestring('usernmae:password').strip()
headers['Authorization']=
t = datetime.now()
print t
conn.request('GET','/somefile.zip',None,headers)
print 'request:',datetime.now()-t
response = conn.getresponse()
print 'response:',datetime.now()-t
data = response.read()
print 'read:',datetime.now()-t
..however, I saw absolutely no change in download speed.
Aren, I notice in your pastebin code that you do response.read(10485700)
in a loop rather than just one response.read(), why is that? |
|
Date |
User |
Action |
Args |
2009-08-12 07:54:24 | cjw296 | set | recipients:
+ cjw296, facundobatista, ajaksu2, schmir, reacocard |
2009-08-12 07:54:24 | cjw296 | set | messageid: <1250063664.65.0.157354990447.issue2576@psf.upfronthosting.co.za> |
2009-08-12 07:54:23 | cjw296 | link | issue2576 messages |
2009-08-12 07:54:21 | cjw296 | create | |
|