Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

CURL.SetOptionHTTPHeader

Sets the http header list.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 2.5 Yes Yes Yes Yes Yes

MBS( "CURL.SetOptionHTTPHeader"; Handle; Value )

Parameters

Parameter Description Example value
Handle The CURL session handle. $curl
Value Header values "Content-Type: text/xml"

Result

Returns "OK" on success.

Description

Sets the http header list.
Pass a list of HTTP headers to pass to the server in your HTTP request. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no content as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no content, make the content be two quotes: "". The headers included in the linked list must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified.

The first line in a request (containing the method, usually a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers. Adding this method line in this list of headers will only cause your request to send an invalid header.

Pass a no parameters to this to reset back to no custom headers.

The most commonly replaced headers have "shortcuts" in the options CURL.SetOptionCookie, CURL.SetOptionUserAgent and CURL.SetOptionReferer.

This option takes a list of items. So this function takes a variable number of arguments. If you call function with 2 parameters, you set an empty list. If you call it with 5 parameters, you set a list with 3 values.

Examples

Set text/xml content type:

MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: text/xml" )

Set two custom headers:

MBS( "CURL.SetOptionHTTPHeader"; $curl; "MyHeader1: hello"; "MyHeader2: world" )

Call with three parameters:

MBS( "CURL.SetOptionHTTPHeader"; handle; $value1; $value2; $value3 )

For SOAP, set content type and disable Expect header:

MBS("CURL.SetOptionHTTPHeader"; $curl; "Expect:"; "Content-Type: text/xml")

Set content type including a soap action:

MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/soap+xml;charset=UTF-8;action=\"urn:sap-com:document:sap:soap:functions:mc-style:ZMF_WS_00:ZmfWs00Request\"" )

Request no cached copy:

MBS("CURL.SetOptionHTTPHeader"; $curl; "Cache-Control: no-cache")

Set content type for URL encoded form data:

MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/x-www-form-urlencoded" )

See also

Example Databases


CURL.SetOptionHTTPContentDecoding   -   CURL.SetOptionHTTPProxyTunnel

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins