Skip to content

Commit

Permalink
Merge pull request #16 from zalando/feature-#15-powered-by-and-server…
Browse files Browse the repository at this point in the history
…-headers

Added some basic branding (X-Powered-By and Server headers)
  • Loading branch information
danpersa committed Oct 12, 2015
2 parents 2949862 + f65613c commit 1b8d714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}()
}

addBranding(rs)

c.res = rs
applyFiltersToResponse(f, c)

Expand All @@ -266,3 +268,8 @@ func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
copyStream(w.(flusherWriter), rs.Body)
}
}

func addBranding(rs *http.Response) {
rs.Header.Set("X-Powered-By", "Skipper")
rs.Header.Set("Server", "Skipper")
}
8 changes: 8 additions & 0 deletions proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ func TestGetRoundtrip(t *testing.T) {
t.Error("wrong content length")
}

if xpb, ok := w.Header()["X-Powered-By"]; !ok || xpb[0] != "Skipper" {
t.Error("Wrong X-Powered-By header value")
}

if xpb, ok := w.Header()["Server"]; !ok || xpb[0] != "Skipper" {
t.Error("Wrong Server header value")
}

if !bytes.Equal(w.Body.Bytes(), payload) {
t.Error("wrong content", string(w.Body.Bytes()))
}
Expand Down

0 comments on commit 1b8d714

Please sign in to comment.