Skip to content

Commit

Permalink
chore: allow response body to be traced
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jun 9, 2020
1 parent b957b8e commit 4710769
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,12 @@ should you want to control log level in your tests, you can set it like so:
```go
pact := Pact{
...
LogLevel: "DEBUG", // One of DEBUG, INFO, ERROR, NONE
LogLevel: "DEBUG", // One of TRACE, DEBUG, INFO, ERROR, NONE
}
```
`TRACE` level logging will print the entire request/response cycle.
#### Check if the CLI tools are up to date
Pact ships with a CLI that you can also use to check if the tools are up to date. Simply run `pact-go install`, exit status `0` is good, `1` or higher is bad.
Expand Down
6 changes: 2 additions & 4 deletions proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ func HTTPReverseProxy(options Options) (int, error) {
Path: options.TargetPath,
}

// TODO: may be able to revert to the default single proxy
// and just override the transport!
proxy := createProxy(url, options.InternalRequestPathPrefix)
proxy.Transport = customTransport{tlsConfig: options.CustomTLSConfig}

Expand Down Expand Up @@ -142,7 +140,7 @@ func (c customTransport) RoundTrip(r *http.Request) (*http.Response, error) {
log.Println("[ERROR]", err)
return nil, err
}
b, err = httputil.DumpResponse(res, false)
b, err = httputil.DumpResponse(res, true)
log.Println("[TRACE] proxied server response\n", string(b))

return res, err
Expand All @@ -160,7 +158,7 @@ func createProxy(target *url.URL, ignorePrefix string) *httputil.ReverseProxy {
req.Host = target.Host

req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path)
log.Println("[DEBUG] outgoing request", req.URL)
log.Println("[DEBUG] outgoing request to target", req.URL)
if targetQuery == "" || req.URL.RawQuery == "" {
req.URL.RawQuery = targetQuery + req.URL.RawQuery
} else {
Expand Down

0 comments on commit 4710769

Please sign in to comment.