HTTP server request/reply for logging user exit

The HTTP server request/reply for logging user exit enables z/TPF applications to log inbound HTTP requests and outbound HTTP responses.

When the z/TPF HTTP server successfully reads a request from an HTTP client, the HTTP server request/reply for logging user exit is called. The input structure that is passed to the user exit contains the following items:
  • The socket descriptor that read the request.
  • Start of changeThe connection type. A value of zero indicates a non-SSL connection. A value of 1 indicates an SSL connection.End of change
  • Remote and local IP addresses and port numbers.
  • A pointer to the HTTP server request structure.
  • A pointer to the data that was received. For a body that was received in chunks, the individual chunks are combined by the z/TPF HTTP server and presented as part of the data that is passed to the user exit. Start of changeFor HTTP/2 requests this value is NULL. A compatible HTTP/1.x data format can be created by using the tpf_httpFormatRequest function.End of change
  • The length of the data that was received. Start of changeFor HTTP/2 requests, this value is 0.End of change
  • A flag that indicates whether a body was received in chunks.
  • Start of changeThe HTTP/2 stream identifier. For non-HTTP/2 requests, this value is 0.End of change
The user exit can log the request before returning to the z/TPF HTTP server, which enters the server application to send the response.
If the server application issues the tpf_httpSendResponse function to send the HTTP response, the HTTP server request/reply for logging user exit is called a second time. The input structure that is passed to the user exit contains the following items:
  • The socket descriptor that is assigned to the response.
  • Start of changeThe connection type. A value of zero indicates a non-SSL connection. A value of 1 indicates an SSL connection.End of change
  • Remote and local IP addresses and port numbers.
  • A pointer to the HTTP server response structure. Start of changeFor HTTP/2 stream and connection errors, this value is NULL. The stream identifier is 0 for HTTP/2 connection errorsEnd of change.
  • A pointer to the HTTP response data. Start of changeFor HTTP/2 responses, this value is NULL. A compatible HTTP/1.x data format can be created by using the tpf_httpFormatResponse function.End of change
  • The length of the HTTP response data. Start of changeFor HTTP/2 responses, this value is 0.End of change
  • A flag that indicates whether data was sent and whether the body was compressed.
  • Start of changeThe HTTP/2 stream identifier. For non-HTTP/2 responses, this value is 0.End of change
  • Start of changeThe error code sent for HTTP/2 stream and connection errors.End of change
If the body of the HTTP response was compressed, the HTTP server response structure contains a pointer to the uncompressed data. The compressed data is contained in the HTTP response data after the start line and the headers.

If the z/TPF HTTP request sweeper detects that a request has timed out because the server application did not issue the tpf_httpSendResponse function, the HTTP server request/reply for logging user exit is called when the sweeper uses the tpf_httpSendResponse function to send an internal server error to the client.

The socket descriptor Start of changeand HTTP/2 stream identifierEnd of change can be used to correlate the response with the original request that was received from the HTTP client. The user exit can log the response before returning to the z/TPF HTTP server, which returns to the server application that issued the tpf_httpSendResponse function.

If an error occurs on the z/TPF HTTP server response, errno is set and the HTTP server request/reply for logging user exit is called with the following data that is passed from the input structure:
  • The associated socket descriptor, if available
  • Remote and local IP addresses and port numbers, if available
  • A pointer to the HTTP server response structure

If errno is set to ETPF_HTTPSENDRSP_TOKEN_ERR, the user exit is not entered.

The HTTP server request/reply for logging user exit is called only if the z/TPF HTTP server successfully reads a request from an HTTP clientStart of change, or if an HTTP/2 connection error occursEnd of change. If the z/TPF HTTP server successfully reads an HTTP request, the user exit is called a second time when the HTTP server application on the z/TPF system issues the tpf_httpSendResponse function to send the response to the HTTP client.