Mark websocket http responses as keep_alive

The keep_alive flag is needed on http_response for websocket
connections. Without it, the server closes the connection as soon as a
reply to the first frame is sent.
master
Jessie Murray 3 years ago
parent 71a30e9d3a
commit b46bb8504b
No known key found for this signature in database
GPG Key ID: E7E4D57EDDA744C5

@ -415,12 +415,14 @@ ws_reply(struct cmd *cmd, const char *p, size_t sz) {
/* send WS frame */ /* send WS frame */
r = http_response_init(cmd->w, 0, NULL); r = http_response_init(cmd->w, 0, NULL);
if (cmd_is_subscribe(cmd)) { if (r == NULL) {
r->keep_alive = 1; free(frame);
slog(cmd->w->s, WEBDIS_ERROR, "Failed response allocation in ws_reply", 0);
return -1;
} }
if (r == NULL) /* mark as keep alive, otherwise we'll close the connection after the first reply */
return -1; r->keep_alive = 1;
r->out = frame; r->out = frame;
r->out_sz = frame_sz; r->out_sz = frame_sz;

Loading…
Cancel
Save