4D v13.4WEB SEND RAW DATA |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v13.4
WEB SEND RAW DATA
WEB SEND RAW DATA
The WEB SEND RAW DATA command lets the 4D Web server send “raw” HTTP data, which can be chunked. . The data parameter contains the two standard parts of an HTTP response, i.e. Header and Body. The data are sent without prior formatting by the server. However, 4D carries out a basic check of the response header and body in order to make sure that they are valid:
HTTP/1.1 302 Location: http://... If you only pass: Location: http://... 4D will complete the request by adding HTTP/1.1 302. The optional * parameter lets you specify that the response will be sent “chunked”. The cutting up of responses into chunks can be useful when the server sends a response without knowing its total length (if, for instance, the response has not yet been generated). All HTTP/1.1-compatible browsers accept chunked responses. If you pass the * parameter, the Web server will automatically include the transfer-encoding: chunked field in the header of the response, if necessary (you can handle the response header manually if you so desire). The remainder of the response will also be formatted in order to respect the syntax of the chunked option. Chunked responses contain a single header and an undefined number of body “chunks”. All the WEB SEND RAW DATA statements that follow the execution of WEB SEND RAW DATA(data;*) within the same method will be considered as part of the response (regardless of whether they contain the * parameter). The server puts an end to the chunked send when the method execution is terminated. Note: If the Web client does not support HTTP/1.1, 4D will automatically convert the response into an HTTP/1.0-compatible format (the data sent will not be chunked). However, in this case, the result may not correspond to your wishes. It is therefore recommended to check whether the Web browser supports HTTP/1.1 and to send an appropriate response. To do so, you can use a method such as: C_BOOLEAN($0) Combined with the WEB GET HTTP BODY command and other commands of the “Web Server” theme, this command completes the range of tools available to 4D developers in order to entirely customize the processing of incoming and outgoing HTTP connections. These different tools are shown in the following diagram: This example illustrates the use of the chunked option with the WEB SEND RAW DATA command. The data (a sequence of numbers) are sent in 100 chunks generated on the fly in a loop. Keep in mind that the header of the response is not explicitly set: the command will send it automatically and insert the transfer-encoding: chunked field into it since the * parameter is used. C_LONGINT($cpt) |
PROPERTIES
Product: 4D
INDEX HISTORY
SEE ALSO
WEB GET HTTP BODY |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||