4D v16.3

WEB SET HTTP HEADER

Home

 
4D v16.3
WEB SET HTTP HEADER

WEB SET HTTP HEADER 


 

WEB SET HTTP HEADER ( header|fieldArray {; valueArray} ) 
Parameter Type   Description
header|fieldArray  Text, Text array in Field or variable containing the request HTTP header or HTTP header fields
valueArray  Text array in HTTP header field content

The WEB 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.
This command allows you to manage “cookies”.

Two syntaxes are available for this command:

  • First syntax: WEB 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=/"
 WEB 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: WEB 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"
 fieldArray{4}:="Server"
 
 valueArray{1}:="HTTP/1.0"*
 valueArray{2}:="200 OK"*
 valueArray{3}:="C=HELLO"
 valueArray{4}:="North_Carolina"

* 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. By default, the Server field is "4D/<version>". The Date and Content-Length fields are also set by default by 4D.



See also 

WEB GET HTTP HEADER

 
PROPERTIES 

Product: 4D
Theme: Web Server
Number: 660

This command can be run in preemptive processes

 
HISTORY 

Modified: 4D v6.8
Renamed: 4D v13
Modified: 4D v14 R3

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)