Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
surykatka
Commits
4c7900b1
Commit
4c7900b1
authored
Jul 19, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: handle ChunkedEncodingError
parent
cd0fb0d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
src/surykatka/http.py
src/surykatka/http.py
+4
-1
tests/test_http.py
tests/test_http.py
+13
-0
No files found.
src/surykatka/http.py
View file @
4c7900b1
...
@@ -74,7 +74,10 @@ def request(url, timeout=TIMEOUT, headers=None, session=requests, version=0):
...
@@ -74,7 +74,10 @@ def request(url, timeout=TIMEOUT, headers=None, session=requests, version=0):
except
requests
.
exceptions
.
ConnectionError
:
except
requests
.
exceptions
.
ConnectionError
:
response
=
requests
.
models
.
Response
()
response
=
requests
.
models
.
Response
()
response
.
status_code
=
523
response
.
status_code
=
523
except
requests
.
exceptions
.
Timeout
:
except
(
requests
.
exceptions
.
Timeout
,
requests
.
exceptions
.
ChunkedEncodingError
,
):
response
=
requests
.
models
.
Response
()
response
=
requests
.
models
.
Response
()
response
.
status_code
=
524
response
.
status_code
=
524
except
requests
.
exceptions
.
TooManyRedirects
:
except
requests
.
exceptions
.
TooManyRedirects
:
...
...
tests/test_http.py
View file @
4c7900b1
...
@@ -152,6 +152,19 @@ class SurykatkaHttpTestCase(unittest.TestCase):
...
@@ -152,6 +152,19 @@ class SurykatkaHttpTestCase(unittest.TestCase):
assert
mock_request
.
call_count
==
1
assert
mock_request
.
call_count
==
1
assert
response
.
status_code
==
524
,
response
.
status_code
assert
response
.
status_code
==
524
,
response
.
status_code
def
test_request_ChunkedEncodingError
(
self
):
url_to_proxy
=
"http://example.org/"
httpretty
.
register_uri
(
httpretty
.
GET
,
url_to_proxy
)
with
mock
.
patch
(
"surykatka.http.requests.request"
)
as
mock_request
:
def
sideEffect
(
*
args
,
**
kw
):
raise
surykatka
.
http
.
requests
.
exceptions
.
ChunkedEncodingError
()
mock_request
.
side_effect
=
sideEffect
response
=
request
(
url_to_proxy
)
assert
mock_request
.
call_count
==
1
assert
response
.
status_code
==
524
,
response
.
status_code
def
test_request_tooManyRedirect
(
self
):
def
test_request_tooManyRedirect
(
self
):
url_to_proxy
=
"http://example.org/"
url_to_proxy
=
"http://example.org/"
httpretty
.
register_uri
(
httpretty
.
GET
,
url_to_proxy
)
httpretty
.
register_uri
(
httpretty
.
GET
,
url_to_proxy
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment