New runnableExample for newAsyncHttpClient() (#14045)
This commit is contained in:
parent
7beed44fc9
commit
1a44b7e3ce
1 changed files with 11 additions and 0 deletions
|
|
@ -573,6 +573,17 @@ proc newHttpClient*(userAgent = defUserAgent, maxRedirects = 5,
|
|||
## ``TimeoutError`` is raised.
|
||||
##
|
||||
## ``headers`` specifies the HTTP Headers.
|
||||
runnableExamples:
|
||||
import asyncdispatch, httpclient, strutils
|
||||
|
||||
proc asyncProc(): Future[string] {.async.} =
|
||||
var client = newAsyncHttpClient()
|
||||
return await client.getContent("http://example.com")
|
||||
|
||||
let exampleHtml = waitFor asyncProc()
|
||||
assert "Example Domain" in exampleHtml
|
||||
assert not ("Pizza" in exampleHtml)
|
||||
|
||||
new result
|
||||
result.headers = headers
|
||||
result.userAgent = userAgent
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue