Skip to content

Commit

Permalink
fix X-Powered-By header
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Winther <jippignu@gmail.com>
  • Loading branch information
jippi committed Mar 14, 2018
1 parent 7076d25 commit fc30e55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func StarServer() {
if err := srv.ListenAndServe(); err != nil {
log.Fatal(err)
}

}

// handles: /{api_version}/meta-data/iam/info
Expand Down Expand Up @@ -178,6 +177,7 @@ func iamSecurityCredentialsName(w http.ResponseWriter, r *http.Request) {

// send the response
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("X-Powered-By", "go-metadataproxy")
w.WriteHeader(http.StatusOK)
w.Write([]byte(*roleInfo.RoleName))

Expand Down Expand Up @@ -302,7 +302,7 @@ func passthroughHandler(w http.ResponseWriter, r *http.Request) {
}
defer resp.Body.Close()

w.Header().Add("X-Powered-By", "go-metadataproxy")
w.Header().Set("X-Powered-By", "go-metadataproxy")
w.WriteHeader(resp.StatusCode)
io.Copy(w, resp.Body)

Expand Down
1 change: 1 addition & 0 deletions internal/http_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func isCompatibleAPIVersion(r *http.Request) bool {

func httpError(err error, w http.ResponseWriter, r *http.Request) {
log.Error(err)
w.Header().Set("X-Powered-By", "go-metadataproxy")
http.NotFound(w, r)
}

Expand Down

0 comments on commit fc30e55

Please sign in to comment.