mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-19 13:51:01 +00:00
added patches from SVN
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3527 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
e20ff5af15
commit
be4d9a2468
1 changed files with 25 additions and 3 deletions
|
|
@ -665,9 +665,17 @@ class HTTPConnection:
|
|||
if self.debuglevel > 0:
|
||||
print "send:", repr(str)
|
||||
try:
|
||||
self.sock.sendall(str)
|
||||
blocksize=8192
|
||||
if hasattr(str,'read') :
|
||||
if self.debuglevel > 0: print "sendIng a read()able"
|
||||
data=str.read(blocksize)
|
||||
while data:
|
||||
self.sock.sendall(data)
|
||||
data=str.read(blocksize)
|
||||
else:
|
||||
self.sock.sendall(str)
|
||||
except socket.error, v:
|
||||
if v[0] == errno.EPIPE:
|
||||
if v[0] == 32: # Broken pipe
|
||||
self.close()
|
||||
raise
|
||||
|
||||
|
|
@ -840,7 +848,21 @@ class HTTPConnection:
|
|||
self.putrequest(method, url, **skips)
|
||||
|
||||
if body and ('content-length' not in header_names):
|
||||
self.putheader('Content-Length', str(len(body)))
|
||||
thelen=None
|
||||
try:
|
||||
thelen=str(len(body))
|
||||
except TypeError, te:
|
||||
# If this is a file-like object, try to
|
||||
# fstat its file descriptor
|
||||
import os
|
||||
try:
|
||||
thelen = str(os.fstat(body.fileno()).st_size)
|
||||
except (AttributeError, OSError):
|
||||
# Don't send a length if this failed
|
||||
if self.debuglevel > 0: print "Cannot stat!!"
|
||||
|
||||
if thelen is not None:
|
||||
self.putheader('Content-Length',thelen)
|
||||
for hdr, value in headers.iteritems():
|
||||
self.putheader(hdr, value)
|
||||
self.endheaders()
|
||||
|
|
|
|||
Loading…
Reference in a new issue