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

Use a user-agent other than the httplib2 default. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ralphbean
Copy link

There is something about the default httplib2 user-agent that causes some web
servers to throw up.

Try this, for example::

>>> import httplib2
>>> h = httplib2.Http()
>>> response, content = h.request(
...   "http://ankursinha.in/blog/feed/")
>>> response.status
406
>>> response, content = h.request(
...   "http://ankursinha.in/blog/feed/",
...   headers={'user-agent': 'trololololololol 9000'})
>>> response.status
200

There is something about the default httplib2 user-agent that causes some web
servers to throw up.

Try this, for example::

    >>> import httplib2
    >>> h = httplib2.Http()
    >>> response, content = h.request(
    ...   "http://ankursinha.in/blog/feed/")
    >>> response.status
    406
    >>> response, content = h.request(
    ...   "http://ankursinha.in/blog/feed/",
    ...   headers={'user-agent': 'trololololololol 9000'})
    >>> response.status
    200
@james-see
Copy link

Adding a custom user agent mitigated my issue with BadStatusLine errors. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants