Skip to content
This repository was archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
repassando headers de cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonata-menezes committed Jun 4, 2018
1 parent fb00f54 commit 8248dbd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,19 @@ func Proxy(response http.ResponseWriter, request *http.Request) {
response.WriteHeader(http.StatusNoContent)
return
}
responseProxy, by, errs := gorequest.New().Get(url).EndBytes()
r := gorequest.New()
gorequest.New()
for _, h := range []string{"content-type", "cache-control", "expires", "last-modified"} {
r.Header.Set(h, request.Header.Get(h))
}
responseProxy, by, errs := r.Get(url).EndBytes()
if len(errs) > 0 {
response.WriteHeader(http.StatusNoContent)
return
}
response.Header().Set("content-type", responseProxy.Header.Get("content-type"))
for _, h := range []string{"content-type", "cache-control", "expires", "last-modified"} {
response.Header().Set(h, responseProxy.Header.Get(h))
}
response.Write(by)
response.WriteHeader(responseProxy.StatusCode)
}
Expand Down

0 comments on commit 8248dbd

Please sign in to comment.