diff options
Diffstat (limited to 'handlers/passthrough.go')
| -rw-r--r-- | handlers/passthrough.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/handlers/passthrough.go b/handlers/passthrough.go index f322d3a..b2daa88 100644 --- a/handlers/passthrough.go +++ b/handlers/passthrough.go @@ -2,7 +2,6 @@ package handlers import ( "github.com/valyala/fasthttp" - "net/http" "portgate" ) @@ -16,14 +15,13 @@ func (h *RequestHandler) handlePassthroughRequest(ctx *fasthttp.RequestCtx, p po // We reuse the request given to us by the user with minor changes to route it to the // destination host. ctx.Request.SetRequestURI(h.config.MakeUrl(p)) - ctx.Request.Header.Set("Host", h.config.TargetAddress(p.DestinationIdentifier)) + ctx.Request.Header.SetHost(h.config.TargetAddress(p.DestinationIdentifier)) // We pipe the response given to us by the destination host back to the user. // Since it's possible that we get a redirect, we take this into account, // but only allow upto 10 redirects. err := h.client.DoRedirects(&ctx.Request, &ctx.Response, 10) if err != nil { - ctx.SetStatusCode(http.StatusInternalServerError) - _, _ = ctx.WriteString("An error occurred.") + h.handleError(ctx) } } |
