Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DISCUSSION: Allow http as an argument to Connection so libraries other than httplib2 can be used #551

Closed
dhermes opened this issue Jan 15, 2015 · 1 comment · Fixed by #608
Assignees
Labels
api: core type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. type: question Request for information or clarification. Not an issue.

Comments

@dhermes
Copy link
Contributor

dhermes commented Jan 15, 2015

This way we can support people using Twisted (for example) or other frameworks without having to write any other code. Though docs could be nice? We could supply an abstract class for them to subclass?


As of 12ac983:

$ git log -1 --pretty=%H
12ac983fe613785c998aeeb1d8b981f4b5b347d9
$ git grep '\.http' -- gcloud/ | egrep -v 'test'
gcloud/datastore/connection.py:        :raises: :class:`six.moves.http_client.HTTPException` if the response
gcloud/datastore/connection.py:        headers, content = self.http.request(
gcloud/datastore/connection.py:            raise six.moves.http_client.HTTPException(message)
gcloud/storage/connection.py:        return self.http.request(uri=url, method=method, headers=headers,
gcloud/storage/key.py:        download.InitializeDownload(request, self.connection.http)
gcloud/storage/key.py:        upload.InitializeUpload(request, conn.http)
gcloud/storage/key.py:            http_wrapper.MakeRequest(conn.http, request, retries=num_retries)

We only actively use the httplib2.Http() instance twice. Once in storage.connection.Connection.make_request:

        return self.http.request(uri=url, method=method, headers=headers,
                                 body=data)

and once in datastore.connection.Connection._request:

        headers, content = self.http.request(
            uri=self.build_api_url(dataset_id=dataset_id, method=method),
            method='POST', headers=headers, body=data)

In either case the object only needs to be able to accept

  • uri
  • method
  • headers
  • body

and needs to append a

Authorization: Bearer ya29.some-OAUTH-TOKEN...

header to headers. (See the source, the user agent is also updated and the request is retried if a 401 Unauthorized is encountered, but an external client need not do either of those.)


ASIDE: Should we add an auth label?

@dhermes dhermes added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. type: question Request for information or clarification. Not an issue. labels Jan 15, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Jan 15, 2015

Other things to note:

  1. As seen above, the httplib2.Http() instance is passed along to our vendored in apitools code.
  2. The credentials object is used in storage.Connection.generate_signed_url (and nowhere else):
$ git grep -n '\.credentials' | egrep -v 'test'
gcloud/storage/connection.py:550:        query_params = _get_signed_query_params(self.credentials,

@jgeewax jgeewax modified the milestone: Core Stable Jan 30, 2015
@dhermes dhermes modified the milestones: Core Stable, Core Future Feb 9, 2015
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Feb 10, 2015
This will allow libraries other than httplib2 to be used.

Fixes googleapis#551.
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Feb 10, 2015
This will allow libraries other than httplib2 to be used.

Fixes googleapis#551.
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Feb 12, 2015
This will allow libraries other than httplib2 to be used.

Fixes googleapis#551.
vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
* chore(deps): update all dependencies

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* revert

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this issue Sep 22, 2023
* docs: Minor formatting

PiperOrigin-RevId: 552889922

Source-Link: googleapis/googleapis@34a499a

Source-Link: googleapis/googleapis-gen@3fb6cbe
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2ZiNmNiZTc5YzFiYTI5MDc1NzQyOWE3NDM2MmQ4ZGNiYWQ5MTEwYyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
)

Source-Link: googleapis/synthtool@d6103f4
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:39f0f3f2be02ef036e297e376fe3b6256775576da8a6ccb1d5eeb80f4c8bf8fb

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants