File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -694,7 +694,7 @@ def http_request(
694
694
stream = streamed ,
695
695
** opts ,
696
696
)
697
- except requests .ConnectionError :
697
+ except ( requests .ConnectionError , requests . exceptions . ChunkedEncodingError ) :
698
698
if retry_transient_errors and (
699
699
max_retries == - 1 or cur_retries < max_retries
700
700
):
Original file line number Diff line number Diff line change @@ -129,6 +129,37 @@ def request_callback(request):
129
129
assert len (responses .calls ) == calls_before_success
130
130
131
131
132
+ @responses .activate
133
+ def test_http_request_with_retry_on_method_for_transient_network_failures_chunked (gl ):
134
+ call_count = 0
135
+ calls_before_success = 3
136
+
137
+ url = "http://localhost/api/v4/projects"
138
+
139
+ def request_callback (request ):
140
+ nonlocal call_count
141
+ call_count += 1
142
+ status_code = 200
143
+ headers = {}
144
+ body = "[]"
145
+
146
+ if call_count >= calls_before_success :
147
+ return (status_code , headers , body )
148
+ raise requests .exceptions .ChunkedEncodingError ("todo" )
149
+
150
+ responses .add_callback (
151
+ method = responses .GET ,
152
+ url = url ,
153
+ callback = request_callback ,
154
+ content_type = "application/json" ,
155
+ )
156
+
157
+ http_r = gl .http_request ("get" , "/projects" , retry_transient_errors = True )
158
+
159
+ assert http_r .status_code == 200
160
+ assert len (responses .calls ) == calls_before_success
161
+
162
+
132
163
@responses .activate
133
164
def test_http_request_with_retry_on_class_for_transient_failures (gl_retry ):
134
165
call_count = 0
You can’t perform that action at this time.
0 commit comments