KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: v15 honors Hypertext Transfer Protocol (HTTP/1.1) regarding web requests
PRODUCT: 4D | VERSION: 15 | PLATFORM: Mac & Win
Published On: December 17, 2015

When responding to a web request and the response will be using the 4D command WEB SEND TEXT developers must be aware that 4D v15 strictly honors the guidelines for Accept found in the HTTP/1.1 when it comes to responding with the MIME type specified in the Accept header.

If the MIME type set for 4D to return does not match the MIME type in the Accept header 4D v15 returns a 406 -- Not Acceptable error.

This is significantly different from prior versions of 4D, which did not return the 406 error when using WEB SEND TEXT, it was up to the web client to handle what was being returned.

In 4D v14.4 the optional second parameter in WEB SEND TEXT was changed from a Boolean to a MIME type. If the optional parameter is not included 4D by default returned the MIME type of "text/html."

It has been a common practice to ignore the values in the Accept header, see the hightlighted elements in the image below.



The example above illustrates how a web client can make a request and is willing to accept more than one MIME type in response. There is a precedence as to what is desired for the response. See the guidelines referenced in paragraph one for explanation.

Within 4D the desired MIME type can be captured using the 4D command WEB GET HTTP HEADER, see the image below. In this example, if the Accept header is not present the response is sent using the default MIME type of "text/html."