[Patches] [ python-Patches-516715 ] HTTPConnection.send() fails large reques

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Feb 2002 20:39:03 -0800


Patches item #516715, was opened at 2002-02-12 15:44
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=516715&group_id=5470

Category: Library (Lib)
Group: Python 2.1.2
Status: Open
Resolution: None
>Priority: 7
Submitted By: James Rucker (jamesrucker)
Assigned to: Nobody/Anonymous (nobody)
Summary: HTTPConnection.send() fails large reques

Initial Comment:
The present implementation of HTTPConnection.send() in
httplib.py does not handle the case of less than the
number of requested bytes being sent via socket.send().

Indeed, this condition occurs for fairly large
requests.  In my environment, socket.send() will max
out at transferring 33011 bytes.

The routine needs to check how many bytes where
actually  transferred and make subsequent socket.send()
calls until all of the data makes it through.  In the
patch I've supplied, I send slices of a particular
maximum size in each iteration, rather than attempting
to send the entire remainder of data, for efficiency
(it proved expensive to have big slices being created
per call, which would happen otherwise).

I noticed that in the description of recent patches it
appears that an attempt has made to address this, but
the version of httplib.py that supposedly provides a
fix appears to make invalid references to socket.py. 
If what's there is actually suitable, please do disregard.

The submitted diff is against version 1.34.2.1


----------------------------------------------------------------------

Comment By: James Rucker (jamesrucker)
Date: 2002-02-15 17:47

Message:
Logged In: YES 
user_id=351540

When I say 'max out' I mean that only the first 33011 (in 
my environment) bytes get through on a call.  You don't 
receive an error, per se, as the client things it's send 
is successful.  The problem is that the server doesn't get 
all the bytes expected.  To be clear, this isn't a problem 
with socket.send(); just httplib.py's use of socket.send
() - in particular, the expectation that a lack of an 
error condition being presumed to mean that all bytes were 
sent.

In general, there isn't a problem passing arbitrarily 
large blocks of data, however, clients of socket.send() 
are to check the result of the call, which is an integer 
specifying the number of bytes that were actually 
transmitted.  Note that this number is not guaranteed to 
be the same as the number of bytes specified.  I believe 
that the number of bytes that make it across in a single 
call depend on the underlying buffering and the rate at 
which the client is reading.

I just found the following url which talks in more detail 
about the issue:
http://py-howto.sourceforge.net/sockets/node6.html

Btw, I'm using freebsd 4.4.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-02-15 16:16

Message:
Logged In: YES 
user_id=21627

I fail to see a problem in the current code. What does "max
out" mean exactly? There shouldn't be a problem passing an
arbitrarily large block of data to the send system call,
atleast not over a TCP connection. What operating system are
you using, and what is the precise error that you get with
the  current code?

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=516715&group_id=5470