Commit cacfe84c authored by Jacob Vosmaer's avatar Jacob Vosmaer

Remove unused 'body' argument

parent 11c8ab89
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
...@@ -170,17 +169,14 @@ func rebaseUrl(url *url.URL, onto *url.URL, suffix string) *url.URL { ...@@ -170,17 +169,14 @@ func rebaseUrl(url *url.URL, onto *url.URL, suffix string) *url.URL {
return &newUrl return &newUrl
} }
func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*http.Request, error) { func (api *API) newRequest(r *http.Request, suffix string) (*http.Request, error) {
authReq := &http.Request{ authReq := &http.Request{
Method: r.Method, Method: r.Method,
URL: rebaseUrl(r.URL, api.URL, suffix), URL: rebaseUrl(r.URL, api.URL, suffix),
Header: helper.HeaderClone(r.Header), Header: helper.HeaderClone(r.Header),
} }
if body != nil {
authReq.Body = ioutil.NopCloser(body)
}
// Clean some headers when issuing a new request without body // Clean some headers when issuing a new request without body
if body == nil {
authReq.Header.Del("Content-Type") authReq.Header.Del("Content-Type")
authReq.Header.Del("Content-Encoding") authReq.Header.Del("Content-Encoding")
authReq.Header.Del("Content-Length") authReq.Header.Del("Content-Length")
...@@ -197,7 +193,6 @@ func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*htt ...@@ -197,7 +193,6 @@ func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*htt
authReq.Header.Del("Te") authReq.Header.Del("Te")
authReq.Header.Del("Trailers") authReq.Header.Del("Trailers")
authReq.Header.Del("Upgrade") authReq.Header.Del("Upgrade")
}
// Also forward the Host header, which is excluded from the Header map by the http libary. // Also forward the Host header, which is excluded from the Header map by the http libary.
// This allows the Host header received by the backend to be consistent with other // This allows the Host header received by the backend to be consistent with other
...@@ -227,7 +222,7 @@ func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*htt ...@@ -227,7 +222,7 @@ func (api *API) newRequest(r *http.Request, body io.Reader, suffix string) (*htt
// //
// authResponse will only be present if the authorization check was successful // authResponse will only be present if the authorization check was successful
func (api *API) PreAuthorize(suffix string, r *http.Request) (httpResponse *http.Response, authResponse *Response, outErr error) { func (api *API) PreAuthorize(suffix string, r *http.Request) (httpResponse *http.Response, authResponse *Response, outErr error) {
authReq, err := api.newRequest(r, nil, suffix) authReq, err := api.newRequest(r, suffix)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("preAuthorizeHandler newUpstreamRequest: %v", err) return nil, nil, fmt.Errorf("preAuthorizeHandler newUpstreamRequest: %v", err)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment