Fix fcgi_muxer_send()

Outgoing records were missing padding and the reserved field.
This commit is contained in:
Přemysl Eric Janouch 2018-10-13 04:08:09 +02:00
parent fd17b4e504
commit 8b334e9c91
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 6 additions and 2 deletions

View File

@ -145,14 +145,18 @@ fcgi_muxer_send (struct fcgi_muxer *self,
hard_assert (len <= UINT16_MAX); hard_assert (len <= UINT16_MAX);
struct str message = str_make (); struct str message = str_make ();
static char zeroes[8];
size_t padding = -len & 7;
str_pack_u8 (&message, FCGI_VERSION_1); str_pack_u8 (&message, FCGI_VERSION_1);
str_pack_u8 (&message, type); str_pack_u8 (&message, type);
str_pack_u16 (&message, request_id); str_pack_u16 (&message, request_id);
str_pack_u16 (&message, len); // content length str_pack_u16 (&message, len); // content length
str_pack_u8 (&message, 0); // padding length str_pack_u8 (&message, padding); // padding length
str_pack_u8 (&message, 0); // reserved
str_append_data (&message, data, len); str_append_data (&message, data, len);
str_append_data (&message, zeroes, padding);
// XXX: we should probably have another write_cb that assumes ownership // XXX: we should probably have another write_cb that assumes ownership
self->write_cb (self->user_data, message.str, message.len); self->write_cb (self->user_data, message.str, message.len);