Skip to content

Commit

Permalink
Merge b196c06 into d31e82a
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley authored Nov 21, 2018
2 parents d31e82a + b196c06 commit 7fd4156
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func (c *CoProcessor) ObjectFromRequest(r *http.Request) *coprocess.Object {
if host != "" {
headers["Host"] = host
}

scheme := "http"
if r.TLS != nil {
scheme = "https"
}
miniRequestObject := &coprocess.MiniRequestObject{
Headers: headers,
SetHeaders: map[string]string{},
Expand All @@ -92,7 +95,7 @@ func (c *CoProcessor) ObjectFromRequest(r *http.Request) *coprocess.Object {
},
Method: r.Method,
RequestUri: r.RequestURI,
Scheme: r.URL.Scheme,
Scheme: scheme,
}

if r.Body != nil {
Expand Down
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 7fd4156

Please sign in to comment.