Add Server field in HTTP API
Resolves #625 Included in tests. License: MIT Signed-off-by: Jakub (Kubuxu) Sztandera <kubuxu@gmail.com>
Jakub Sztandera committed
Dec 31, 2015 at 14:24 UTC
981b389a04fa0fbe69f47c3912adfad305261f7d
2 files changed
+6
-2
commands/http/handler.go
+4
-2
@@ -199,6 +199,10 @@ func guessMimeType(res cmds.Response) (string, error) {
199
}
200
201
func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req cmds.Request) {
202
+ h := w.Header()
203
+ // Expose our agent to allow identification
204
+ h.Set("Server", "go-ipfs/" + config.CurrentVersionNumber)
205
+
206
mime, err := guessMimeType(res)
207
if err != nil {
208
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -222,8 +226,6 @@ func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req
226
return
227
}
228
225
- h := w.Header()
226
-
229
// Set up our potential trailer
230
h.Set("Trailer", StreamErrHeader)
231
test/sharness/t0230-channel-streaming-http-content-type.sh
+2
@@ -24,6 +24,7 @@ test_ls_cmd() {
24
printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
25
printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
26
printf "Content-Type: text/plain\r\n" >>expected_output &&
27
+ printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
28
printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
29
printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
30
printf "X-Chunked-Output: 1\r\n" >>expected_output &&
@@ -46,6 +47,7 @@ test_ls_cmd() {
47
printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
48
printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
49
printf "Content-Type: application/json\r\n" >>expected_output &&
50
+ printf "Server: go-ipfs/%s\r\n" $(ipfs version -n) >>expected_output &&
51
printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
52
printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
53
printf "X-Chunked-Output: 1\r\n" >>expected_output &&