IETF Date in If-Modified-Since header
Tuesday, 29 May 2018 · 3 messages
ML
Marco Lettere29 May 2018 13:49 #
Hello all,
need to use the If-Modified-Since header in one of my APIs. The format requested is the IETF date format:
If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT
as explained in [1].
If I pass the header as prescribed to a restxq made like:
declare
%rest:path("config")
%rest:header-param("If-Modified-Since", "{$modifiedsince-ietf}") %rest:HEAD
function config:check($modifiedsince-ietf as xs:string?){
I get the following exception:
Cannot convert xs:string+ to xs:string?: ("Wed", "21 Oct 2015 07:28:00 GMT").
Which somehow demonstrates that , is treated as a separator of values for the header.
I patched by replacing ? with * and using a string-join on the $modifiedsince-ietf before passing it to the follwoing parse-ietf-date function. But this is hard to explain and probably subject to other issues in the future.
Is there a way to pass HTTP headers verbatim to the RestXQ function?
thanks!
M.
[1]
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since
CG
Christian Grün29 May 2018 13:58 #
Hi Marco,
The current RESTXQ 1.0 specification seems to mandate that comma separated lists needs to be extracted to single items [1]. There isn’t that much activity on the EXQuery repository [2], but maybe it could be discussed over there?
As an alternative, you can use the
request:header function to retrieve the full value [3].
Best,
Christian
[1]
http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-specification.html#form-header-annotation [2] https://github.com/exquery/exquery/issues
[3] http://docs.basex.org/wiki/Request_Module#request:headerQuoted text · Marco Lettere · 42 lines
On Tue, May 29, 2018 at 1:49 PM, Marco Lettere <m.lettere at gmail.com> wrote: > Hello all, > > need to use the If-Modified-Since header in one of my APIs. The format > requested is the IETF date format: > > If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT > > as explained in [1]. > > If I pass the header as prescribed to a restxq made like: > > declare > %rest:path("config") > %rest:header-param("If-Modified-Since", "{$modifiedsince-ietf}") > %rest:HEAD > function config:check($modifiedsince-ietf as xs:string?){ > > I get the following exception: > > Cannot convert xs:string+ to xs:string?: ("Wed", "21 Oct 2015 07:28:00 > GMT"). > > Which somehow demonstrates that , is treated as a separator of values for > the header. > > I patched by replacing ? with * and using a string-join on the > $modifiedsince-ietf before passing it to the follwoing parse-ietf-date > function. But this is hard to explain and probably subject to other issues > in the future. > > Is there a way to pass HTTP headers verbatim to the RestXQ function? > > thanks! > > M. > > > [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If > -Modified-Since > >
ML
Marco Lettere29 May 2018 14:38 #
Quoted text · Christian Grün · 7 lines
On 29/05/2018 13:58, Christian Grün wrote: > Hi Marco, > > The current RESTXQ 1.0 specification seems to mandate that comma > separated lists needs to be extracted to single items [1]. There isn’t > that much activity on the EXQuery repository [2], but maybe it could > be discussed over there?
Yes. Going to ask there.
Quoted text · Christian Grün · 4 lines
> > As an alternative, you can use the request:header function to retrieve > the full value [3]. >
Much better solution than mine! I'll follow this advice. Thanks!
Quoted text · Christian Grün · 55 lines
> Best, > Christian > > [1] > http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-specification.html#form-header-annotation > [2] https://github.com/exquery/exquery/issues > [3] http://docs.basex.org/wiki/Request_Module#request:header > > > > On Tue, May 29, 2018 at 1:49 PM, Marco Lettere <m.lettere at gmail.com > <mailto:m.lettere at gmail.com>> wrote: > > Hello all, > > need to use the If-Modified-Since header in one of my APIs. The > format requested is the IETF date format: > > If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT > > as explained in [1]. > > If I pass the header as prescribed to a restxq made like: > > declare > %rest:path("config") > %rest:header-param("If-Modified-Since", "{$modifiedsince-ietf}") > %rest:HEAD > function config:check($modifiedsince-ietf as xs:string?){ > > I get the following exception: > > Cannot convert xs:string+ to xs:string?: ("Wed", "21 Oct 2015 > 07:28:00 GMT"). > > Which somehow demonstrates that , is treated as a separator of > values for the header. > > I patched by replacing ? with * and using a string-join on the > $modifiedsince-ietf before passing it to the follwoing > parse-ietf-date function. But this is hard to explain and probably > subject to other issues in the future. > > Is there a way to pass HTTP headers verbatim to the RestXQ function? > > thanks! > > M. > > > [1] > https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since > <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since> > >
Written for BaseX 9.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery