Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Fix user agent string #398

Merged
merged 5 commits into from
May 28, 2019
Merged

Fix user agent string #398

merged 5 commits into from
May 28, 2019

Conversation

enriquejosepadilla
Copy link
Contributor

We previosuly thought we were sending the user agent string, but googleapis/google-api-python-client#656 showed us that it was implemented incorrectly. The additional code from utils is required until this
PR: googleapis/google-api-python-client#658 is merged.

django_cloud_deploy/cloudlib/_utils.py Outdated Show resolved Hide resolved
django_cloud_deploy/cloudlib/_utils.py Outdated Show resolved Hide resolved
connection_type=connection_type)
return resp, content

http.request = new_request
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, why can't subclass here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subclass google_auth_httplib2.AuthorizedHttp?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. That seems like the obvious way to customize a classes behavior and I was wondering if that would be more appropriate here.

@enriquejosepadilla
Copy link
Contributor Author

The newest version of google-api-python client fixes the bug that we encountered when trying to use this. Updated the package versioning as well as removed duplicate code.

Latest output of print statements:

------------Create Project-------
{'content-type': 'application/json', 'content-length': '108', 'accept': 'application/json', 'accept-encoding': 'gzip, deflate', 'user-agent': 'django-cloud-deploy/0.3.4 google-api-python-client/1.7.9 (gzip)'}

Which shows that the user agent string has been appeneded.

http=http_client)
auth_http = google_auth_httplib2.AuthorizedHttp(credentials)
user_agent = '/'.join(['django-cloud-deploy', __version__.__version__])
auth_http = http.set_user_agent(auth_http, user_agent)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auth_http = http.set_user_agent(auth_http, user_agent)
http.set_user_agent(auth_http, user_agent)

@enriquejosepadilla enriquejosepadilla merged commit ae772d9 into master May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants