Skip to content

Commit

Permalink
Merge 6a185db into 41bd15a
Browse files Browse the repository at this point in the history
  • Loading branch information
jayanthchandra committed Jul 30, 2019
2 parents 41bd15a + 6a185db commit 3ef4358
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions usp/web_client/requests_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests
from requests import Response
from requests import exceptions

from .abstract_client import AbstractWebClientResponse, AbstractWebClient
from usp.__about__ import __version__
Expand Down Expand Up @@ -64,13 +65,18 @@ def set_max_response_data_length(self, max_response_data_length: int) -> None:
self.__max_response_data_length = max_response_data_length

def get(self, url: str) -> RequestsWebClientResponse:
response = requests.get(
url,
timeout=self.__HTTP_REQUEST_TIMEOUT,
stream=True,
headers={'User-Agent': self.__USER_AGENT},
)
try:
response = requests.get(
url,
timeout=self.__HTTP_REQUEST_TIMEOUT,
stream=True,
headers={'User-Agent': self.__USER_AGENT},
)
except exceptions.ConnectionError as conn_error:
response = Response()
response.status_code = 444
return RequestsWebClientResponse(
requests_response=response,
max_response_data_length=self.__max_response_data_length,
)

0 comments on commit 3ef4358

Please sign in to comment.