-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'refs/pull/129/head' of github.com:twisted/treq into 129…
…-httpclient-docs
- Loading branch information
Showing
3 changed files
with
45 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from treq.client import HTTPClient | ||
from _utils import print_response | ||
from twisted.internet.task import react | ||
from twisted.web.client import Agent | ||
|
||
def make_custom_agent(reactor): | ||
return Agent(reactor, connectTimeout=42) | ||
|
||
def main(reactor, *args): | ||
agent = make_custom_agent(reactor) | ||
http_client = HTTPClient(agent) | ||
d = http_client.get( | ||
'https://secure.example.net/area51', | ||
auth=('admin', "you'll never guess!")) | ||
d.addCallback(print_response) | ||
return d | ||
|
||
react(main, []) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters