Skip to content

Commit

Permalink
Merge pull request #11 from saucelabs/dans-runtime
Browse files Browse the repository at this point in the history
response handler panics - resolves issue #10
  • Loading branch information
waggledans authored Apr 21, 2022
2 parents 514f948 + a0b271e commit b169472
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Use of this source code is governed by a MIT
# license that can be found in the LICENSE file.

---
run:
timeout: 1m
skip-files:
Expand All @@ -25,7 +26,7 @@ linters:
# Settings for specific linters
linters-settings:
gocognit:
min-complexity: 35
min-complexity: 40

funlen:
lines: 200
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Load config from Config file, and from env vars. Use viper for that
- Automatically alocates a random port, if the specified one is in-use

## [0.1.20] - 2022-04-21
## Changed
- Upgrade goproxy library to the latest master
- Check that the response struct is allocated before logging its details

## [0.1.19] - 2022-04-18
## Changed
- Revert the changes introduced in 0.1.18
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/eapache/go-resiliency v1.2.0
github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac
github.com/elazarl/goproxy v0.0.0-20220417044921-416226498f94
github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac
github.com/go-playground/validator/v10 v10.10.0
github.com/saucelabs/customerror v1.0.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUK
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac h1:XDAn206aIqKPdF5YczuuJXSQPx+WOen0Pxbxp5Fq8Pg=
github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy v0.0.0-20220417044921-416226498f94 h1:VIy7cdK7ufs7ctpTFkXJHm1uP3dJSnCGSPysEICB1so=
github.com/elazarl/goproxy v0.0.0-20220417044921-416226498f94/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac h1:9yrT5tmn9Zc0ytWPASlaPwQfQMQYnRf0RSDe1XvHw0Q=
github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
Expand Down
8 changes: 6 additions & 2 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,12 @@ func New(
})

p.proxy.OnResponse().DoFunc(func(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
logger.Get().Debuglnf("%s <- %s %v (%v bytes)",
resp.Request.RemoteAddr, resp.Request.Host, resp.Status, resp.ContentLength)
if resp != nil {
logger.Get().Debuglnf("%s <- %s %v (%v bytes)",
resp.Request.RemoteAddr, resp.Request.Host, resp.Status, resp.ContentLength)
} else {
logger.Get().Tracelnf("%s <- %s response is empty", ctx.Req.Host, ctx.Req.RemoteAddr)
}

return resp
})
Expand Down

0 comments on commit b169472

Please sign in to comment.