zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #23543
Re: [Merge] lp:~zorba-coders/zorba/json-http-module into lp:zorba
> "timeout" option has a bug. Uncomment "timeout" in the following script and
> get this error:
>
> $ ./zorba -i -f -q q.jq
> error [zerr:ZSTR0040]: type error: Item::getIntValue() not defined for type
> "xs:integer"
>
>
> jsoniq version "1.0";
> import module namespace http="http://zorba.io/modules/http-client";
>
> http:send-request(
> {
> "method": "POST",
> "href": "http://requestb.in/13727yx1",
> "authentication":
> {
> "username" : "user",
> "password" : "pass",
> "auth-method" : "Basic"
> },
> "options":
> {
> "status-only": true,
> "override-media-type": "text/plain",
> "follow-redirect": true,
> (: "timeout": "30", :)
> "user-agent": "Mozilla/5.0"
> },
> "headers":
> {
> "name": "value"
> },
> "body":
> {
> "media-type": "text/plain",
> "content": "..."
> }
> })
Federico, the problem occurs because getIntValue only works for xs:int items and not for xs:integer. However, because there is no representation of an arbitrary precision integer in the API, you have to do a trick as follows:
Item lTmp = aOptions.getObjectValue("timeout");
if (!lTmp.isNull())
{
if (lTmp.getTypeCode() != store::XS_INTEGER)
{
// raiseTypeError(lTmp.getType(), "timeout", "integer");
}
else
{
aValue = atoi(lTmp.getStringValue().c_str());
}
}
else
{
aValue = 0;
}
--
https://code.launchpad.net/~zorba-coders/zorba/json-http-module/+merge/169579
Your team Zorba Coders is subscribed to branch lp:zorba.
References