Merge commit '176d462b076db24d9f71ddb40163d1ef82823771' into dev/etan/zz-dbg

This commit is contained in:
Etan Kissling 2023-09-12 22:43:46 +02:00
commit 24b87864a0
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 14 additions and 3 deletions

View File

@ -13,7 +13,7 @@ import ../../streams/[asyncstream, tlsstream, chunkstream, boundstream]
import httptable, httpcommon, httpagent, httpbodyrw, multipart
export results, asyncloop, asyncsync, asyncstream, tlsstream, chunkstream,
boundstream, httptable, httpcommon, httpagent, httpbodyrw, multipart,
httputils
httputils, uri
export SocketFlags
const
@ -1336,8 +1336,13 @@ proc redirect*(request: HttpClientRequestRef,
if redirectCount > request.session.maxRedirections:
err("Maximum number of redirects exceeded")
else:
let headers =
block:
var res = request.headers
res.set(HostHeader, ha.hostname)
res
var res = HttpClientRequestRef.new(request.session, ha, request.meth,
request.version, request.flags, request.headers.toList(), request.buffer)
request.version, request.flags, headers.toList(), request.buffer)
res.redirectCount = redirectCount
ok(res)
@ -1354,8 +1359,14 @@ proc redirect*(request: HttpClientRequestRef,
err("Maximum number of redirects exceeded")
else:
let address = ? request.session.redirect(request.address, uri)
# Update Host header to redirected URL hostname
let headers =
block:
var res = request.headers
res.set(HostHeader, address.hostname)
res
var res = HttpClientRequestRef.new(request.session, address, request.meth,
request.version, request.flags, request.headers.toList(), request.buffer)
request.version, request.flags, headers.toList(), request.buffer)
res.redirectCount = redirectCount
ok(res)