Skip to content
Snippets Groups Projects
Commit a3680c5e authored by Travis Ralston's avatar Travis Ralston
Browse files

Set host on MMR test requests

parent a3216a0b
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,7 @@ func (h *HostRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
"action": GetActionName(r),
"method": r.Method,
}).Inc()
logger.Warn("The server name provided in the Host header is not configured, or the request was made directly to the media repo. Please specify a Host header and check your reverse proxy configuration. The request is being rejected.")
logger.Warnf("The server name provided ('%s') in the Host header is not configured, or the request was made directly to the media repo. Please specify a Host header and check your reverse proxy configuration. The request is being rejected.", r.Host)
w.WriteHeader(http.StatusBadGateway)
if b, err := json.Marshal(_responses.BadGatewayError("Review server logs to continue")); err != nil {
panic(errors.New("error preparing BadGatewayError: " + err.Error()))
......
......@@ -65,6 +65,9 @@ func (c *MatrixClient) DoRaw(method string, endpoint string, qs url.Values, cont
if err != nil {
return nil, err
}
if c.ServerName != "" {
req.Host = c.ServerName
}
if contentType != "" {
req.Header.Set("Content-Type", contentType)
}
......@@ -72,6 +75,6 @@ func (c *MatrixClient) DoRaw(method string, endpoint string, qs url.Values, cont
req.Header.Set("Authorization", "Bearer "+c.AccessToken)
}
log.Println(fmt.Sprintf("[HTTP] [Auth=%s] %s %s", c.AccessToken, req.Method, req.RequestURI))
log.Println(fmt.Sprintf("[HTTP] [Auth=%s] [Host=%s] %s %s", c.AccessToken, c.ServerName, req.Method, req.URL.String()))
return http.DefaultClient.Do(req)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment