of-watchdog icon indicating copy to clipboard operation
of-watchdog copied to clipboard

HTTP Path is not passed in to handler in http mode

Open alexellis opened this issue 7 years ago • 5 comments
trafficstars

Expected Behaviour

Paths should be forwarded to the upstream function.

Current Behaviour

I tried to run a SimpleHTTPServer in Python and noticed the file-browser wasn't passing through the path.

Possible Solution

Update the proxying code to pass the requestURI

Steps to Reproduce (for bugs)

  1. port=8081 mode=http fprocess="python -m SimpleHTTPServer" upstream_url="http://127.0.0.1:8000" ./of-watchdog

Browse into a directory and see it doesn't work

Context

Running as a Go binary outside of Docker.

We should be careful to test this change since the templates only bind to a single path anyway of /

https://github.com/openfaas-incubator/node8-express-template/blob/master/template/node8-express/index.js#L83

alexellis avatar Apr 24 '18 19:04 alexellis

Patch for the fix: https://gist.github.com/alexellis/ba1c3b0fdde166a937810c262d4378df

alexellis avatar Apr 24 '18 19:04 alexellis

I experienced the same issue with querystring variables not being passed to the nodejs handler. Do you plan to merge the patch anytime soon?

satie avatar May 04 '18 00:05 satie

I am having the same problem: not being able to access GET parameters of the query. It would be nice if you could merge the patch. Many thanks

lapwat avatar May 11 '18 15:05 lapwat

I tried with the patch, where should I access the Query ? I tried to print Header & Body of handler.Request instance but I cannot find the Query.

Workaround

I succeded to get path and query of the url by tweaking this file: https://github.com/openfaas-incubator/golang-http-template/blob/master/template/golang-http/main.go#L31,L34

You should do something like this:

req := handler.Request{
    Body:        input,
    Header:      r.Header,
    QueryString: r.URL.Path + "/?" + r.URL.RawQuery,
}

Do not forget to compile ./watchdog with the patch for this to work.

lapwat avatar May 14 '18 13:05 lapwat

QueryString is passed, use the latest release of the project:

https://github.com/openfaas-incubator/of-watchdog/blob/master/executor/http_runner.go#L102

This issue is about the URL Path, not the QueryString.

Alex

alexellis avatar Jul 21 '18 08:07 alexellis