diff --git a/commands/http/handler.go b/commands/http/handler.go index 9f43e4d6e8c9..e747e82fa4b2 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -199,6 +199,10 @@ func guessMimeType(res cmds.Response) (string, error) { } func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req cmds.Request) { + h := w.Header() + // Expose our agent to allow identification + h.Set("Server", "go-ipfs/" + config.CurrentVersionNumber) + mime, err := guessMimeType(res) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -222,8 +226,6 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req return } - h := w.Header() - // Set up our potential trailer h.Set("Trailer", StreamErrHeader) diff --git a/test/sharness/t0230-channel-streaming-http-content-type.sh b/test/sharness/t0230-channel-streaming-http-content-type.sh index 0f234d940d80..3825a2cf81ed 100755 --- a/test/sharness/t0230-channel-streaming-http-content-type.sh +++ b/test/sharness/t0230-channel-streaming-http-content-type.sh @@ -24,6 +24,7 @@ test_ls_cmd() { printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output && printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output && printf "Content-Type: text/plain\r\n" >>expected_output && + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && printf "Trailer: X-Stream-Error\r\n" >>expected_output && printf "Transfer-Encoding: chunked\r\n" >>expected_output && printf "X-Chunked-Output: 1\r\n" >>expected_output && @@ -46,6 +47,7 @@ test_ls_cmd() { printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output && printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output && printf "Content-Type: application/json\r\n" >>expected_output && + printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output && printf "Trailer: X-Stream-Error\r\n" >>expected_output && printf "Transfer-Encoding: chunked\r\n" >>expected_output && printf "X-Chunked-Output: 1\r\n" >>expected_output &&