Skip to content

sync chunked requests proxy updates #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plotly/graph_reference/default-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7017,7 +7017,7 @@
"valType": "string"
}
},
"description": "The data that describes the heatmap value-to-color mapping is set in `z`. Data in `z` can either be a {2D array} of values (ragged or not) or a 1D array of values. In the case where `z` is a {2D array}, say that `z` has N rows and M columns. Then, by default, the resulting heatmap will have N partitions along the y axis and M partitions along the x axis. In other words, the i-th row/ j-th column cell in `z` is mapped to the i-th partition of the y axis (starting from the bottom of the plot) and the j-th partition of the x-axis (starting from the left of the plot). This behavior can be flipped by using `transpose`. Moreover, `x` (`y`) can be provided with M or M+1 (N or N+1) elements If M (N), then the coordinates correspond to the center of the heatmap cells and the cells have equal width. If M+1 (N+1), then the coordinates correspond to the edges of the heatmap cells. In the case where `z` is a 1D {array}, the x and y coordinates must be provided in `x` and `y` respectively to form data triplets."
"description": "The data that describes the heatmap value-to-color mapping is set in `z`. Data in `z` can either be a {2D array} of values (ragged or not) or a 1D array of values. In the case where `z` is a {2D array}, say that `z` has N rows and M columns. Then, by default, the resulting heatmap will have N partitions along the y axis and M partitions along the x axis. In other words, the i-th row/ j-th column cell in `z` is mapped to the i-th partition of the y axis (starting from the bottom of the plot) and the j-th partition of the x-axis (starting from the left of the plot). This behavior can be flipped by using `transpose`. Moreover, `x` (`y`) can be provided with M or M+1 (N or N+1) elements. If M (N), then the coordinates correspond to the center of the heatmap cells and the cells have equal width. If M+1 (N+1), then the coordinates correspond to the edges of the heatmap cells. In the case where `z` is a 1D {array}, the x and y coordinates must be provided in `x` and `y` respectively to form data triplets."
},
"histogram": {
"attributes": {
Expand Down
34 changes: 24 additions & 10 deletions plotly/plotly/chunked_requests/chunked_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,38 @@ def write(self, data, reconnect_on=('', 200, )):
self._reconnect()
self.write(data)

def _get_proxy_config(self):
"""
Determine if self._url should be passed through a proxy. If so, return
the appropriate proxy_server and proxy_port

"""

proxy_server = None
proxy_port = None

## only doing HTTPConnection, so only use http_proxy
proxy = os.environ.get("http_proxy")
no_proxy = os.environ.get("no_proxy")
no_proxy_url = no_proxy and self._url in no_proxy

if proxy and not no_proxy_url:
p = urlparse(proxy)
proxy_server = p.hostname
proxy_port = p.port

return proxy_server, proxy_port

def _connect(self):
''' Initialize an HTTP connection with chunked Transfer-Encoding
to server:port with optional headers.
'''
server = self._server
port = self._port
headers = self._headers
proxy_server, proxy_port = self._get_proxy_config()

## only doing HTTPConnection, so only use http_proxy
proxy = os.environ.get("http_proxy");
proxy_server = None
proxy_port = None
if (proxy != None):
p = urlparse(proxy)
proxy_server = p.hostname
proxy_port = p.port

if (proxy_server != None and proxy_port != None):
if (proxy_server and proxy_port):
self._conn = http_client.HTTPConnection(proxy_server, proxy_port)
self._conn.set_tunnel(server, port)
else:
Expand Down
2 changes: 1 addition & 1 deletion submodules/chunked_requests
Submodule chunked_requests updated 2 files
+24 −10 chunked_requests/chunked_request.py
+37 −0 test/tests.py