From: Loren C. <lor...@gm...> - 2010-05-10 22:52:46
|
I need to add authentication to the httpclient function module. I will be adding the optional parameters of username and password to the functions. If the call without the username and password returns SC_UNAUTHORIZED ala: http://www.java2s.com/Code/Java/Apache-Common/BasicAuthenticationGetJSPMethodReturnCode.htm Does anyone have any serious objections to this? If you do not add the username/password combination and the call receives an SC_UNAUTHORIZED, then it will work as it currently works. Loren httpclient http://exist-db.org/xquery/httpclient A module for performing HTTP requests as a client clear-all httpclient:clear-all() empty() Clears all persistent state (eg. cookies, crednetials, etc.) stored in the current session on the client. delete httpclient:delete($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP DELETE request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. $url The URL to process $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> $username The username $password The password Returns the XML body content get httpclient:get($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP GET request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. $url The URL to process $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content head httpclient:head($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP HEAD request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response> $url The URL to process $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content options httpclient:options($url as xs:anyURI, $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP OPTIONS request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers></httpclient:response> $url The URL to process $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content post httpclient:post($url as xs:anyURI, $content as item(), $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP POST request. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. $url The URL to process $content The XML POST payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string. $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content post-form httpclient:post-form($url as xs:anyURI, $content as element(), $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP POST request for a form. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. $url The URL to process $content The form data in the format <httpclient:fields><httpclient:field name="" value="" type="string|file"/>...</httpclient:fields>. If the field values will be suitably URLEncoded and sent with the mime type application/x-www-form-urlencoded. $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content put httpclient:put($url as xs:anyURI, $content as node(), $persist as xs:boolean, $request-headers as element()?, $username as xs:string?, $password as xs:string?) item() Performs a HTTP PUT request.. This method returns the HTTP response encoded as an XML fragment, that looks as follows: <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"><httpclient:headers><httpclient:header name="name" value="value"/>...</httpclient:headers><httpclient:body type="xml|xhtml|text|binary" mimetype="returned content mimetype">body content</httpclient:body></httpclient:response> where XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data. $url The URL to process $content The XML PUT payload/content. If it is an XML Node it will be serialized, any other type will be atomized into a string. $persist Indicates if the HTTP state (eg. cookies, credentials, etc.) should persist for the life of this xquery $request-headers Any HTTP Request Headers to set in the form <headers><header name="" value=""/></headers> Returns the XML body content Return to list of all modules |