Header fields
When setting up a WebSocket connection, an HTTP request is first sent to the server. This request is used to switch the connection from HTTP to the WebSocket protocol. In this initial request, header fields can be used to exchange additional information between the client and the server.
Header fields consist of a field name and an associated value. They contain metadata about the request and can, for example, convey information regarding authentication, the requested resource, or server-specific requirements.
In TwinCAT, additional header fields can be created using the FB_IotHttpHeaderFieldMap function block to establish a connection and passed to the WebSocket client. This allows the requirements of a WebSocket server to be taken into account directly from within the PLC context.
The header fields are used exclusively for establishing the initial HTTP connection. After successfully switching to the WebSocket protocol, further communication no longer takes place via HTTP messages, but rather via WebSocket frames.