improvements for httpcore (#12228)

* improvements for httpcore
* further improvements, now stable API but needs extensions later on
This commit is contained in:
Andreas Rumpf 2019-09-23 12:38:35 +02:00 • committed by GitHub
commit b865c2a54b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 44 deletions

View file

@ -847,7 +847,7 @@ proc newConnection(client: HttpClient | AsyncHttpClient,
proc override(fallback, override: HttpHeaders): HttpHeaders =
# Right-biased map union for `HttpHeaders`
if override.isNil:
if override.isEmpty:
return fallback
result = newHttpHeaders()
@ -858,7 +858,7 @@ proc override(fallback, override: HttpHeaders): HttpHeaders =
proc requestAux(client: HttpClient | AsyncHttpClient, url: string,
httpMethod: string, body = "",
headers: HttpHeaders = nil): Future[Response | AsyncResponse]
headers = EmptyHttpHeaders): Future[Response | AsyncResponse]
{.multisync.} =
# Helper that actually makes the request. Does not handle redirects.
let requestUrl = parseUri(url)
@ -892,7 +892,7 @@ proc requestAux(client: HttpClient | AsyncHttpClient, url: string,
proc request*(client: HttpClient | AsyncHttpClient, url: string,
httpMethod: string, body = "",
headers: HttpHeaders = nil): Future[Response | AsyncResponse]
headers = EmptyHttpHeaders): Future[Response | AsyncResponse]
{.multisync.} =
## Connects to the hostname specified by the URL and performs a request
## using the custom method string specified by ``httpMethod``.
@ -917,7 +917,7 @@ proc request*(client: HttpClient | AsyncHttpClient, url: string,
proc request*(client: HttpClient | AsyncHttpClient, url: string,
httpMethod = HttpGet, body = "",
headers: HttpHeaders = nil): Future[Response | AsyncResponse]
headers = EmptyHttpHeaders): Future[Response | AsyncResponse]
{.multisync.} =
## Connects to the hostname specified by the URL and performs a request
## using the method specified.