if (get_flags() & PRIORITY)
hpack_headers_offset = 5;
+ // No message body after stream bit is set
+ bool no_message_body = (get_flags() & END_STREAM);
+
// Set up the decoding context
Http2HpackDecoder& hpack_decoder = session_data->hpack_decoder[source_id];
if (!hpack_decoder.decode_headers((data.start() + hpack_headers_offset), data.length() -
hpack_headers_offset, decoded_headers,
start_line_generator, session_data->events[source_id],
- session_data->infractions[source_id]))
+ session_data->infractions[source_id], no_message_body))
{
session_data->frame_type[source_id] = FT__ABORT;
error_during_decode = true;
bool Http2HpackDecoder::decode_headers(const uint8_t* encoded_headers,
const uint32_t encoded_headers_length, uint8_t* decoded_headers,
Http2StartLine *start_line_generator, Http2EventGen* stream_events,
- Http2Infractions* stream_infractions)
+ Http2Infractions* stream_infractions, bool no_message_body)
{
uint32_t total_bytes_consumed = 0;
uint32_t line_bytes_consumed = 0;
if (!start_line->is_finalized())
success &= finalize_start_line();
- // write the last CRLF to end the header
+ /* Write the last CRLF to end the header
+
+ Adding artificial chunked header to end of HTTP/1.1 decoded header block for H2I to communicate
+ frame boundaries to http_inspect and http_inspect can expect chunked data during inspection */
if (success)
{
- success = write_decoded_headers((const uint8_t*)"\r\n", 2, decoded_headers +
- decoded_headers_size, MAX_OCTETS - decoded_headers_size, line_bytes_written);
+ if (no_message_body)
+ success = write_decoded_headers((const uint8_t*)"\r\n", 2, decoded_headers +
+ decoded_headers_size, MAX_OCTETS - decoded_headers_size, line_bytes_written);
+ else
+ {
+ const uint8_t chunk_hdr[] = "transfer-encoding: chunked\r\n\r\n";
+ success = write_decoded_headers(chunk_hdr, sizeof(chunk_hdr) - 1, decoded_headers +
+ decoded_headers_size, MAX_OCTETS - decoded_headers_size, line_bytes_written);
+ }
decoded_headers_size += line_bytes_written;
}
else
Http2HpackDecoder() { }
bool decode_headers(const uint8_t* encoded_headers, const uint32_t encoded_headers_length,
uint8_t* decoded_headers, Http2StartLine* start_line,
- Http2EventGen* stream_events, Http2Infractions* stream_infractions);
+ Http2EventGen* stream_events, Http2Infractions* stream_infractions, bool no_message_body);
bool write_decoded_headers(const uint8_t* in_buffer, const uint32_t in_length,
uint8_t* decoded_header_buffer, uint32_t decoded_header_length, uint32_t& bytes_written);
bool decode_header_line(const uint8_t* encoded_header_buffer,