Conversation
|
Thanks for attention and contribution! Also, this functionality should be covered by tests. |
| def send_message_through_proxy(self, url, payload, receiver, proxy): | ||
| payload['chat_id'] = receiver | ||
| self.logger.debug('Sending message to %s . Using proxy' % receiver) | ||
| response = requests.post(url, data=payload, proxies=dict(http=proxy, https=proxy)) |
There was a problem hiding this comment.
I would prefer to refrain from the direct use of requests. Sentry has internal, unified utils to interact with network.
Please, look for safe_urlopen() built-in function. It supports params to pass additional options, like proxy-settings.
There was a problem hiding this comment.
We can't use params because this argument for query data https://github.com/requests/requests/blob/master/requests/sessions.py#L455
Is it worth to add PR to sentry for adding proxy functionality?
| ) | ||
| self.logger.debug('Response code: %s, content: %s' % (response.status_code, response.content)) | ||
|
|
||
| def send_message_through_proxy(self, url, payload, receiver, proxy): |
There was a problem hiding this comment.
This method looks like almost copy of send_message method.
I propose to use one send_message, and add proxies like this:
response = safe_urlopen(
method='POST',
url=url,
json=payload,
params=self.get_request_params(),
)
Where get_request_params() will return proxies settings, if it required.
There are several questions left