[ python-Bugs-1019956 ] httplib.HTTPConnection sends extra blank line

SourceForge.net noreply at sourceforge.net
Fri Sep 3 16:10:25 CEST 2004


Bugs item #1019956, was opened at 2004-08-31 15:00
Message generated for change (Comment added) made by antrod
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1019956&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Antonio Rodriguez (antrod)
Assigned to: Jeremy Hylton (jhylton)
Summary: httplib.HTTPConnection sends extra blank line

Initial Comment:
It seems that line 594 of httplib.py:

       self._buffer.extend(("", ""))

Causes the insertion of an extra \r\n so that at the end of the 
headers an extra blank line is submitted. This can create problems 
when PUTting files because the extra line gets treated as part of 
the payload and can thus cause the truncation of the end of the file 
on servers that are listening to the Content-Length header.

I think that:


       self._buffer.extend(("", ))

fixes the issue but I am not quite sure whether this is there for 
some other reason.



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

>Comment By: Antonio Rodriguez (antrod)
Date: 2004-09-03 09:10

Message:
Logged In: YES 
user_id=714839

Calvin, 

After much checking, I've discovered you are indeed correct. A million 
apologies for raising a false alarm. I was confused by the line:
h.extend(("", ""))
In that it would seem to add two blank lines when it really just adds two 
\r\n s. 

Anyhow, I guess this officially closes this. Again, thanks for the prompt 
response.

AR


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

Comment By: Wummel (calvin)
Date: 2004-09-02 16:26

Message:
Logged In: YES 
user_id=9205

Hm, the code adds just two CRLFs:
>>> h = ["Header: value"]
>>> h.extend(("", ""))
>>> "\r\n".join(h)
'Header: value\r\n\r\n'

If you see 3 \r\n in your application it must be something
else, perhaps the header value had an additional line ending
in it.

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

Comment By: Antonio Rodriguez (antrod)
Date: 2004-09-02 16:09

Message:
Logged In: YES 
user_id=714839

Calvin,

Sorry, I should have been more clear in my original post.
My *skim* of the RFC is that one blank line is required (so \r\n at the 
end of the last header and then another \r\n). What I think this is doing 
is inserting two blank lines (so 3 total \r\n) which is not (as far as I can 
see in the RFC).

Should I append some test code to make it clearer?

Antonio


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

Comment By: Wummel (calvin)
Date: 2004-09-02 15:48

Message:
Logged In: YES 
user_id=9205

The \r\n (CRLF) line is required by RFC 2616 section 5: a
CRLF ends the headers. The line must not be treated as part
of the payload, the message-body begins after the newline.


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1019956&group_id=5470


More information about the Python-bugs-list mailing list