Skip to content

Commit

Permalink
ENH: switched back to the httpclient module for http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Sep 11, 2013
1 parent 45ff34e commit b7c084d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion webapp/xql/modules/ajax.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ declare function ajax:getPNDBeacons($pnd as xs:string, $name as xs:string, $lang
let $findbuchResponse := wega:grabExternalResource('beacon', $pnd, (), true())
(:util:binary-to-string(wega:grabExternalResource('beacon', $pnd, (), true())):)
let $jxml :=
if(exists($findbuchResponse)) then xqjson:parse-json($findbuchResponse)
if(exists($findbuchResponse)) then
if($findbuchResponse/httpclient:body/@encoding = 'Base64Encoded') then xqjson:parse-json(util:binary-to-string($findbuchResponse))
else xqjson:parse-json($findbuchResponse)
else ()
let $list :=
<ul>{
Expand Down
12 changes: 9 additions & 3 deletions webapp/xql/modules/wega.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -1777,11 +1777,17 @@ declare function wega:printSourceDesc($doc as document-node(), $lang as xs:strin
declare %private function wega:http-get($url as xs:anyURI) as element(wega:externalResource) {
let $req := <http:request href="{$url}" method="get" timeout="4"/>
let $response :=
try { http:send-request($req) }
try { (:http:send-request($req):) httpclient:get($url,true(), ()) }
catch * {wega:logToFile('warn', string-join(('wega:http-get', $err:code, $err:description, 'URL: ' || $url), ' ;; '))}
let $statusCode := $response[1]/data(@status)
let $response :=
if($response/httpclient:body[matches(@mimetype,"text/html")]) then wega:changeNamespace($response,'http://www.w3.org/1999/xhtml', 'http://exist-db.org/xquery/httpclient')
else $response
(: let $statusCode := $response[1]/data(@status):)
return
<wega:externalResource date="{current-date()}">
{$response}
</wega:externalResource>
(:<wega:externalResource date="{current-date()}">
<httpclient:response statusCode="{$statusCode}">
<httpclient:headers>{
for $header in $response[1]//http:header
Expand All @@ -1791,7 +1797,7 @@ declare %private function wega:http-get($url as xs:anyURI) as element(wega:exter
{$response[2]}
</httpclient:body>
</httpclient:response>
</wega:externalResource>
</wega:externalResource>:)
};

(:~
Expand Down

0 comments on commit b7c084d

Please sign in to comment.