<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.httpGet.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.httpGet</api:function-name><api:suggest>xdmp.httpget</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>httpget</api:suggest><api:function-link mode="xquery" fullname="xdmp:http-get">/apidoc/8.0/xdmp:http-get.xml</api:function-link><api:function mode="javascript" name="httpGet" type="builtin" lib="xdmp" category="Extension" subcategory="HTTP" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.httpGet"><api:summary>
  Sends the http GET method to the specified URI. Returns the http response
  as well as whatever information is identified by the specified URI
  (for example, an html document).
</api:summary><api:params><api:param name="uri" type="xs:string" optional="false"><api:param-description>
   The URI of the requested document.
  </api:param-description><api:param-name>uri</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="options" type="(element()|map:map)?" optional="true"><api:param-description>
    
    <span class="javascript" xmlns="http://www.w3.org/1999/xhtml">The options object for this request. The default
    value is null.
    This parameter can also include certain options (for example,
    <code>repair</code>,
    <code>encoding</code>, <code>defaultLanguage</code>) from
    <code>xdmp.documentLoad</code>
    and <code>xdmp.documentGet</code>.</span>
    <p xmlns="http://www.w3.org/1999/xhtml">The 
    <code class="javascript">xdmp.httpGet</code> options include:</p>
    <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
    
    <dt class="javascript"><p>headers</p></dt>
    
    <dd class="javascript">An object with each of its property representing one
    HTTP header. The name of the property is the header's name and the value
    of the property is the header's value.  The names can be anything, but
    many HTTP servers understand HTTP names such as
    <code>content-type</code>.</dd>
    
    <dt class="javascript"><p>authentication</p></dt>
    
    <dd class="javascript">The credentials and the authentication method
    to use for this request.  This object has properties for the
    <code>username</code> and <code>password</code>.
    The username is the name of the user to be authenticated
    on the http server. The password is that user's password.
    You can optionally use a <code>method</code> property on the
    "authentication" object.  If it is specified it must be either
    'basic' or 'digest'.  If a method is specified and the HTTP server
    requests a different type of authentication, then an error is raised.
    If the attribute is not specified, or matches the server's requested
    method, the authentication proceeds.</dd>
    
    <dt class="javascript"><p>timeout</p></dt>
    <dd>The amount of time, in seconds, to wait until the HTTP connection
    times out. The default value is the <code>http timeout</code> for the
    group.</dd>
    
    <dt class="javascript"><p>ciphers</p></dt>
    <dd>A standard cipher string. For details on legal ciper strings, see
    <a href="http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS">http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS</a>.
    </dd>
    
    <dt class="javascript"><p>client-cert</p></dt>
    <dd>A PEM encoded client certificate for identifying the client to
    the remote server.</dd>
    
    <dt class="javascript"><p>clientKey</p></dt>
    <dd>The private key that corresponds to
    <code class="javascript">clientCert</code>.</dd>
    
    <dt class="javascript"><p>passPhrase</p></dt>
    <dd>A pass phrase, if one is needed to decrypt client-key.</dd>
    
    <dt class="javascript"><p>method</p></dt>
    <dd>The authentication method, which can be "basic", "digest", "aws", or 
    "aws4".</dd>
    
    <dt class="javascript"><p>username</p></dt>
    <dd>A user name, if required for authentication.</dd>
    
    <dt class="javascript"><p>password</p></dt>
    <dd>A password, if required for authentication.</dd>
    
    <dt class="javascript"><p>allowSslv3</p></dt>
    <dd>A boolean value to specify whether to communicate using the SSL
     v3 protocol.
     The default is <code>true</code>, which indicates communication using the
     SSL v3 protocol.</dd>
    
    <dt class="javascript"><p>allowTls</p></dt>
    <dd>A boolean value to specify whether to communicate using the TLS
     protocol.
     The default is <code>true</code>, which indicates communication using the
     TLS protocol.</dd>
    
    <dt class="javascript"><p>verifyCert</p></dt>
    <dd>A boolean value to specify whether the server's certificate should be
    verified. The default value is <code>true</code>. A value of
    <code>false</code>
    should only be specfied after careful consideration of the security
    risks since it
    permits communication with servers whose certificates are expired, revoked,
    or signed by unknown or untrusted authorities. A value of <code>false</code>
    also removes protection against a man-in-the-middle attack.</dd>
    
    <dt class="javascript"><p>sslSessionCache</p></dt>
    <dd>A boolean value to specify whether ssl session should be cached and
    reused. The default value is <code>true</code>. A value of
    <code>false</code>
    should only be specfied if ssl session cache causes problem with
    a url.</dd>
    </dl>
    </blockquote>
  </api:param-description><api:param-name>options</api:param-name><api:param-type>Object?</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The http functions only operate on URIs that use the http or https
   schemes; specifying a URI that does not begin with <code>http://</code>
   or <code>https://</code> throws an exception.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">If an http function times out, it throws a socket received
   exception (SVC-SOCRECV).</p>
   <p xmlns="http://www.w3.org/1999/xhtml">An automatic encoding detector will be used if the value <code>auto</code>
   is specified for the <code>encoding</code> option
   .  If no option is specified, the encoding defaults to
   the encoding specified
   in the http header. If there is no encoding in the http header, the encoding
   defaults to UTF-8.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">The first node in the output of this function is the
   response header from the http server.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">The second node in the output of this function is the
   response from the http server.  The response is treated as
   text, XML, JSON or binary, depending on the content-type header sent from
   the http server.  If the node is html, the header should indicate
   <code>text/html</code>, which is returned as a text document by default.
   The type of document is determined by the mimetypes mappings, and
   you can change the mappings in the Admin Interface as needed.
   </p>
   
   
    <p class="javascript" xmlns="http://www.w3.org/1999/xhtml">
   To use this function with a proxy, you need to translate the URI to the
   proxy uri. For example:
   <pre xml:space="preserve">
function httpGetProxy(proxy, uri) {
var host = fn.subsequence(fn.tokenize(uri,'/'), 3, 3);
// you might need to modify the next line based on your proxy server config 
var proxyuri = fn.concat(proxy, uri);
return xdmp.httpGet(proxyuri,
               {headers:{host: host}});
};
  
httpGetProxy('http://some.proxy.com:8080','http://www.google.com');
   </pre>
   </p>
   
</api:usage><api:privilege>
   <code xmlns="http://www.w3.org/1999/xhtml">http://marklogic.com/xdmp/privileges/xdmp-http-get</code>
</api:privilege><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.httpGet("http://www.my.com/document.xhtml",
     {
       "authentication": {
         "method" : "basic",
         "username" : "myname",
         "password" : "mypassword"
       }
     })
=&gt; the response from the server as well as the specified document


</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.subsequence(
  xdmp.httpGet("http://www.marklogic.com",
     {
       "encoding" : "iso-8859-1"
     }), 2, 1)
=&gt; The specified document, transcoded from ISO-8859-1
   to UTF-8 encoding.  This assumes the document is
   encoded in ISO-8859-1.

</pre></api:example></api:function></api:function-page>