1 From 268a1f179e554027637bd2951b24ad44ecb4a1ee Mon Sep 17 00:00:00 2001
2 From: Daniel Badea <daniel.badea@windriver.com>
3 Date: Wed, 7 Sep 2016 09:10:10 +0000
4 Subject: [PATCH] close connection on HTTP 413 Request Entity Too
7 Allow low_conn to retrieve/handle unread response data buffers
8 in case ProtocolError or socket.error are raised while sending
11 requests/adapters.py | 18 ++++++++++++------
12 1 file changed, 12 insertions(+), 6 deletions(-)
14 diff --git a/requests/adapters.py b/requests/adapters.py
15 index fd46325..087258a 100644
16 --- a/requests/adapters.py
17 +++ b/requests/adapters.py
18 @@ -466,12 +466,18 @@ class HTTPAdapter(BaseAdapter):
22 - for i in request.body:
23 - low_conn.send(hex(len(i))[2:].encode('utf-8'))
24 - low_conn.send(b'\r\n')
26 - low_conn.send(b'\r\n')
27 - low_conn.send(b'0\r\n\r\n')
29 + for i in request.body:
30 + low_conn.send(hex(len(i))[2:].encode('utf-8'))
31 + low_conn.send(b'\r\n')
33 + low_conn.send(b'\r\n')
34 + low_conn.send(b'0\r\n\r\n')
35 + except (ProtocolError, socket.error) as err:
36 + # allow low_conn to retrieve/handle unread response
37 + # data buffers in case ProtocolError or socket.error
38 + # are raised while sending request data
41 # Receive the response from the server