[experr:HC0001] unknown protocol: localhost (Windows only)
Wednesday, 8 May 2019 · 7 messages · last reply 21 May 2019
FB
France Baril8 May 2019 11:54 #
Hi,
We have two servers with similar jetty configuration, we find that an http:request call on static works on Linux but not on Windows.
HOW TO REPLICATE
Add an image test.png in webapp/static
Try the attached .xqm (change img-url for your server path)
Copy of the .xqm function for reference:
declare %rest:path('/a-test')Quoted text · 11 lines
> %rest:GET > %output:method("html") > %output:html-version("5.0") > function a-test:http-req(){ > let $img-url := 'http://localhost:8972/static/test.png' > let $http-function := function() {http:send-request(<http:request > method='get' status-only='true'/>, $img-url)} > let $http-s := xquery:fork-join($http-function) > let $http-status := $http-s//data(@status) > return <div>{$http-status}</div> > };
Test: http://localhost:8972/a-test
Result on Linux: 200
Result on Windows: [experr:HC0001] unknown protocol: localhost
This seemed to be security issue, but tests in multiple browsers return the same results and enabling CORS doesn't help... technically we're calling from the same domain/port... but hey we tried!
If we type the value of $img-url directly in the browser, we see the image on both platforms, so the issue is not with accessing the image itself, but with accessing it with the
http:send-request function.--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
CG
Christian Grün8 May 2019 13:17 #
Hi France,
Thanks for the test case. I called your RESTXQ function with Windows, and it seems to work. What I did:
* I started basexhttp.bat
* I modified your script to be runnable (8972 → 8984, namespace added for "a-test", etc.)
* I added a test.png to the "static" webapp directory
* I called http://localhost/a-test (in the browser and via curl), it returns <div>200</div>
Maybe you did something differently?
Does the problem persist if you…
* send the HTTP request without
xquery:fork-join?
* use fetch:binary?
The easier your example code and setup is, the easier it might get to reproduce the problem.
And a general observation: It’s recommendable not to the same HTTP instance from a RESTXQ function (but this may simply have been the result of our persistance to deliver us with reproducible test cases?).
Cheers
ChristianQuoted text · France Baril · 34 lines
On Wed, May 8, 2019 at 11:54 AM France Baril <france.baril at architextus.com> wrote: > > Hi, > > We have two servers with similar jetty configuration, we find that an http:request call on static works on Linux but not on Windows. > > HOW TO REPLICATE > > Add an image test.png in webapp/static > Try the attached .xqm (change img-url for your server path) > Copy of the .xqm function for reference: > >> declare %rest:path('/a-test') >> %rest:GET >> %output:method("html") >> %output:html-version("5.0") >> function a-test:http-req(){ >> let $img-url := 'http://localhost:8972/static/test.png' >> let $http-function := function() {http:send-request(<http:request method='get' status-only='true'/>, $img-url)} >> let $http-s := xquery:fork-join($http-function) >> let $http-status := $http-s//data(@status) >> return <div>{$http-status}</div> >> }; > > > Test: http://localhost:8972/a-test > > Result on Linux: 200 > Result on Windows: [experr:HC0001] unknown protocol: localhost > > This seemed to be security issue, but tests in multiple browsers return the same results and enabling CORS doesn't help... technically we're calling from the same domain/port... but hey we tried! > > If we type the value of $img-url directly in the browser, we see the image on both platforms, so the issue is not with accessing the image itself, but with accessing it with the http:send-request function.
FB
France Baril12 May 2019 11:44 #
I'll try
fetch:binary and have the Windows team members try it, but one question while we wait for result: If it is better to not use HTTP for the same server, is there an alternate way to check binary files in webapp/static? My 1st thought was the file module, but it doesn't seem to have access to that directory.Quoted text · Christian Grün · 74 lines
On Wed, May 8, 2019 at 1:17 PM Christian Grün <christian.gruen at gmail.com> wrote: > Hi France, > > Thanks for the test case. I called your RESTXQ function with Windows, > and it seems to work. What I did: > > * I started basexhttp.bat > * I modified your script to be runnable (8972 → 8984, namespace added > for "a-test", etc.) > * I added a test.png to the "static" webapp directory > * I called http://localhost/a-test (in the browser and via curl), it > returns <div>200</div> > > Maybe you did something differently? > > Does the problem persist if you… > > * send the HTTP request without xquery:fork-join? > * use fetch:binary? > > The easier your example code and setup is, the easier it might get to > reproduce the problem. > > And a general observation: It’s recommendable not to the same HTTP > instance from a RESTXQ function (but this may simply have been the > result of our persistance to deliver us with reproducible test > cases?). > > Cheers > Christian > > > On Wed, May 8, 2019 at 11:54 AM France Baril > <france.baril at architextus.com> wrote: > > > > Hi, > > > > We have two servers with similar jetty configuration, we find that an > http:request call on static works on Linux but not on Windows. > > > > HOW TO REPLICATE > > > > Add an image test.png in webapp/static > > Try the attached .xqm (change img-url for your server path) > > Copy of the .xqm function for reference: > > > >> declare %rest:path('/a-test') > >> %rest:GET > >> %output:method("html") > >> %output:html-version("5.0") > >> function a-test:http-req(){ > >> let $img-url := 'http://localhost:8972/static/test.png' > >> let $http-function := function() {http:send-request(<http:request > method='get' status-only='true'/>, $img-url)} > >> let $http-s := xquery:fork-join($http-function) > >> let $http-status := $http-s//data(@status) > >> return <div>{$http-status}</div> > >> }; > > > > > > Test: http://localhost:8972/a-test > > > > Result on Linux: 200 > > Result on Windows: [experr:HC0001] unknown protocol: localhost > > > > This seemed to be security issue, but tests in multiple browsers return > the same results and enabling CORS doesn't help... technically we're > calling from the same domain/port... but hey we tried! > > > > If we type the value of $img-url directly in the browser, we see the > image on both platforms, so the issue is not with accessing the image > itself, but with accessing it with the http:send-request function. >
--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
CG
Christian Grün13 May 2019 12:03 #
Quoted text · France Baril · 1 line
> My 1st thought was the file module, but it doesn't seem to have access to that directory.
Sounds surprising. Which error message do you get?
Quoted text · France Baril · 72 lines
>> Hi France, >> >> Thanks for the test case. I called your RESTXQ function with Windows, >> and it seems to work. What I did: >> >> * I started basexhttp.bat >> * I modified your script to be runnable (8972 → 8984, namespace added >> for "a-test", etc.) >> * I added a test.png to the "static" webapp directory >> * I called http://localhost/a-test (in the browser and via curl), it >> returns <div>200</div> >> >> Maybe you did something differently? >> >> Does the problem persist if you… >> >> * send the HTTP request without xquery:fork-join? >> * use fetch:binary? >> >> The easier your example code and setup is, the easier it might get to >> reproduce the problem. >> >> And a general observation: It’s recommendable not to the same HTTP >> instance from a RESTXQ function (but this may simply have been the >> result of our persistance to deliver us with reproducible test >> cases?). >> >> Cheers >> Christian >> >> >> On Wed, May 8, 2019 at 11:54 AM France Baril >> <france.baril at architextus.com> wrote: >> > >> > Hi, >> > >> > We have two servers with similar jetty configuration, we find that an http:request call on static works on Linux but not on Windows. >> > >> > HOW TO REPLICATE >> > >> > Add an image test.png in webapp/static >> > Try the attached .xqm (change img-url for your server path) >> > Copy of the .xqm function for reference: >> > >> >> declare %rest:path('/a-test') >> >> %rest:GET >> >> %output:method("html") >> >> %output:html-version("5.0") >> >> function a-test:http-req(){ >> >> let $img-url := 'http://localhost:8972/static/test.png' >> >> let $http-function := function() {http:send-request(<http:request method='get' status-only='true'/>, $img-url)} >> >> let $http-s := xquery:fork-join($http-function) >> >> let $http-status := $http-s//data(@status) >> >> return <div>{$http-status}</div> >> >> }; >> > >> > >> > Test: http://localhost:8972/a-test >> > >> > Result on Linux: 200 >> > Result on Windows: [experr:HC0001] unknown protocol: localhost >> > >> > This seemed to be security issue, but tests in multiple browsers return the same results and enabling CORS doesn't help... technically we're calling from the same domain/port... but hey we tried! >> > >> > If we type the value of $img-url directly in the browser, we see the image on both platforms, so the issue is not with accessing the image itself, but with accessing it with the http:send-request function. > > > > -- > France Baril > Architecte documentaire / Documentation architect > france.baril at architextus.com
FB
France Baril13 May 2019 18:01 #
It looks for content in the home directory, not in webapp/static.
Le lun. 13 mai 2019 12 h 04, Christian Grün <christian.gruen at gmail.com> a écrit :
Quoted text · Christian Grün · 85 lines
> > My 1st thought was the file module, but it doesn't seem to have access > to that directory. > > Sounds surprising. Which error message do you get? > > > >> Hi France, > >> > >> Thanks for the test case. I called your RESTXQ function with Windows, > >> and it seems to work. What I did: > >> > >> * I started basexhttp.bat > >> * I modified your script to be runnable (8972 → 8984, namespace added > >> for "a-test", etc.) > >> * I added a test.png to the "static" webapp directory > >> * I called http://localhost/a-test (in the browser and via curl), it > >> returns <div>200</div> > >> > >> Maybe you did something differently? > >> > >> Does the problem persist if you… > >> > >> * send the HTTP request without xquery:fork-join? > >> * use fetch:binary? > >> > >> The easier your example code and setup is, the easier it might get to > >> reproduce the problem. > >> > >> And a general observation: It’s recommendable not to the same HTTP > >> instance from a RESTXQ function (but this may simply have been the > >> result of our persistance to deliver us with reproducible test > >> cases?). > >> > >> Cheers > >> Christian > >> > >> > >> On Wed, May 8, 2019 at 11:54 AM France Baril > >> <france.baril at architextus.com> wrote: > >> > > >> > Hi, > >> > > >> > We have two servers with similar jetty configuration, we find that an > http:request call on static works on Linux but not on Windows. > >> > > >> > HOW TO REPLICATE > >> > > >> > Add an image test.png in webapp/static > >> > Try the attached .xqm (change img-url for your server path) > >> > Copy of the .xqm function for reference: > >> > > >> >> declare %rest:path('/a-test') > >> >> %rest:GET > >> >> %output:method("html") > >> >> %output:html-version("5.0") > >> >> function a-test:http-req(){ > >> >> let $img-url := 'http://localhost:8972/static/test.png' > >> >> let $http-function := function() {http:send-request(<http:request > method='get' status-only='true'/>, $img-url)} > >> >> let $http-s := xquery:fork-join($http-function) > >> >> let $http-status := $http-s//data(@status) > >> >> return <div>{$http-status}</div> > >> >> }; > >> > > >> > > >> > Test: http://localhost:8972/a-test > >> > > >> > Result on Linux: 200 > >> > Result on Windows: [experr:HC0001] unknown protocol: localhost > >> > > >> > This seemed to be security issue, but tests in multiple browsers > return the same results and enabling CORS doesn't help... technically we're > calling from the same domain/port... but hey we tried! > >> > > >> > If we type the value of $img-url directly in the browser, we see the > image on both platforms, so the issue is not with accessing the image > itself, but with accessing it with the http:send-request function. > > > > > > > > -- > > France Baril > > Architecte documentaire / Documentation architect > > france.baril at architextus.com >
CG
Christian Grün13 May 2019 18:06 #
You can specify arbitrary file system paths as argument:
• If you prefix your actual path with
db:option('WEBPATH'), you should end up in the directory that’s relevant for you.
• file:base-dir() points to the directory of your XQuery module
• file:current-dir() points to the directory from which BaseX or your web server was started.Quoted text · France Baril · 84 lines
On Mon, May 13, 2019 at 6:01 PM France Baril <france.baril at architextus.com> wrote: > > It looks for content in the home directory, not in webapp/static. > > Le lun. 13 mai 2019 12 h 04, Christian Grün <christian.gruen at gmail.com> a écrit : >> >> > My 1st thought was the file module, but it doesn't seem to have access to that directory. >> >> Sounds surprising. Which error message do you get? >> >> >> >> Hi France, >> >> >> >> Thanks for the test case. I called your RESTXQ function with Windows, >> >> and it seems to work. What I did: >> >> >> >> * I started basexhttp.bat >> >> * I modified your script to be runnable (8972 → 8984, namespace added >> >> for "a-test", etc.) >> >> * I added a test.png to the "static" webapp directory >> >> * I called http://localhost/a-test (in the browser and via curl), it >> >> returns <div>200</div> >> >> >> >> Maybe you did something differently? >> >> >> >> Does the problem persist if you… >> >> >> >> * send the HTTP request without xquery:fork-join? >> >> * use fetch:binary? >> >> >> >> The easier your example code and setup is, the easier it might get to >> >> reproduce the problem. >> >> >> >> And a general observation: It’s recommendable not to the same HTTP >> >> instance from a RESTXQ function (but this may simply have been the >> >> result of our persistance to deliver us with reproducible test >> >> cases?). >> >> >> >> Cheers >> >> Christian >> >> >> >> >> >> On Wed, May 8, 2019 at 11:54 AM France Baril >> >> <france.baril at architextus.com> wrote: >> >> > >> >> > Hi, >> >> > >> >> > We have two servers with similar jetty configuration, we find that an http:request call on static works on Linux but not on Windows. >> >> > >> >> > HOW TO REPLICATE >> >> > >> >> > Add an image test.png in webapp/static >> >> > Try the attached .xqm (change img-url for your server path) >> >> > Copy of the .xqm function for reference: >> >> > >> >> >> declare %rest:path('/a-test') >> >> >> %rest:GET >> >> >> %output:method("html") >> >> >> %output:html-version("5.0") >> >> >> function a-test:http-req(){ >> >> >> let $img-url := 'http://localhost:8972/static/test.png' >> >> >> let $http-function := function() {http:send-request(<http:request method='get' status-only='true'/>, $img-url)} >> >> >> let $http-s := xquery:fork-join($http-function) >> >> >> let $http-status := $http-s//data(@status) >> >> >> return <div>{$http-status}</div> >> >> >> }; >> >> > >> >> > >> >> > Test: http://localhost:8972/a-test >> >> > >> >> > Result on Linux: 200 >> >> > Result on Windows: [experr:HC0001] unknown protocol: localhost >> >> > >> >> > This seemed to be security issue, but tests in multiple browsers return the same results and enabling CORS doesn't help... technically we're calling from the same domain/port... but hey we tried! >> >> > >> >> > If we type the value of $img-url directly in the browser, we see the image on both platforms, so the issue is not with accessing the image itself, but with accessing it with the http:send-request function. >> > >> > >> > >> > -- >> > France Baril >> > Architecte documentaire / Documentation architect >> > france.baril at architextus.com
FB
France Baril21 May 2019 15:04 #
Thanks! I FYI, if anyone has the same problem and read this thread... The issue with the Windows installation was that basehttp.bat was starting the wrong jetty instance. Issue is resolved.
Quoted text · Christian Grün · 106 lines
On Mon, May 13, 2019 at 6:06 PM Christian Grün <christian.gruen at gmail.com> wrote: > You can specify arbitrary file system paths as argument: > > • If you prefix your actual path with db:option('WEBPATH'), you should > end up in the directory that’s relevant for you. > • file:base-dir() points to the directory of your XQuery module > • file:current-dir() points to the directory from which BaseX or your > web server was started. > > > > On Mon, May 13, 2019 at 6:01 PM France Baril > <france.baril at architextus.com> wrote: > > > > It looks for content in the home directory, not in webapp/static. > > > > Le lun. 13 mai 2019 12 h 04, Christian Grün <christian.gruen at gmail.com> > a écrit : > >> > >> > My 1st thought was the file module, but it doesn't seem to have > access to that directory. > >> > >> Sounds surprising. Which error message do you get? > >> > >> > >> >> Hi France, > >> >> > >> >> Thanks for the test case. I called your RESTXQ function with Windows, > >> >> and it seems to work. What I did: > >> >> > >> >> * I started basexhttp.bat > >> >> * I modified your script to be runnable (8972 → 8984, namespace added > >> >> for "a-test", etc.) > >> >> * I added a test.png to the "static" webapp directory > >> >> * I called http://localhost/a-test (in the browser and via curl), it > >> >> returns <div>200</div> > >> >> > >> >> Maybe you did something differently? > >> >> > >> >> Does the problem persist if you… > >> >> > >> >> * send the HTTP request without xquery:fork-join? > >> >> * use fetch:binary? > >> >> > >> >> The easier your example code and setup is, the easier it might get to > >> >> reproduce the problem. > >> >> > >> >> And a general observation: It’s recommendable not to the same HTTP > >> >> instance from a RESTXQ function (but this may simply have been the > >> >> result of our persistance to deliver us with reproducible test > >> >> cases?). > >> >> > >> >> Cheers > >> >> Christian > >> >> > >> >> > >> >> On Wed, May 8, 2019 at 11:54 AM France Baril > >> >> <france.baril at architextus.com> wrote: > >> >> > > >> >> > Hi, > >> >> > > >> >> > We have two servers with similar jetty configuration, we find that > an http:request call on static works on Linux but not on Windows. > >> >> > > >> >> > HOW TO REPLICATE > >> >> > > >> >> > Add an image test.png in webapp/static > >> >> > Try the attached .xqm (change img-url for your server path) > >> >> > Copy of the .xqm function for reference: > >> >> > > >> >> >> declare %rest:path('/a-test') > >> >> >> %rest:GET > >> >> >> %output:method("html") > >> >> >> %output:html-version("5.0") > >> >> >> function a-test:http-req(){ > >> >> >> let $img-url := 'http://localhost:8972/static/test.png' > >> >> >> let $http-function := function() > {http:send-request(<http:request method='get' status-only='true'/>, > $img-url)} > >> >> >> let $http-s := xquery:fork-join($http-function) > >> >> >> let $http-status := $http-s//data(@status) > >> >> >> return <div>{$http-status}</div> > >> >> >> }; > >> >> > > >> >> > > >> >> > Test: http://localhost:8972/a-test > >> >> > > >> >> > Result on Linux: 200 > >> >> > Result on Windows: [experr:HC0001] unknown protocol: localhost > >> >> > > >> >> > This seemed to be security issue, but tests in multiple browsers > return the same results and enabling CORS doesn't help... technically we're > calling from the same domain/port... but hey we tried! > >> >> > > >> >> > If we type the value of $img-url directly in the browser, we see > the image on both platforms, so the issue is not with accessing the image > itself, but with accessing it with the http:send-request function. > >> > > >> > > >> > > >> > -- > >> > France Baril > >> > Architecte documentaire / Documentation architect > >> > france.baril at architextus.com >
--
France Baril
Architecte documentaire / Documentation architect
france.baril at architextus.com
Written for BaseX 9.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery