Skip to content

Commit

Permalink
Add Server field in HTTP API
Browse files Browse the repository at this point in the history
Resolves #625
Included in tests.

License: MIT
Signed-off-by: Jakub (Kubuxu) Sztandera <[email protected]>
  • Loading branch information
Kubuxu committed Jan 6, 2016
1 parent 65785e0 commit 9e74a0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions commands/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions test/sharness/t0230-channel-streaming-http-content-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand Down

0 comments on commit 9e74a0c

Please sign in to comment.