Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-cloud / recipes-devtools / python / files / requests / 0001-close-connection-on-HTTP-413-Request-Entit.patch
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
5  Large
6
7 Allow low_conn to retrieve/handle unread response data buffers
8 in case ProtocolError or socket.error are raised while sending
9 request data.
10 ---
11  requests/adapters.py | 18 ++++++++++++------
12  1 file changed, 12 insertions(+), 6 deletions(-)
13
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):
19
20                      low_conn.endheaders()
21
22 -                    for i in request.body:
23 -                        low_conn.send(hex(len(i))[2:].encode('utf-8'))
24 -                        low_conn.send(b'\r\n')
25 -                        low_conn.send(i)
26 -                        low_conn.send(b'\r\n')
27 -                    low_conn.send(b'0\r\n\r\n')
28 +                    try:
29 +                        for i in request.body:
30 +                            low_conn.send(hex(len(i))[2:].encode('utf-8'))
31 +                            low_conn.send(b'\r\n')
32 +                            low_conn.send(i)
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
39 +                        pass
40
41                      # Receive the response from the server
42                      try:
43 -- 
44 1.8.3.1
45