aboutsummaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
authorGravatar brian-armstrong-discord <brian.armstrong@discordapp.com> 2022-11-03 13:25:19 -0700
committerGravatar GitHub <noreply@github.com> 2022-11-03 21:25:19 +0100
commitf095481f0014ab50fc4c8593d6751ab3584b2457 (patch)
treea869320f271db2cf073dab304f923f1695ecf2fa /http.go
parentfix form empty field error when used with pipe (#1417) (diff)
downloadfasthttp-f095481f0014ab50fc4c8593d6751ab3584b2457.tar.gz
fasthttp-f095481f0014ab50fc4c8593d6751ab3584b2457.tar.bz2
fasthttp-f095481f0014ab50fc4c8593d6751ab3584b2457.zip
Request.SetTimeout (#1415)
* Request.SetTimeout This functionally works the same as e.g. Client.DoTimeout(), but we can also use it for Client.DoRedirect(). There is no way as far as I can tell to set a timeout on a DoRedirect call, so this makes it possible. * tests * docs
Diffstat (limited to 'http.go')
-rw-r--r--http.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/http.go b/http.go
index 4ef3744..4b9e113 100644
--- a/http.go
+++ b/http.go
@@ -2290,3 +2290,11 @@ func round2(n int) int {
return int(x + 1)
}
+
+// SetTimeout sets timeout for the request.
+//
+// req.SetTimeout(t); c.Do(&req, &resp) is equivalent to
+// c.DoTimeout(&req, &resp, t)
+func (req *Request) SetTimeout(t time.Duration) {
+ req.timeout = t
+}