From 28ae9028b38423807e3c7431aafe1026f54a23ce Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 17 Oct 2024 02:14:09 +0300 Subject: [PATCH] [req] 'AutoDiscard' now doesn't affect responses with successful response status codes (200-299) --- CHANGELOG.md | 4 ++++ req/req.go | 4 ++-- version.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd58f822..d156e8b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### [13.8.1](https://kaos.sh/ek/13.8.1) + +- `[req]` `AutoDiscard` now doesn't affect responses with successful response status codes (`200`-`299`) + ### [13.8.0](https://kaos.sh/ek/13.8.0) - `[knf/validators]` Added support of `int64`, `uint`, and `uint64` to `Less` vaildator diff --git a/req/req.go b/req/req.go index 8624e7c6..4670858b 100644 --- a/req/req.go +++ b/req/req.go @@ -199,7 +199,7 @@ type Request struct { BasicAuthUsername string // Basic auth username BasicAuthPassword string // Basic auth password BearerAuth string // Bearer auth token - AutoDiscard bool // Automatically discard all responses with status code != 200 + AutoDiscard bool // Automatically discard all responses with status code > 299 FollowRedirect bool // Follow redirect Close bool // Close indicates whether to close the connection after sending request } @@ -614,7 +614,7 @@ func (e *Engine) doRequest(r Request, method string) (*Response, error) { result := &Response{resp, r.URL} - if resp.StatusCode != STATUS_OK && r.AutoDiscard { + if resp.StatusCode > 299 && r.AutoDiscard { result.Discard() } diff --git a/version.go b/version.go index 2ffec021..8f66647d 100644 --- a/version.go +++ b/version.go @@ -8,4 +8,4 @@ package ek // ////////////////////////////////////////////////////////////////////////////////// // // VERSION is current ek package version -const VERSION = "13.8.0" +const VERSION = "13.8.1"