diff options
author | Elad <theman@elad.im> | 2018-08-10 19:49:37 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-10 19:49:37 +0800 |
commit | 3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c (patch) | |
tree | 45d10898a4b86b2a7185272e1317e5b96315a6dd /swarm/api/http/response.go | |
parent | 45eaef24319897f5b1679c9d1aa7d88702cce905 (diff) | |
download | go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar.gz go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar.bz2 go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar.lz go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar.xz go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.tar.zst go-tangerine-3ec5dda4d2dd0dec6d5bd465752f30e8f6ce208c.zip |
swarm/api/http: added logging to denote request ended (#17371)
Diffstat (limited to 'swarm/api/http/response.go')
-rw-r--r-- | swarm/api/http/response.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/swarm/api/http/response.go b/swarm/api/http/response.go index 9f4788d35..f050e706a 100644 --- a/swarm/api/http/response.go +++ b/swarm/api/http/response.go @@ -84,15 +84,16 @@ func RespondError(w http.ResponseWriter, r *http.Request, msg string, code int) } func respond(w http.ResponseWriter, r *http.Request, params *ResponseParams) { + w.WriteHeader(params.Code) if params.Code >= 400 { - w.Header().Del("Cache-Control") //avoid sending cache headers for errors! + w.Header().Del("Cache-Control") w.Header().Del("ETag") } acceptHeader := r.Header.Get("Accept") - // this cannot be in a switch form since an Accept header can be in the form of "Accept: */*, text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8" + // this cannot be in a switch since an Accept header can have multiple values: "Accept: */*, text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8" if strings.Contains(acceptHeader, "application/json") { if err := respondJSON(w, r, params); err != nil { RespondError(w, r, "Internal server error", http.StatusInternalServerError) |