Skip to main content

TURL_SetCustomHeader (function reference)

By October 1, 2021October 13th, 2021Online Help, Troi URL plug-in
Troi URL Plug-in > Functions reference > TURL_SetCustomHeader
Troi URL Plug-in for FileMaker Pro

TURL_SetCustomHeader

Sets a custom header to be used.

SyntaxFunction badge

TURL_SetCustomHeader( switches ; customHeaderText )

Parameters

switches not used, reserved for future use. Leave blank or put "-unused"
customHeaderText the customHeaderText

Returned Result

Data type returned

Error code

Result

If successful this function returns 0. If unsuccessful it returns an error code starting with $$ followed by the error code.

At the moment this function does not return errors.

Originated in

Troi URL Plug-in 1.2

Compatibility

FileMaker Pro 16 to 19

Considerations

Some web browsers require a special header text before they return the wanted data. This function allows you to set this text.

The custom header text is remembered until you specify a different text. The text is also removed when you quit FileMaker Pro. The maximum length of the custom header text is 1Gb.

If you don’t specify a custom header text the plug-in will use a default header. If you specify an empty string the default header will be used.

Each line of the custom header needs to be separated with a return. If you use a calculation to construct the custom header, add the return character ¶ between each line.

Example

TURL_SetCustomHeader ("-unused " ; 
"Accept: */*" & "¶" &
"Content-Type: text/html" & "¶" &
"Cookie: 1234-ckie-5678" )

This will send the custom header with each subsequent request. If you want to reset to the default headers use:

Set Field [ result ; TURL_SetCustomHeader ( "-unused" ; "" ) ]

This will clear the custom header text. No custom headers will be sent with a request.

Example 2

Some web servers expect web forms to be sent with specific custom headers (usually x-www-form-urlencoded). In this case you should set the headers before you send the form to the server. This can be done like this:

Set Variable [ $result ; TURL_SetCustomHeader ( "-unused"  ; 
		"Content-Type:application/x-www-form-urlencoded" ) ]
Set Variable [ $resultData ; TURL_Post ( "-unused" ; $URL ; $FormData ) ]

Here $URL is a variable with the URL of the POST and $FormData is a variable that contains the form data to be sent.

Related functionFunction badge

TURL_Post

Related topics

Troi URL Plug-in online help (overview)


Online Help Page for Troi URL Plug-in for 16 to 19 –> TURL_SetCustomHeader (urlp4409) 2021-1013 16:34:38