submitResponse

Submits response HEADERS frame and optionally one or more DATA frames against the stream |stream_id|.

The |hfa| is an array of HeaderField with |hfa.length| elements. The application is responsible to include required pseudo-header fields (header field whose name starts with ":") in |hfa| and must place pseudo-headers before regular header fields.

This function creates copies of all header fields in |hfa|. It also lower-cases all names in |hfa|. The order of elements in |hfa| is preserved.

HTTP/2 specification has requirement about header fields in the response HEADERS. See the specification for more details.

If |data_prd| is not null, it provides data which will be sent in subsequent DATA frames. If |data_prd| is null, HEADERS will have END_STREAM flag set.

This method can be used as normal HTTP response and push response. When pushing a resource using this function, the Session must be configured using new Session() or its variants and the target stream denoted by the |stream_id| must be reserved using submitPushPromise().

To send non-final response headers (e.g., HTTP status 101), don't use this function because this function half-closes the outbound stream. Instead, use submitHeaders() for this purpose.

This function returns 0 if it succeeds, or one of the following negative error codes:

ErrorCode.INVALID_ARGUMENT The |stream_id| is 0.

.. warning::

Calling this function twice for the same stream ID may lead to program crash. It is generally considered to a programming error to commit response twice.

Meta