User-agent lookup 

likely in `requests.utils.agents`


Is this a feature request?  I don't see anything about user agents in requests.utils at present... (New to the codebase, but I've walked through this module and follow it pretty easily).


Feature request indeed :)


Could you eludicate on the requirements of this feature so I can build it to spec?  What sorts of functionality are you envisioning?


I'd love for it to be similar to `requests.codes`, but for looking up browser string user agents.

My thought is something like this

`requests.utils.agents`

``` pycon
>>> agents['firefox']
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"

>>> agents['chrome']['osx']
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"
```

I'm a bit torn on the API, but I think that this could work well.


Thoughts/feedback appreciated.


So you store browsers default user agents in the code somewhere?
That could be helpful indeed


For what could this be used? 


@FSX: attaching a user-agent to a request. 

Use cases: When a site blocks non-browsers from making requests. Maybe also testing?


Setting a fake user agent to pretend you are firefox instead of an automatic request made by a piece of code.


Ok. Doing that manually is not much work, but less work is always nice.


Yeah, that's why I'm hesitant to implement. Would love other opinions.


I found an xml dump of many known user-agents [here](http://www.user-agents.org/allagents.xml).  Looks like it could be pretty helpful.

Additionally, [RFC 1945](http://tools.ietf.org/html/rfc1945) provides the following helpful definition about user-agents:

### 10.15  User-Agent

```
Publisher-Subscriber based events infrastructure for asynchronous message 
passing between services.

The User-Agent request-header field contains information about the
user agent originating the request. This is for statistical purposes,
the tracing of protocol violations, and automated recognition of user
agents for the sake of tailoring responses to avoid particular user
agent limitations. Although it is not required, user agents should
include this field with requests. The field can contain multiple
product tokens (Section 3.7) and comments identifying the agent and
any subproducts which form a significant part of the user agent. By
convention, the product tokens are listed in order of their
significance for identifying the application.

    User-Agent     = "User-Agent" ":" 1*( product | comment )

Example:

    User-Agent: CERN-LineMode/2.15 libwww/2.17b3
```

Some upfront things stand out about the vast space of user agents:

### Notes
- Most modern browsers keep `Mozilla/5.0` upfront for compatibility reasons.  It initially was meant to signify that the browser was "Mozilla compatible" ([source](https://developer.mozilla.org/en/Gecko_user_agent_string_reference)), but is now widely adopted.
- The platform field is not specific to just "osx" or "linux".  It seems like there is more a fine-grained description of platform (e.g. `(Windows; U; Windows NT 5.1; de; rv:1.9.2.3)` or `(Macintosh; Intel Mac OS X 10.7; rv:7.0.1)`).

### Questions
- Are we interested in supporting the vast space of user agents, or just popular browsers?


The more I think about this, the more I think it's unnecessary. It would be useful under certain occasions, but it would be best in a separate module.