Skip to content
Merged
Changes from 4 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
16 changes: 16 additions & 0 deletions pusher_push_notifications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import datetime
import json
import os
import re
import time
import warnings
Expand Down Expand Up @@ -76,6 +77,13 @@ def _make_url(scheme, host, path):
])


def _get_proxies_from_env():
return {
'http': os.environ.get('HTTP_PROXY') or os.environ.get('http_proxy'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's case sensitive? :o

'https': os.environ.get('HTTPS_PROXY') or os.environ.get('https_proxy'),
}


class PushNotifications(object):
"""Pusher Push Notifications API client
This client class can be used to publish notifications to the Pusher
Expand Down Expand Up @@ -117,6 +125,14 @@ def _make_request(self, method, path, path_params, body=None):
url = _make_url(scheme='https', host=self.endpoint, path=path)

session = requests.Session()
# We've had multiple support requests about this library not working
# on PythonAnywhere (a popular python deployment platform)
# They require that proxy servers be loaded from the environment when
# making requests (on their free plan).
# This reintroduces the proxy support that is the default in requests
# anyway.
session.proxies = _get_proxies_from_env()

request = requests.Request(
method,
url,
Expand Down