mirror of
https://github.com/openziti/zrok.git
synced 2024-11-25 01:23:49 +01:00
headers; they make a world of difference
This commit is contained in:
parent
d471484f99
commit
7e39a99ade
28
http/http.go
28
http/http.go
@ -34,25 +34,29 @@ func Run(cfg *Config) error {
|
|||||||
|
|
||||||
type handler struct{}
|
type handler struct{}
|
||||||
|
|
||||||
func (self *handler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
|
func (self *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
logrus.Infof("handling request from [%v]", req.RemoteAddr)
|
logrus.Infof("handling request from [%v]", r.RemoteAddr)
|
||||||
|
|
||||||
req.Host = "localhost:3000"
|
r.Host = "localhost:3000"
|
||||||
req.URL.Host = "localhost:3000"
|
r.URL.Host = "localhost:3000"
|
||||||
req.URL.Scheme = "http"
|
r.URL.Scheme = "http"
|
||||||
req.RequestURI = ""
|
r.RequestURI = ""
|
||||||
|
|
||||||
rRes, err := http.DefaultClient.Do(req)
|
rr, err := http.DefaultClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
_, _ = fmt.Fprint(res, err)
|
_, _ = fmt.Fprint(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := io.Copy(res, rRes.Body)
|
for k, v := range rr.Header {
|
||||||
|
w.Header().Add(k, v[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
n, err := io.Copy(w, rr.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
_, _ = fmt.Fprint(res, err)
|
_, _ = fmt.Fprint(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,14 +43,18 @@ func (self *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
r.RequestURI = ""
|
r.RequestURI = ""
|
||||||
logrus.Warnf("request: %v", r)
|
logrus.Warnf("request: %v", r)
|
||||||
|
|
||||||
pResp, err := client.Do(r)
|
rr, err := client.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
_, _ = fmt.Fprint(w, err)
|
_, _ = fmt.Fprint(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := io.Copy(w, pResp.Body)
|
for k, v := range rr.Header {
|
||||||
|
w.Header().Add(k, v[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
n, err := io.Copy(w, rr.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user