Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
3ed1d3e7
Commit
3ed1d3e7
authored
8 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Add proxy to connection handlers
parent
70f4bc28
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
duniterpy/api/bma/api.py
+7
-4
7 additions, 4 deletions
duniterpy/api/bma/api.py
duniterpy/documents/peer.py
+4
-4
4 additions, 4 deletions
duniterpy/documents/peer.py
with
11 additions
and
8 deletions
duniterpy/api/bma/api.py
+
7
−
4
View file @
3ed1d3e7
...
...
@@ -43,7 +43,7 @@ ERROR_SCHEMA = {
class
ConnectionHandler
(
object
):
"""
Helper class used by other API classes to ease passing server connection information.
"""
def
__init__
(
self
,
http_scheme
,
ws_scheme
,
server
,
port
,
session
=
None
):
def
__init__
(
self
,
http_scheme
,
ws_scheme
,
server
,
port
,
proxy
=
None
,
session
=
None
):
"""
Init instance of connection handler
...
...
@@ -54,6 +54,7 @@ class ConnectionHandler(object):
self
.
http_scheme
=
http_scheme
self
.
ws_scheme
=
ws_scheme
self
.
server
=
server
self
.
proxy
=
proxy
self
.
port
=
port
self
.
session
=
session
...
...
@@ -152,7 +153,8 @@ class API(object):
logging
.
debug
(
"
Request : {0}
"
.
format
(
self
.
reverse_url
(
self
.
connection_handler
.
http_scheme
,
path
)))
with
aiohttp
.
Timeout
(
15
):
url
=
self
.
reverse_url
(
self
.
connection_handler
.
http_scheme
,
path
)
response
=
await
self
.
connection_handler
.
session
.
get
(
url
,
params
=
kwargs
,
headers
=
self
.
headers
)
response
=
await
self
.
connection_handler
.
session
.
get
(
url
,
params
=
kwargs
,
headers
=
self
.
headers
,
proxy
=
self
.
connection_handler
.
proxy
)
if
response
.
status
!=
200
:
try
:
error_data
=
parse_error
(
await
response
.
text
())
...
...
@@ -177,7 +179,8 @@ class API(object):
response
=
await
self
.
connection_handler
.
session
.
post
(
self
.
reverse_url
(
self
.
connection_handler
.
http_scheme
,
path
),
data
=
kwargs
,
headers
=
self
.
headers
headers
=
self
.
headers
,
proxy
=
self
.
connection_handler
.
proxy
)
return
response
...
...
@@ -189,4 +192,4 @@ class API(object):
:rtype: aiohttp.ClientWebSocketResponse
"""
url
=
self
.
reverse_url
(
self
.
connection_handler
.
ws_scheme
,
path
)
return
self
.
connection_handler
.
session
.
ws_connect
(
url
)
return
self
.
connection_handler
.
session
.
ws_connect
(
url
,
proxy
=
self
.
connection_handler
.
proxy
)
This diff is collapsed.
Click to expand it.
duniterpy/documents/peer.py
+
4
−
4
View file @
3ed1d3e7
...
...
@@ -180,7 +180,7 @@ class BMAEndpoint(Endpoint):
IPv6
=
(
"
{0}
"
.
format
(
self
.
ipv6
)
if
self
.
ipv6
else
""
),
PORT
=
(
"
{0}
"
.
format
(
self
.
port
)
if
self
.
port
else
""
))
def
conn_handler
(
self
,
session
=
None
):
def
conn_handler
(
self
,
session
=
None
,
proxy
=
None
):
"""
Return connection handler instance for the endpoint
...
...
@@ -188,11 +188,11 @@ class BMAEndpoint(Endpoint):
:rtype: ConnectionHandler
"""
if
self
.
server
:
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
self
.
server
,
self
.
port
,
session
)
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
self
.
server
,
self
.
port
,
proxy
,
session
)
elif
self
.
ipv4
:
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
self
.
ipv4
,
self
.
port
,
session
)
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
self
.
ipv4
,
self
.
port
,
proxy
,
session
)
else
:
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
"
[{0}]
"
.
format
(
self
.
ipv6
),
self
.
port
,
session
)
return
ConnectionHandler
(
"
http
"
,
"
ws
"
,
"
[{0}]
"
.
format
(
self
.
ipv6
),
self
.
port
,
proxy
,
session
)
def
__str__
(
self
):
return
self
.
inline
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment