Skip to content

Commit

Permalink
Remove httplib2, replace with Requests (#3674)
Browse files Browse the repository at this point in the history
* Core: remove httplib2, replace with Requests

Additionally remove make_exception in favor of from_http_status and from_http_response.

* Datastore: replace httplib2 with Requests

* DNS: replace httplib2 with Requests

* Error Reporting: replace httplib2 with requests

* Language: replace httplib2 with Requests

* Logging: replace httplib2 with requests

* Monitoring: replace httplib2 with Requests

* Pubsub: replace httplib2 with Requests

* Resource Manager: replace httplib2 with Requests

* Runtimeconfig: replace httplib2 with Requests

* Speech: replace httplib2 with Requests

* Storage: replace httplib2 with Requests

* BigQuery: replace httplib2 with Requests

* Translate: replace httplib2 with Requests

* Vision: replace httplib2 with Requests
  • Loading branch information
Jon Wayne Parrott authored Jul 27, 2017
1 parent f5771fb commit 9f22095
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/google-cloud-vision/google/cloud/vision/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class Client(ClientWithProject):
passed), falls back to the default inferred from the
environment.
:type _http: :class:`~httplib2.Http`
:type _http: :class:`~requests.Session`
:param _http: (Optional) HTTP object to make requests. Can be any object
that defines ``request()`` with the same interface as
:meth:`~httplib2.Http.request`. If not passed, an
:meth:`requests.Session.request`. If not passed, an
``_http`` object is created that is bound to the
``credentials`` for the current object.
This parameter should be considered private, and could
Expand Down
15 changes: 9 additions & 6 deletions packages/google-cloud-vision/tests/unit/test__http.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def test_default_url(self):
self.assertEqual(conn._client, client)

def test_extra_headers(self):
import requests

from google.cloud import _http as base_http
from google.cloud.vision import _http as MUT

http = mock.Mock(spec=['request'])
response = mock.Mock(status=200, spec=['status'])
http = mock.create_autospec(requests.Session, instance=True)
response = requests.Response()
response.status_code = 200
data = b'brent-spiner'
http.request.return_value = response, data
response._content = data
http.request.return_value = response
client = mock.Mock(_http=http, spec=['_http'])

conn = self._make_one(client)
Expand All @@ -56,17 +60,16 @@ def test_extra_headers(self):
self.assertEqual(result, data)

expected_headers = {
'Content-Length': str(len(req_data)),
'Accept-Encoding': 'gzip',
base_http.CLIENT_INFO_HEADER: MUT._CLIENT_INFO,
'User-Agent': conn.USER_AGENT,
}
expected_uri = conn.build_api_url('/rainbow')
http.request.assert_called_once_with(
body=req_data,
data=req_data,
headers=expected_headers,
method='GET',
uri=expected_uri,
url=expected_uri,
)


Expand Down

0 comments on commit 9f22095

Please sign in to comment.