From: Can Sarıgöl Date: Sat, 17 Aug 2019 16:07:04 +0000 (+0300) Subject: Documented netrc support (#225) X-Git-Tag: 0.7.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21939fdaa873c1a8e9ee6398e92c91022a8ba91b;p=thirdparty%2Fhttpx.git Documented netrc support (#225) --- diff --git a/README.md b/README.md index 9a2c846a..c8f68d77 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/advanced.md b/docs/advanced.md index 3c957ae2..5ecf5a62 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -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 + +... +``` diff --git a/docs/index.md b/docs/index.md index 4d0287cf..40813c63 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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