Skip to content

Commit

Permalink
fix extra header write. (#179)
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <nicholss@google.com>
  • Loading branch information
n3wscott authored and markpeek committed Sep 9, 2019
1 parent d3eb0a1 commit 5088975
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/cloudevents/transport/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,18 +576,20 @@ func (t *Transport) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if len(resp.Message.Header) > 0 {
copyHeaders(resp.Message.Header, w.Header())
}

status := http.StatusAccepted
if resp.StatusCode >= 200 && resp.StatusCode < 600 {
status = resp.StatusCode
}
w.Header().Add("Content-Length", strconv.Itoa(len(resp.Message.Body)))
w.WriteHeader(status)

if len(resp.Message.Body) > 0 {
if _, err := w.Write(resp.Message.Body); err != nil {
r.Error()
return
}
}
status := http.StatusAccepted
if resp.StatusCode >= 200 && resp.StatusCode < 600 {
status = resp.StatusCode
}
w.WriteHeader(status)

r.OK()
return
Expand Down

0 comments on commit 5088975

Please sign in to comment.