Skip to content

Commit

Permalink
[req] 'AutoDiscard' now doesn't affect responses with successful resp…
Browse files Browse the repository at this point in the history
…onse status codes (200-299)
  • Loading branch information
andyone committed Oct 16, 2024
1 parent 2b36109 commit 28ae902
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions req/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package ek
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION is current ek package version
const VERSION = "13.8.0"
const VERSION = "13.8.1"

0 comments on commit 28ae902

Please sign in to comment.