Define DNS used to resolve domain in request (suggestion)

For example:

```
    req = requests.post('https://'+self.server+'/'+method,
            data=json.dumps(kwargs),
            cert=self.certs,
            verify=self.verify,
            headers={'content-type': 'application/json' },
            dns=85.86.87.88
            )
```

This could be practical if requests are used (for example) in test suite which connects to more than one test environment, and each environment has its own DNS (code cannot rely on the DNS defined in the connection properities, /etc/hosts and so on.

At the moment connection must be patched at a lower level to achieve this, and in the end it takes less code when I use socket + ssl instead of requests (in the whole project).

I am aware that this use is not very, but it may be useful in the future.


Thanks for the suggestion!

Unfortunately, this is not something we're going to accept. We've got the requests API in feature freeze, as we believe that the 90% use-case is covered. We won't accept extensions to the API unless we think it's going to be generally useful, and I don't believe that this will be.

If you're genuinely finding that you need to connect to different DNS servers but that you can't control it at the level of `/etc/hosts` or having multiple connections then this is very challenging.

Note also that we build on top of `urllib3` and `httplib`, which do not expose this functionality, requiring that we take away connection building logic from `httplib` even further than we currently do. That's not really a good idea. =(


I agree entirely with @Lukasa. You may want to investigate how (if at all) other libraries do this @taku-pl like [httplib2](https://github.com/jcgregorio/httplib2) or [httpplus](https://code.google.com/p/httpplus/) and use them instead if possible.


I understand, and I already investigated, that's why I asked if this is at all possible, because it would be a lot, lot easier using requests :)
Unfortuantely in the case I described there's no way to modify /etc/hosts: one of the reasons is that multiple tests run simultaneously, and usually on more than two environments, so global change is out of the question. Besides, we wouldn't want to run them as root :)

For some time I digged all the way down and patched httplib/urllib2, but it got too complicated to maintain the code with new cases (verifying self-signed test certificates, SNI support and such), and the patched code now is much more complicated than 'simply' (ahem :) ) use httplib/urllib.

Thanks for the feedback. Looks like I'll have to bid farewell to requests in this project :/


P.S. Just for laughs, this is not intended as a mean comment :)

I spent a few afternoons trying to hack httplub and urllib 2/3 to get what I want (custom resolving with SSL+SNI support for verification). That's because I wanted to rely solely on python to do this. Today, I tried  a completely different approach, and it replaced a few dozen lines of code:

return subprocess.check_output(["curl", '-v', '-k','https://'+domain, '--resolve', domain+':443:'+ip])

Works like a charm - returns a string with complete page content and certificate C/CN/O :) It's the exact opposite of _how_ I wanted to do this, but, well, it works.


Then you can probably do this with pyCurl @taku-pl. I always forget it's an option because of its terrible API. =P