]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Documented netrc support (#225)
authorCan Sarıgöl <cansarigol@derinbilgi.com.tr>
Sat, 17 Aug 2019 16:07:04 +0000 (19:07 +0300)
committerSeth Michael Larson <sethmichaellarson@gmail.com>
Sat, 17 Aug 2019 16:07:04 +0000 (11:07 -0500)
README.md
docs/advanced.md
docs/index.md

index 9a2c846a5a6d94a93389ed3f88efa257c5861292..c8f68d77f64ca59b3987d311cf3c4c9cc47ac57b 100644 (file)
--- 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
index 3c957ae27b7d36447199447c2255b5a4bc4a0f40..5ecf5a62c18e4b6e91bb2fab1821434f06c64060 100644 (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
+
+...
+```
index 4d0287cf544a22ee579ab19b15d37876b879c578..40813c63b7efa5aa8826f278557954bbdfa7953e 100644 (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