Hello,

 

Could you please advise how to use xdmp:http-post and xdmp:http-get for
proxy? The MarkLogic Server running behind a proxy and trying to use
xdmp:http-post and xdmp:http-get functions to connect the external site, but
getting <code>400</code> <message>Bad Request</message>.

 

Will MarkLogic Server 7.x support proxy options?

 

 

1.       Request and Response without proxy.

                                                

Request

let $uri := "https://www.google.com.sg/?gws_rd=ssl#q=xml";

let $result := xdmp:http-get($uri,

                                <options xmlns="xdmp:document-get">

                                                <format>binary</format>

                                </options>)

  return $result

 

 

Response

<response xmlns="xdmp:http">

                <code>200</code>

                <message>OK</message>

                <headers>

                                <date>Thu, 20 Nov 2014 03:33:28 GMT</date>

                                <server>Apache</server>

 
<transfer-encoding>chunked</transfer-encoding>

                                <content-type>text/html;
charset=utf-8</content-type>

                </headers>

</response>

<binary node of 155262 bytes> {0x3C21444F43545950...}

 

2.       Request made as discussed at this
http://markmail.org/message/sbfj44jtmpsyopyh   (with proxy server)  

 

Request

let $proxy := "http://172.21.10.60:3128"; (: simple http proxy :)

let $uri := " https://www.google.com.sg/?gws_rd=ssl#q=xml";(: target web
service :)

 

let $host := tokenize($uri,'/')[3] 

let $proxyuri := concat($proxy, '/', tokenize($uri, '/')[last()])  

 

return xdmp:http-post(

      $proxyuri,

      <options xmlns="xdmp:http">

        <headers>

          <Host>{$host}</Host>          

        </headers>

      </options>

    )

 

Response

<response xmlns="xdmp:http">

  <code>400</code>

  <message>Bad Request</message>

  <headers>

    <server>squid/3.1.4</server>

    <mime-version>1.0</mime-version>

    <date>Thu, 20 Nov 2014 04:09:50 GMT</date>

    <content-type>text/html</content-type>

    <content-length>3071</content-length>

    <x-squid-error>ERR_INVALID_URL 0</x-squid-error>

    <vary>Accept-Language</vary>

    <content-language>en</content-language>

    <x-cache>MISS from l076ddms1</x-cache>

    <x-cache-lookup>NONE from l076ddms1:3128</x-cache-lookup>

    <via>1.0 l076ddms1 (squid/3.1.4)</via>

    <proxy-connection>close</proxy-connection>

  </headers>

</response>

 

Look at the URL formed by the above request

 

<div id="content">

<p>The following error was encountered while trying to retrieve the URL: <a
href="/?gws_rd=ssl#q=xml">/?gws_rd=ssl#q=xml</a></p>

 

Thanks. 

 

Regards

Dinesh 

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to