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.
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@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.
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.
On Wed, May 8, 2019 at 1:17 PM Christian Grün christian.gruen@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@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.
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@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@architextus.com
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@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@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@architextus.com
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@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@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@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@architextus.com
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.
On Mon, May 13, 2019 at 6:06 PM Christian Grün christian.gruen@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@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@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@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@architextus.com
basex-talk@mailman.uni-konstanz.de