From 4ba9a2ffbee6cc608b272e8b7f683ff24b62722d Mon Sep 17 00:00:00 2001 From: ZoaR <460891016@qq.com> Date: Mon, 24 Jan 2022 20:00:30 +0800 Subject: [PATCH] net.http: implement a Request.allow_redirect field (true by default) (#13259) --- vlib/net/http/request.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/net/http/request.v b/vlib/net/http/request.v index c32cf2c35b..a1f0c66615 100644 --- a/vlib/net/http/request.v +++ b/vlib/net/http/request.v @@ -33,6 +33,7 @@ pub mut: cert string cert_key string in_memory_verification bool // if true, verify, cert, and cert_key are read from memory, not from a file + allow_redirect bool = true //whether to allow redirect } fn (mut req Request) free() { @@ -63,6 +64,9 @@ pub fn (req &Request) do() ?Response { } qresp := req.method_and_url_to_response(req.method, rurl) ? resp = qresp + if !req.allow_redirect { + break + } if resp.status() !in [.moved_permanently, .found, .see_other, .temporary_redirect, .permanent_redirect] { break