Re: [basex-talk] http:send-request - problem with response

2019-11-13 Thread Bogdan Bogucki

Hi Christian,

It works. Thank you for quick fix.

Best Regards

Bogdan Bogucki

W dniu 11/13/2019 o 17:42, Christian Grün pisze:

Hi Bogdan (cc to the list),

Thanks for digging deeper. I noticed that the standard Java function
that we used returned only one value per header field, and dropped the
others [1].

I managed to fix this in the latest stable snapshot; could you give it
a try [2]?

BaseX 9.3 will be released end of November.

Cheers,
Christian

[1] http://files.basex.org/releases/latest/
[2] https://github.com/BaseXdb/basex/issues/1751




On Wed, Nov 13, 2019 at 4:26 PM Bogdan Bogucki  wrote:

Hi Christian,
Lack of many redirection is not a big problem. I can handle it manually.
Problem is not complete response header form first request.

Browser make 3 redirection I am talking about first.

Please take a look.


Response header from browser (first request) - contains three fields Set
Cookies:

set-cookie __cfduid=daf54110b2a87d66c2a53…; domain=.pracuj.pl; HttpOnly

set-cookie _yaic=13; expires=Fri, 31-Dec- 23:59:59 GMT; path=/

set-cookie _urnadiam=A; domain=.pracuj.pl…3:00:00 GMT; path=/; HttpOnly

but response header form http:send-request contains only last one:



I need information from previous set-cookie fields to make manual
redirection passing information about sessions to next requests.

Regards

Bogdan Bogucki

W dniu 29.10.2019 o 03:06, Christian Grün pisze:

Hi Bogdan,

The current http:send-request implementation is based on the default
Java HttpURLConnection, which does not resolve redirects that use
different protocols [1]. This is the reason why your request will not
be fully processed (as it e.g. happens when you use the browser).

It seems that your initial request to the https protocol returns a 302
redirect to a (now unsafe) http URL, which returns another redirect to
https. I don’t know who maintains the discussed web site, but it could
be worth contacting the admins and asking them if they could update
and simplify their redirect policy.

Hope this helps,
Christian

[1] https://stackoverflow.com/a/1884427/1018790




On Fri, Oct 25, 2019 at 1:52 PM Bogdan Bogucki  wrote:

Hello,

I encounter problem with http:send-request function. I need handle multiple 
forward requests (3) with cookies.

First request returns cookies information which are required with next 
requests. Output from http:send-request dosen't contains all fields which are 
returned by server.

Response from browser is flowing:
cache-control
private
cf-cache-status
DYNAMIC
cf-ray
52b3cedc5b9bcc9f-WAW
content-type
text/html; charset=utf-8
date
Fri, 25 Oct 2019 11:21:37 GMT
expect-ct
max-age=604800, report-uri="ht….com/cdn-cgi/beacon/expect-ct"
location
http://www.pracuj.pl/praca/jav…eloper-warszawa,oferta,7171988
server
cloudflare
set-cookie
__cfduid=daf54110b2a87d66c2a53…; domain=.pracuj.pl; HttpOnly
set-cookie
_yaic=13; expires=Fri, 31-Dec- 23:59:59 GMT; path=/
set-cookie
_urnadiam=A; domain=.pracuj.pl…3:00:00 GMT; path=/; HttpOnly
x-aspnet-version
4.0.30319
x-aspnetmvc-version
5.2
X-Firefox-Spdy
h2
x-powered-by
ASP.NET
x-ua-compatible
IE=edge


Request:

http:send-request(
  







  , 
'https://www.pracuj.pl/praca/java-developer-warszawa,oferta,7171988')

Response form http:send-request is:

http://expath.org/ns/http-client; status="302" 
message="Found">











https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"/>





Two set-cookie fields is missing.

How should I invoke http:send-request to receive proper result  ?

Regards

Bogdan


Re: [basex-talk] Docker query

2019-11-13 Thread Bogdan Bogucki

Hi Joshep,

Docker image does not contain webapp folder.

You have to copy it to file system form zip archive and pass path to run 
command.


|docker run -d \ --name basexhttp \ --publish 1984:1984 \ --publish 
8984:8984 \ --volume "$HOME/basex/data":/srv/basex/data \ --volume 
"$HOME/basex/webapp":/srv/basex/webapp \ basex/basexhttp:latest|


Please take a look:

https://hub.docker.com/r/basex/basexhttp

Regards

Bogdan Bogucki
W dniu 13.11.2019 o 17:52, Christian Grün pisze:

Hi Joseph,

Docker is not included in the default installations of BaseX. I
haven’t tried it by myself, but you could have a look at our
documentation and see what needs to be done to get the DBA application
running [1].

Best
Christian

[1] http://docs.basex.org/wiki/Docker


On Fri, Nov 8, 2019 at 10:03 AM Joseph Szili  wrote:

Hello all,  I'm trying to use the docker image for 9.x but when I surf to 
http://localhost:8984/dba/ per the documentation ...

I get the following response in the browser

No function found that matches the request.


Using this command in linux (Ubuntu 19.04)

›$ docker run -d \
 --name basexhttp \
 --publish 1984:1984 \
 --publish 8984:8984 \
 --volume "$HOME/Projects/basex-dev/data":/srv/basex/data \
 basex/basexhttp:latest


container log >>>>>>>>>>
/srv/basex/.basex: writing new configuration file.
BaseX 9.3 beta [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @248ms to 
org.eclipse.jetty.util.log.Slf4jLog
[main] INFO org.eclipse.jetty.server.Server - jetty-9.4.21.v20190926; built: 
2019-09-26T16:41:09.154Z; git: 72970db61a2904371e1218a95a3bef5d79788c33; jvm 
1.8.0_212-b04
[main] INFO org.eclipse.jetty.util.TypeUtil - JVM Runtime does not support 
Modules
[main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP 
Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
[main] INFO org.eclipse.jetty.server.session - DefaultSessionIdManager 
workerName=node0
[main] INFO org.eclipse.jetty.server.session - No SessionScavenger set, using 
defaults
[main] INFO org.eclipse.jetty.server.session - node0 Scavenging every 60ms
Server was started (port: 1984).
java.io.FileNotFoundException: /srv/basex/data/.logs/2019-11-08.log (No such 
file or directory)
 at java.io.FileOutputStream.open0(Native Method)
 at java.io.FileOutputStream.open(FileOutputStream.java:270)
 at java.io.FileOutputStream.(FileOutputStream.java:213)
 at org.basex.server.LogFile.create(LogFile.java:31)
 at org.basex.server.Log.write(Log.java:128)
 at org.basex.server.Log.writeServer(Log.java:70)
 at org.basex.BaseXServer.(BaseXServer.java:122)
 at org.basex.http.HTTPContext.init(HTTPContext.java:101)
 at org.basex.http.BaseXServlet.init(BaseXServlet.java:37)
 at 
org.eclipse.jetty.servlet.ServletHolder$WrapperServlet.init(ServletHolder.java:1287)
 at 
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:599)
 at 
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:425)
 at 
org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:751)
 at 
java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:352)
 at 
java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483)
 at 
java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
 at 
java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
 at 
java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
 at 
java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
 at 
java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
 at 
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:744)
 at 
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:361)
 at 
org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1443)
 at 
org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1407)
 at 
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:821)
 at 
org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:276)
 at 
org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
 at 
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
 at 
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
 at org.eclipse.jetty.server.Server.start(Server.java:407)
 at 
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
 at 
org.eclipse.jetty.ser

[basex-talk] http:send-request - problem with response

2019-10-25 Thread Bogdan Bogucki


Hello,

I encounter problem with http:send-request function. I need handle 
multiple forward requests (3) with cookies.


First request returns cookies information which are required with next 
requests. Output from http:send-request dosen't contains all fields 
which are returned by server.


Response from browser is flowing:
cache-control   
private
cf-cache-status 
DYNAMIC
cf-ray  
52b3cedc5b9bcc9f-WAW
content-type
text/html; charset=utf-8
date
Fri, 25 Oct 2019 11:21:37 GMT
expect-ct   
max-age=604800, report-uri="ht….com/cdn-cgi/beacon/expect-ct"
location
http://www.pracuj.pl/praca/jav…eloper-warszawa,oferta,7171988
server  
cloudflare
set-cookie  
__cfduid=daf54110b2a87d66c2a53…; domain=.pracuj.pl; HttpOnly
set-cookie  
_yaic=13; expires=Fri, 31-Dec- 23:59:59 GMT; path=/
set-cookie  
_urnadiam=A; domain=.pracuj.pl…3:00:00 GMT; path=/; HttpOnly
x-aspnet-version
4.0.30319
x-aspnetmvc-version 
5.2
X-Firefox-Spdy  
h2
x-powered-by
ASP.NET
x-ua-compatible 
IE=edge


Request:

http:send-request(

  
  value="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"/>

  
  
  
  

    , 
'https://www.pracuj.pl/praca/java-developer-warszawa,oferta,7171988')


Response form http:send-request is:

http://expath.org/ns/http-client; 
status="302" message="Found">

  
  
  
  
  
  
  
  
  
  
  
  https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"/>

  
  
  


Two set-cookie fields is missing.

How should I invoke http:send-request to receive proper result  ?

Regards

Bogdan



[basex-talk] web:response-header & Set-Cookie

2018-09-17 Thread Bogdan Bogucki
Hello,

 

When I try invoke following code:

 

  return (

web:response-header(

  map { 'media-type': web:content-type($path) },

  map { 'Cache-Control': 'max-age=3600,public' },

  map { 'Set-Cookie': 'JSESSIONID=' || session:id() || ';max-age=1800' }

),

file:read-binary($path)

}

 

I receive error: 

[XPTY0004] Unknown option 'Set-Cookie'.

 

I am able to set cookie using .

Following code is working:

 

  return (



  









  

,

file:read-binary($path)

)

 

I think function web:response-header should allow set cookie.

 

Regards
Bogdan Bogucki

 

 

 



[basex-talk] ODP: ODP: Update functions - Error handling and counting

2018-08-25 Thread Bogdan Bogucki
Hi Christian,

I have question about updates.

I use updating function upsertVehicles in loop. Function downloadVehicles 
download from url and pass to upsertVehicles function.

declare %updating function cfv:downloadData () as empty-sequence() {
for $URL in doc("config.xml")/urls
return (cfv:downloadVehicles($URL) => cfv:upsertVehicles(), 
admin:write-log("Inserted: " || serialize(update:cache(
};

When does cache is purged ? In my case cache contains information from previous 
iterations. 
If upsertVehicles fail only updates from this function are reverted. What is 
the scope of the PUL ? Is this query, function or all invocation chain of 
updating functions ?

I have problem with update:cache(). What is the return type ? Sequence of items 
or sequence of sequence [] of items ? When I try get one item like this: 
update:cache()[1] I receive error: 
Item expected, sequence found: (0, 0).

Best Regards
Bogdan Bogucki


-Wiadomość oryginalna-
Od: BaseX-Talk [mailto:basex-talk-boun...@mailman.uni-konstanz.de] W imieniu 
Bogdan Bogucki
Wysłano: 25 sierpnia 2018 17:58
Do: 'Christian Grün'
DW: 'BaseX'
Temat: [basex-talk] ODP: Update functions - Error handling and counting

Hi Christian,

Thank you it helps me a lot.

I found that update:output-cache() is in module db. Wiki describe 
output-cache() in update module.

Best Regards
Bogdan Bogucki
 

-Wiadomość oryginalna-
Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 24 sierpnia 2018 23:41
Do: Bogdan Bogucki
DW: BaseX
Temat: Re: [basex-talk] Update functions - Error handling and counting

Hi Bogdan,

> 1) XQuery is functional language and updating function can return empty 
> sequence. How can I count and return result how many nodes was inserted or 
> updated ?

BaseX provides the update:output function for that purpose [1]. A solution 
could look as follows:

  declare %updating function cfv:upsertVehicles(
$vehicles  as element(car)*
  ) as empty-sequence() {
let $db := db:open("db")/cars
let $existing := $vehicles[$db/car/vin = vin]
return (
  (: replace existing vehicles :)
  for $updated in $existing
  let $old := $db/car[vin = $updated/vin]
  return replace node $old with $updated,
  (: insert new vehicles :)
  insert node ($vehicles except $existing) into $db,
  (: return count :)
  update:output(count($vehicles))
)
  };

> I have similar problem with error handling. How can I catch and return any 
> error.

Due to the semantics of XQuery Update, logical errors will be raised before 
your updates are eventually executed [2]. No updates will be performed if the 
execution is expected to fail.

Best,
Christian

[1] http://docs.basex.org/wiki/Update_Module#update:output
[2] http://docs.basex.org/wiki/XQuery_Update#Error_Messages



[basex-talk] ODP: Update functions - Error handling and counting

2018-08-25 Thread Bogdan Bogucki
Hi Christian,

Thank you it helps me a lot.

I found that update:output-cache() is in module db. Wiki describe 
output-cache() in update module.

Best Regards
Bogdan Bogucki
 

-Wiadomość oryginalna-
Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 24 sierpnia 2018 23:41
Do: Bogdan Bogucki
DW: BaseX
Temat: Re: [basex-talk] Update functions - Error handling and counting

Hi Bogdan,

> 1) XQuery is functional language and updating function can return empty 
> sequence. How can I count and return result how many nodes was inserted or 
> updated ?

BaseX provides the update:output function for that purpose [1]. A solution 
could look as follows:

  declare %updating function cfv:upsertVehicles(
$vehicles  as element(car)*
  ) as empty-sequence() {
let $db := db:open("db")/cars
let $existing := $vehicles[$db/car/vin = vin]
return (
  (: replace existing vehicles :)
  for $updated in $existing
  let $old := $db/car[vin = $updated/vin]
  return replace node $old with $updated,
  (: insert new vehicles :)
  insert node ($vehicles except $existing) into $db,
  (: return count :)
  update:output(count($vehicles))
)
  };

> I have similar problem with error handling. How can I catch and return any 
> error.

Due to the semantics of XQuery Update, logical errors will be raised before 
your updates are eventually executed [2]. No updates will be performed if the 
execution is expected to fail.

Best,
Christian

[1] http://docs.basex.org/wiki/Update_Module#update:output
[2] http://docs.basex.org/wiki/XQuery_Update#Error_Messages



[basex-talk] Update functions - Error handling and counting

2018-08-24 Thread Bogdan Bogucki
Hello,

 

I am playing with XQUF in BaseX ann I encountered following problems.

 

1) XQuery is functional language and updating function can return empty
sequence. How can I count and return result how many nodes was inserted or
updated ?

 

Example:

declare %private %updating function cfv:upsertVehicles ($vehicles as
node()*) as empty-sequence() {

 

let $db := db:open("db")/cars

for $v in $vehicles

let $dbVehicle :=  $db/car[vin = $v/vin]

return if (not(exists($dbVehicle))) then (insert node $v as last into
$db)

 else 

   if (exists($dbVehicle)) then (replace node $dbVehicle with
$v)

   else ()  

};

 

I have similar problem with error handling. How can I catch and return any
error.

 

Regards
Bogdan Bogucki

 

 



[basex-talk] ODP: - unclear strategy of setting header during serialization

2018-07-14 Thread Bogdan Bogucki
Hello CHristian,

 

Thank you for help. Understood. 

Structure  was serialized to empty string. Now It is clear for 
me why data is lost. 

 

Best Regards
Bogdan Bogucki

 

 

Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 14 lipca 2018 13:25
Do: Bogdan Bogucki
DW: BaseX
Temat: Re: [basex-talk]  - unclear strategy of setting header 
during serialization

 

If you change the return type of an XQuery function to xs:string, your nodes 
will be implicitly converted to strings.

This is the standard behavior of XQuery and no particular feature of RESTXQ. 
Play around with the query that I presented in my previous answer.

 

You need to remove the xs:string* return typeb you can replace it with item()*.

 

 



[basex-talk] ODP: - unclear strategy of setting header during serialization

2018-07-14 Thread Bogdan Bogucki
Hello,

 

declare

  %rest:POST("{$json}")

  %rest:path("/drpg/ping")

function drpg:ping(

$json as xs:string

) as xs:string* {

  



  

  



  , 

  let $p := json:parse($json)

  return ($p/json/data/_/_/_)[last()]

};

 

Element was converted to string but header is overwritten. 

 

Response header:

 

Content-Length: 6

Content-Type: application/xml; charset=UTF-8

Date: Sat, 14 Jul 2018 11:14:32 GMT

Server: Jetty(9.4.9.v20180320)

 

How can I set  ?

 

Why when return type is element() header is set correctly ?

 

Access-Control-Allow-Origin : *

Content-Length: 11

Content-Type: text/plain;charset=utf-8

Date:  Sat, 14 Jul 2018 11:18:43 GMT

Server: Jetty(9.4.9.v20180320)

 





    

Pozdrawiam
Bogdan Bogucki

 

HUSSAR SYSTEMS

 

NIP: 532-170-12-00 

Regon: 142624070

 

e-mail:  <mailto:bbogu...@hussar.pl> bbogu...@hussar.pl
tel. kom.: +48 607 409 301
www:  <http://www.hussar.pl/> www.hussar.pl

 

Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 14 lipca 2018 11:45
Do: Bogdan Bogucki
DW: BaseX
Temat: Re: [basex-talk]  - unclear strategy of setting header 
during serialization

 

Hi Bogdan,

 

If you change the return type of an XQuery function to xs:string, your nodes 
will be implicitly converted to strings:

 

  declare function local:f() as xs:string {

X

  };

  (: will result in 'X' :)

  local:f()

 

The string conversion of your http:response element yields an empty string, so 
it does not matter what you specify as attribute values.

 

If you want to return text/plain, you’ll have to change your content type from 
text/html to to text/plain:

 

  

Best,
Christian

 

 

On Sat, Jul 14, 2018 at 11:30 AM Bogdan Bogucki  wrote:

Hello,

 

I encountered strange behavior during HTTP response.

 

I need to set custom header Access-Control-Allow-Origin:*.

 

To do that I am using custom response.

 

Following code is working and set required header:

 

declare

  %rest:POST("{$json}")

  %rest:path("/ping")

function drpg:ping(

$json as xs:string

) as element()* {

​​

  



  

​​

  



  ,  

  let $p := json:parse($json)

  return ($p/json/data/_/_/_)[last()]

};

 

Response header:


Access-Control-Allow-Origin

*

 


Content-Length

11


Content-Type

text/html;charset=utf-8


Date

Sat, 14 Jul 2018 09:17:18 GMT


Server

Jetty(9.4.9.v20180320)

 

I want to return plain text, so when I change return parameter to xs:string* 
and add data function header from  is overwritten. 

 

Response header:


Content-Length

6

 


Content-Type

application/xml; charset=UTF-8


Date

Sat, 14 Jul 2018 09:26:59 GMT


Server

Jetty(9.4.9.v20180320)

 

Example code:

declare

  %rest:POST("{$json}")

  %rest:path("/drpg/ping")

function drpg:ping(

$json as xs:string

) as xs:string* {

  



  

  



  ,  

  let $p := json:parse($json)

  return data(($p/json/data/_/_/_)[last()])

};

 

Why does header is overwritten ?  I think if header is set explicitly it 
shouldn't be overwritten. 

 

Best Regards
Bogdan Bogucki

 

 



[basex-talk] - unclear strategy of setting header during serialization

2018-07-14 Thread Bogdan Bogucki
Hello,

 

I encountered strange behavior during HTTP response.

 

I need to set custom header Access-Control-Allow-Origin:*.

 

To do that I am using custom response.

 

Following code is working and set required header:

 

declare

  %rest:POST("{$json}")

  %rest:path("/ping")

function drpg:ping(

$json as xs:string

) as element()* {

  



  

  



  ,  

  let $p := json:parse($json)

  return ($p/json/data/_/_/_)[last()]

};

 

Response header:


Access-Control-Allow-Origin

*

 


Content-Length

11


Content-Type

text/html;charset=utf-8


Date

Sat, 14 Jul 2018 09:17:18 GMT


Server

Jetty(9.4.9.v20180320)

 

I want to return plain text, so when I change return parameter to xs:string*
and add data function header from  is overwritten. 

 

Response header:


Content-Length

6

 


Content-Type

application/xml; charset=UTF-8


Date

Sat, 14 Jul 2018 09:26:59 GMT


Server

Jetty(9.4.9.v20180320)

 

Example code:

declare

  %rest:POST("{$json}")

  %rest:path("/drpg/ping")

function drpg:ping(

$json as xs:string

) as xs:string* {

  



  

  



  ,  

  let $p := json:parse($json)

  return data(($p/json/data/_/_/_)[last()])

};

 

Why does header is overwritten ?  I think if header is set explicitly it
shouldn't be overwritten. 

 

Best Regards
Bogdan Bogucki

 

 



[basex-talk] ODP: http:send-request - problem with form data

2018-07-12 Thread Bogdan Bogucki
Hi Christian, 

Great!

I have one doubt why when we don't define body in http request third parameter 
is ignored ?

Only when body element is provided parseBody with bodies is invoked. 
I have to check source code to figure out how to pass body payload via third 
argument.

if(body != null) {
final QNm pl = body.qname();
// single part request
if(pl.eq(Q_BODY)) {
  parseBody(body, bodies, hr.payloadAtts, hr.payload);
  hr.isMultipart = false;
  // multipart request
} else if(pl.eq(Q_MULTIPART)) {
  parseMultipart(body, bodies.iter(), hr.payloadAtts, hr.parts);
  hr.isMultipart = true;
} else {
  throw HC_REQ_X.get(info, "Unknown payload element: " + body.qname());
}
}

Best Regards
Bogdan Bogucki
 

-Wiadomość oryginalna-
Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 12 lipca 2018 15:36
Do: Bogdan Bogucki
DW: BaseX
Temat: Re: [basex-talk] http:send-request - problem with form data

Hi Bogdan,

I finally had some time to get to the bottom of the conversion inconsistencies:

If the value is supplied as child of the http:body node, it will be serialized 
as text node. If it’s supplied as extra parameter, it will be serialized as 
string. If text nodes are serialized, entities will be encoded. Strings will be 
returned without encoded entities:

 →   
  ``[&]``   →   &

I agree this is not very intuitive, and I have now rewritten this as
follows: If the supplied output media-type does not result in one of the 
default serialization methods of the spec (xml, xhtml, html, json, text, 
adaptive), the text node will be atomized (i.e., converted to an item of type 
xs:untypedAtomic), which will then be serialized as plain string. With the new 
snapshot [1], it should make no difference if you supply your value as child of 
http:body or as extra argument.

As a general guide, I would recommended everyone to use the third argument for 
body items. It will be both safer and faster (in particular if binary data can 
be streamed). As the rich syntax of http:send-request is regularly confusing 
users on the list, I have reopened an old Github issue, which is about 
providing additional and simpler functions for the most widely used HTTP 
methods [2].

Best,
Christian

[1] http://files.basex.org/releases/latest/
[2] https://github.com/BaseXdb/basex/issues/914



On Wed, Jul 4, 2018 at 10:05 PM Christian Grün  
wrote:
>
> And thanks for the confirmation. I will try to find out why the two 
> alternatives make a difference.
>
>
>
> Bogdan Bogucki  schrieb am Mi., 4. Juli 2018, 21:56:
>>
>> Hello,
>>
>> It works with body as a third parameter. Body has to be defined in http 
>> request because without that third parameter is ignored.
>>
>> Working example:
>>
>> for $x in http:send-request(
>>   
>> 
>> 
>>   
>> ,'http:localhost:3333', 'start=0length=100 
>> ')[2]/data/results/content return $x
>>
>> Thank you Christian for help.
>>
>> Best Regards
>> Bogdan Bogucki
>>
>>
>> -Wiadomość oryginalna-
>> Od: Christian Grün [mailto:christian.gr...@gmail.com]
>> Wysłano: 4 lipca 2018 18:31
>> Do: bbogu...@hussar.pl
>> DW: BaseX
>> Temat: Re: [basex-talk] http:send-request - problem with form data
>>
>> Hi Bogdan,
>>
>> I didn’t try it, but what happens if you specify the body as third argument?
>>
>> Cheers,
>> Christian
>>
>>
>> On Tue, Jul 3, 2018 at 10:14 PM Bogdan Bogucki  wrote:
>> >
>> > Hello,
>> >
>> > I don't want pass values in query string. Server side expect parameters in 
>> > payload.
>> > HTML Form parameters in POST method are passed in payload not in URI.
>> > This is the reason why I put parameters in body. Problem is 
>> > escaping & character with  How can I force BaseX to not escape 
>> > characters in CDATA element ?
>> >
>> > This is my code:
>> >   
>> > 
>> > 
>> > 
>> > 
>> >   
>> >
>> > On server side I received following request:
>> >
>> > POST / HTTP/1.1
>> > User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64)
>> > AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99
>> > Safari/537.36
>> > Content-Type: application/x-www-form-urlencoded; charset=UTF-8
>> >
>> > Host: copart.com:
>> >
>> > Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>> >
>> > Connection: keep-alive
>> > Content-Length: 75
>> >
>> > start=0length=100sort=date_typepage=0size=100

[basex-talk] ODP: http:send-request - problem with form data

2018-07-03 Thread Bogdan Bogucki
Hello,

I don't want pass values in query string. Server side expect parameters in 
payload.
HTML Form parameters in POST method are passed in payload not in URI.
This is the reason why I put parameters in body. Problem is escaping & 
character with 
How can I force BaseX to not escape characters in CDATA element ?

This is my code:
  




  

On server side I received following request: 

POST / HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/67.0.3396.99 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Host: copart.com:

Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Connection: keep-alive
Content-Length: 75

start=0length=100sort=date_typepage=0size=100

I expect that CDATA will be not escaped, or I am wrong ?


Pozdrawiam
Bogdan Bogucki
 
HUSSAR SYSTEMS

NIP: 532-170-12-00 
Regon: 142624070

e-mail: bbogu...@hussar.pl
tel. kom.: +48 607 409 301
www: www.hussar.pl

-Wiadomość oryginalna-
Od: Christian Grün [mailto:christian.gr...@gmail.com] 
Wysłano: 3 lipca 2018 12:11
Do: bbogu...@hussar.pl
DW: BaseX
Temat: Re: [basex-talk] http:send-request - problem with form data

Hi Bogdan,

If you want your arguments parsed as HTTP query parameters, it should suffice 
to attach them to the URL:

  let $url := 'http://localhost:'
  let $params := ``[start=0=100=date_type=0=100]``
  return http:send-request(
 ...

If this is not what you need, you might need to give us more information on how 
the request will be handled server-side (for example, do you use RESTXQ?).

Best,
Christian




On Mon, Jul 2, 2018 at 11:11 PM Bogdan Bogucki  wrote:
>
> Hello,
>
>
>
> I have problem with http:send-request. I want to send post method request 
> with form data but I encountered problem with characters encoding.
>
> Example:
>
>
>
> Request:
>
> for $x in http:send-request(
>
>   
> 'http://localhost:'>
>
> 
>
> 
>
> 
>
> 
>
>   
>
> )[2]/json/data/results/content
>
> return $x
>
>
>
> Optimized Query:
>
> util:item-at(http:send-request(element 
> Q{http://expath.org/ns/http-client}request { (attribute method { ("post") }, 
> attribute href { ("http://localhost:;) }, element 
> Q{http://expath.org/ns/http-client}header { (attribute name { ("User-Agent") 
> }, attribute value { ("Mozilla/5.0 (Windows NT 6.1; Win64; x64) 
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36") }) 
> }, element Q{http://expath.org/ns/http-client}body { (attribute media-type { 
> ("application/x-www-form-urlencoded; charset=UTF-8") }, "
> start=0length=100sort=date_typepage=0size=100") 
> }) }), 2)/json/data/results/content
>
>
>
> Request send:
>
> POST / HTTP/1.1
>
> User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) 
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 
> Safari/537.36
>
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
>
> Host: copart.com:
>
> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>
> Connection: keep-alive
>
> Content-Length: 75
>
>
>
>
>
> start=0length=100sort=date_typepage=0size=100
>
>
>
> Payload is not correctly encoded it should be:
>
> start=0=100=date_type=0=100
>
>
>
> How can I force function http:send-request to serialize CDATA without 
> escaping ?
>
>
>
>
>
> Best Regards
>
> Bogdan Bogucki
>
>



[basex-talk] http:send-request - problem with form data

2018-07-02 Thread Bogdan Bogucki
Hello,

 

I have problem with http:send-request. I want to send post method request
with form data but I encountered problem with characters encoding.

Example:

 

Request:

for $x in http:send-request(

  











)[2]/json/data/results/content

return $x

 

Optimized Query:

util:item-at(http:send-request(element
Q{http://expath.org/ns/http-client}request { (attribute method { ("post") },
attribute href { ("http://localhost:;) }, element
Q{http://expath.org/ns/http-client}header { (attribute name { ("User-Agent")
}, attribute value { ("Mozilla/5.0 (Windows NT 6.1; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36")
}) }, element Q{http://expath.org/ns/http-client}body { (attribute
media-type { ("application/x-www-form-urlencoded; charset=UTF-8") }, "
start=0length=100sort=date_typepage=0size=100")
}) }), 2)/json/data/results/content

 

Request send:

POST / HTTP/1.1

User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Host: copart.com:

Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

Connection: keep-alive

Content-Length: 75

 

 

start=0length=100sort=date_typepage=0size=100

 

Payload is not correctly encoded it should be:

start=0=100=date_type=0=100

 

How can I force function http:send-request to serialize CDATA without
escaping ?

 

 

Best Regards

Bogdan Bogucki