Skip to content

Commit

Permalink
Merge pull request #20 from browny/master
Browse files Browse the repository at this point in the history
Add ContentLength property in mocked http.Response
  • Loading branch information
maxatome authored Mar 17, 2019
2 parents 00fbcf1 + ed3c918 commit b43b330
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func NewErrorResponder(err error) Responder {
// an http status code.
func NewStringResponse(status int, body string) *http.Response {
return &http.Response{
Status: strconv.Itoa(status),
StatusCode: status,
Body: NewRespBodyFromString(body),
Header: http.Header{},
Status: strconv.Itoa(status),
StatusCode: status,
Body: NewRespBodyFromString(body),
Header: http.Header{},
ContentLength: -1,
}
}

Expand All @@ -49,10 +50,11 @@ func NewStringResponder(status int, body string) Responder {
// an http status code.
func NewBytesResponse(status int, body []byte) *http.Response {
return &http.Response{
Status: strconv.Itoa(status),
StatusCode: status,
Body: NewRespBodyFromBytes(body),
Header: http.Header{},
Status: strconv.Itoa(status),
StatusCode: status,
Body: NewRespBodyFromBytes(body),
Header: http.Header{},
ContentLength: -1,
}
}

Expand Down

0 comments on commit b43b330

Please sign in to comment.