Skip to content

Commit

Permalink
fallback to URL host if request host not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
steinfletcher committed Apr 22, 2019
1 parent bf0de5c commit bbb45b4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ type mockInteraction struct {
timestamp time.Time
}

func (r *mockInteraction) GetRequestHost() string {
host := r.request.Host
if host == "" {
host = r.request.URL.Host
}
return host
}

func (a *APITest) report() {
var capturedInboundReq *http.Request
var capturedFinalRes *http.Response
Expand Down Expand Up @@ -454,13 +462,13 @@ func (a *APITest) report() {
for _, interaction := range capturedMockInteractions {
a.recorder.AddHttpRequest(HttpRequest{
Source: quoted(systemUnderTestDefaultName),
Target: quoted(interaction.request.Host),
Target: quoted(interaction.GetRequestHost()),
Value: interaction.request,
Timestamp: interaction.timestamp,
})
if interaction.response != nil {
a.recorder.AddHttpResponse(HttpResponse{
Source: quoted(interaction.request.Host),
Source: quoted(interaction.GetRequestHost()),
Target: quoted(systemUnderTestDefaultName),
Value: interaction.response,
Timestamp: interaction.timestamp,
Expand Down

0 comments on commit bbb45b4

Please sign in to comment.