From 981b389a04fa0fbe69f47c3912adfad305261f7d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 31 Dec 2015 14:24:31 +0100 Subject: [PATCH] Add Server field in HTTP API Resolves #625 Included in tests. License: MIT Signed-off-by: Jakub (Kubuxu) Sztandera --- commands/http/handler.go | 6 ++++-- test/sharness/t0230-channel-streaming-http-content-type.sh | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/http/handler.go b/commands/http/handler.go index 9f43e4d6e8c..e747e82fa4b 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 0f234d940d8..3825a2cf81e 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 &&