-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0a7ea0
commit 8dd3871
Showing
1 changed file
with
10 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,9 @@ | |
import types | ||
import re | ||
from six.moves.urllib.parse import urlencode, quote_plus, urlparse | ||
|
||
from .version import VERSION | ||
|
||
|
||
# use urlfetch as request_lib on google app engine, otherwise use requests | ||
request_lib = None | ||
try: | ||
|
@@ -18,6 +18,7 @@ | |
try: | ||
import requests | ||
request_lib = 'requests' | ||
requests_session = requests.Session() | ||
except ImportError: | ||
raise ImportError('EasyPost requires an up to date requests library. ' | ||
'Update requests via "pip install -U requests" or ' | ||
|
@@ -308,7 +309,14 @@ def requests_request(self, method, abs_url, headers, params): | |
"Please report to [email protected]." % method) | ||
|
||
try: | ||
result = requests.request(method, abs_url, headers=headers, data=data, timeout=60, verify=True) | ||
result = requests_session.request( | ||
method, | ||
abs_url, | ||
headers=headers, | ||
data=data, | ||
timeout=60, | ||
verify=True, | ||
) | ||
http_body = result.text | ||
http_status = result.status_code | ||
except Exception as e: | ||
|