for (n = 0; n < len; n++)
if (libwebsocket_parse(wsi, *buf++)) {
lwsl_info("libwebsocket_parse failed\n");
- goto bail;
+ goto bail_nuke_ah;
}
if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE)
lwsl_parser("libwebsocket_parse sees parsing complete\n");
+ wsi->mode = LWS_CONNMODE_PRE_WS_SERVING_ACCEPT;
+
/* is this websocket protocol or normal http 1.0? */
if (!lws_hdr_total_length(wsi, WSI_TOKEN_UPGRADE) ||
if (!lws_hdr_total_length(wsi, WSI_TOKEN_GET_URI)) {
lwsl_warn("Missing URI in HTTP request\n");
- /* drop the header info */
- if (wsi->u.hdr.ah)
- free(wsi->u.hdr.ah);
- goto bail;
+ goto bail_nuke_ah;
}
lwsl_info("HTTP request for '%s'\n",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_GET_URI));
- if (libwebsocket_ensure_user_space(wsi)) {
- /* drop the header info */
- if (wsi->u.hdr.ah)
- free(wsi->u.hdr.ah);
- goto bail;
- }
+ if (libwebsocket_ensure_user_space(wsi))
+ goto bail_nuke_ah;
/*
* Hm we still need the headers so the
/* union transition */
memset(&wsi->u, 0, sizeof(wsi->u));
+ wsi->mode = LWS_CONNMODE_HTTP_SERVING;
wsi->state = WSI_STATE_HTTP;
n = 0;
if (wsi->protocol->callback)
} else {
lwsl_err("Req protocol %s not supported\n",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_PROTOCOL));
- goto bail;
+ goto bail_nuke_ah;
}
}
return 0;
+bail_nuke_ah:
+ /* drop the header info */
+ if (wsi->u.hdr.ah)
+ free(wsi->u.hdr.ah);
+
bail:
lwsl_info("closing connection at libwebsocket_read bail:\n");