[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-23 Thread SilentGhost

SilentGhost added the comment:

All the tests pass now, not sure why your patch doesn't get associated rietveld 
link, it applies cleanly using hg patch --no-commit

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-22 Thread Wiktor Niesiobedzki

Wiktor Niesiobedzki added the comment:

Maybe something like this? Doesn't look too complicated and I haven't noticed 
any breakage yet.

--
keywords: +patch
Added file: http://bugs.python.org/file41390/http.client.put.fix.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-22 Thread Wiktor Niesiobedzki

Wiktor Niesiobedzki added the comment:

Here is revised patch. Also covers changes to tests.

--
Added file: http://bugs.python.org/file41392/http.client.put.fix.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-22 Thread SilentGhost

SilentGhost added the comment:

There is a test suite which can be run to test for breakages:

./python -m test test_httplib

If you do that you'll notice that some things are broken, I got error in 5 
different tests related to you select.select call:

TypeError: argument must be an int, or have a fileno() method. 

Your test code seems to be running fine now, though.

--
nosy: +SilentGhost

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-22 Thread SilentGhost

SilentGhost added the comment:

That was a testing issue, apparently test.test_httplib.FakeSocket is not fake 
enough.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-21 Thread R. David Murray

R. David Murray added the comment:

Perhaps by doing non-blocking reads between the writes[*]? I suppose it is 
possible, but it might complicate the code considerably.

[*] or re-write it using asyncio, but that is definitely out of scope :)

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-21 Thread SilentGhost

Changes by SilentGhost :


--
components: +Library (Lib) -IO
versions: +Python 3.5, Python 3.6 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-21 Thread Wiktor Niesiobedzki

New submission from Wiktor Niesiobedzki:

It looks like, when doing PUT together with a file-like object to send, 
http.client will try to send the whole file before analysing the response from 
the server.

If you do the following:
$ dd if=/dev/zero of=/tmp/300mb.zero bs=1M count=300

And then run following code in Python 3.4 (tested 3.4.3 on Linux and FreeBSD):
import http.client
conn = http.client.HTTPSConnection('api.onedrive.com')
req = conn.request(
method='PUT',
url='https://api.onedrive.com/v1.0/drives/me/root:/test.file:/content',
body=open("/tmp/300mb.zero", "rb"))
resp = conn.getresponse()

You'll notice the hang. After some time, it will aborted with BrokenPipeError: 
[Errno 32] Broken pipe. If you run the following code within pdb debugger, and 
interrupt, you'll probably interrupt somewhere within write loop. You can call 
self.read() and see, that HTTP 413 is waiting to be interpreted.

Doing similar action with curl:
$ $ curl -v -T /tmp/300mb.zero 
https://api.onedrive.com/v1.0/drives/me/root:/test.file:/content

Gives you immediate HTTP 413 error. Can we have the same behaviour in 
http.client library?

--
components: IO
messages: 256808
nosy: Wiktor Niesiobedzki
priority: normal
severity: normal
status: open
title: htp.client PUT method ignores error responses sent immediatly after 
headers
type: behavior
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com