Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caucase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
caucase
Commits
b5eab640
Commit
b5eab640
authored
Feb 02, 2021
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: Catch SSL errors.
parent
3751896f
Pipeline
#13441
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
caucase/client.py
caucase/client.py
+25
-4
No files found.
caucase/client.py
View file @
b5eab640
...
...
@@ -36,6 +36,8 @@ from . import version
__all__
=
(
'CaucaseError'
,
'CaucaseHTTPError'
,
'CaucaseSSLError'
,
'CaucaseClient'
,
'HTTPSOnlyCaucaseClient'
,
)
...
...
@@ -43,11 +45,23 @@ __all__ = (
_cryptography_backend
=
default_backend
()
class
CaucaseError
(
Exception
):
"""
Base error for errors when communicating with a caucase server.
"""
pass
class
CaucaseHTTPError
(
CaucaseError
):
"""
Raised when server responds with an HTTP error status.
"""
pass
class
CaucaseSSLError
(
CaucaseError
):
"""
Raised when there is an SSL error while communicating with the server.
"""
pass
class
CaucaseClient
(
object
):
"""
Caucase HTTP(S) client.
...
...
@@ -171,11 +185,18 @@ class CaucaseClient(object):
path
=
self
.
_path
+
url
headers
=
headers
or
{}
headers
.
setdefault
(
'User-Agent'
,
'caucase '
+
version
.
__version__
)
connection
.
request
(
method
,
path
,
body
,
headers
)
response
=
connection
.
getresponse
()
response_body
=
response
.
read
()
try
:
connection
.
request
(
method
,
path
,
body
,
headers
)
response
=
connection
.
getresponse
()
response_body
=
response
.
read
()
except
ssl
.
SSLError
as
exc
:
raise
CaucaseSSLError
(
exc
.
errno
,
exc
.
strerror
)
if
response
.
status
>=
400
:
raise
CaucaseError
(
response
.
status
,
response
.
getheaders
(),
response_body
)
raise
CaucaseHTTPError
(
response
.
status
,
response
.
getheaders
(),
response_body
,
)
assert
response
.
status
<
300
# caucase does not redirect
if
response
.
status
==
201
:
return
response
.
getheader
(
'Location'
)
...
...
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