SET HTTP HEADER

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 6.8 (Modified)


SET HTTP HEADER (header|fieldArray{; valueArray})

ParameterTypeDescription
header|fieldArrayText|Text ArrayField or variable containing the request HTTP header
or HTTP header fields
valueArrayText ArrayHTTP header field content

Description

The SET HTTP HEADER command allows you to set the fields in the HTTP header of the reply sent to the Web browser by 4D. It only has an effect in a Web process in non-contextual mode.

This command allows you to manage "cookies".

Two syntaxes are available for this command:

First syntax: SET HTTP HEADER (header)

You pass the HTTP header fields to the fields parameter, of the Text type (variable or field), that you want to set.

This syntax allows writing header types such as "HTTP/1.0 200 OK"+Char(13)+"Set-Cookie: C=HELLO". Header fields must be separated by the CR or CR+LF (Carriage return + Line feed) sequence, under Windows and Mac OS, 4D formats the reply.

Here is an example of a custom "cookie":

   C_TEXT($vTcookie)
   $vTcookie:="SET-COOKIE: USER="+String(Abs(Random))+"; PATH=/"
   SET HTTP HEADER($vTcookie)

Note: The command will not accept a literal text type constant as the header parameter; it must be a 4D variable or field.

For more information about the syntax, please refer to the R.F.Cs (Request For Comments) that can be found at the following Internet address: http://www.w3c.org.

Second syntax: SET HTTP HEADER (fieldArray; valueArray)

The HTTP header is defined through two text arrays, fieldArray and valueArray. The header will be written as follows:

   fieldArray{1}:="X-VERSION"
   fieldArray{2}:="X-STATUS"
   fieldArray{3}:="Set-Cookie"

   valueArray{1}:="HTTP/1.0" *
   valueArray{2}:="200 OK" *
   valueArray{3}:="C=HELLO"

* The first two items are the first line of the reply. When they are entered, they must be the first and second items of the arrays. However, it is possible to omit them and to write only the following (4D will handle the header format):

   fieldArray{1}:="Set-Cookie"
   valueArray{1}:="C=HELLO" 

If you do not specify a state, it will automatically be HTTP/1.0 200 OK.

If several SET HTTP HEADER calls occur in the same Web process, only the last call is taken into account.

The Server, Date and Content-Length fields are always set by 4D.

See Also

GET HTTP HEADER.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next