Documented netrc support (#225)

This commit is contained in:
Can Sarıgöl 2019-08-17 19:07:04 +03:00 committed by Seth Michael Larson
parent 04d5ffb01b
commit 21939fdaa8
3 changed files with 30 additions and 2 deletions

View File

@ -65,7 +65,7 @@ Plus all the standard features of `requests`...
* HTTP(S) Proxy Support *(TODO)*
* Connection Timeouts
* Streaming Downloads
* .netrc Support *(TODO)*
* .netrc Support
* Chunked Requests
## Installation

View File

@ -41,3 +41,31 @@ r = client.get('http://example/')
assert r.status_code == 200
assert r.text == "Hello World!"
```
## .netrc Support
HTTPX supports .netrc file. In `trust_env=True` cases, if auth parameter is
not defined, HTTPX tries to add auth into request's header from .netrc file.
As default `trust_env` is true. To set false:
```python
>>> httpx.get('https://example.org/', trust_env=False)
```
If `NETRC` environment is empty, HTTPX tries to use default files.
(`~/.netrc`, `~/_netrc`)
To change `NETRC` environment:
```python
>>> import os
>>> os.environ["NETRC"] = "my_default_folder/.my_netrc"
```
.netrc file content example:
```
machine netrcexample.org
login example-username
password example-password
...
```

View File

@ -75,7 +75,7 @@ Plus all the standard features of `requests`...
* HTTP(S) Proxy Support *(TODO)*
* Connection Timeouts
* Streaming Downloads
* .netrc Support *(TODO)*
* .netrc Support
* Chunked Requests
## Documentation