Skip to content

Commit

Permalink
Merge bff9902 into d31e82a
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley committed Nov 21, 2018
2 parents d31e82a + bff9902 commit e7dd714
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mw_js_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func (d *DynamicMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Reques
}
headers.Set("Host", host)
}
scheme := "http"
if r.TLS != nil {
scheme = "https"
}

requestData := MiniRequestObject{
Headers: headers,
Expand All @@ -122,7 +126,7 @@ func (d *DynamicMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Reques
DeleteParams: []string{},
Method: r.Method,
RequestURI: r.RequestURI,
Scheme: r.URL.Scheme,
Scheme: scheme,
}

requestAsJson, err := json.Marshal(requestData)
Expand Down
1 change: 0 additions & 1 deletion mw_js_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func TestJSVMRequestScheme(t *testing.T) {
Pre: true,
}
req := httptest.NewRequest("GET", "/foo", nil)
req.URL.Scheme = "http"
jsvm := JSVM{}
jsvm.Init(nil, logrus.NewEntry(log))

Expand Down
6 changes: 6 additions & 0 deletions mw_virtual_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type RequestObject struct {
Body string
URL string
Params map[string][]string
Scheme string
}

type ResponseObject struct {
Expand Down Expand Up @@ -136,10 +137,15 @@ func (d *VirtualEndpoint) ServeHTTPForCache(w http.ResponseWriter, r *http.Reque
}
defer r.Body.Close()

scheme := "http"
if r.TLS != nil {
scheme = "https"
}
requestData := RequestObject{
Headers: r.Header,
Body: string(originalBody),
URL: r.URL.Path,
Scheme: scheme,
}

// We need to copy the body _back_ for the decode
Expand Down

0 comments on commit e7dd714

Please sign in to comment.