mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
use part of service buffer to make response not malloc
Done with an offset because the encoded key is stored at the start of service_buffer at this time Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
895d56d4ce
commit
60fbc63513
1 changed files with 1 additions and 10 deletions
|
@ -83,15 +83,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* make a buffer big enough for everything */
|
||||
|
||||
response = (char *)malloc(256 +
|
||||
wsi->u.hdr.hdrs[WSI_TOKEN_UPGRADE].token_len +
|
||||
wsi->u.hdr.hdrs[WSI_TOKEN_CONNECTION].token_len +
|
||||
wsi->u.hdr.hdrs[WSI_TOKEN_PROTOCOL].token_len);
|
||||
if (!response) {
|
||||
lwsl_err("Out of memory for response buffer\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
response = (char *)context->service_buffer + MAX_WEBSOCKET_04_KEY_LEN;
|
||||
p = response;
|
||||
LWS_CPYAPP(p, "HTTP/1.1 101 Switching Protocols\x0d\x0a"
|
||||
"Upgrade: WebSocket\x0d\x0a"
|
||||
|
@ -251,7 +243,6 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
|
|||
|
||||
/* alright clean up and set ourselves into established state */
|
||||
|
||||
free(response);
|
||||
wsi->state = WSI_STATE_ESTABLISHED;
|
||||
wsi->lws_rx_parse_state = LWS_RXPS_NEW;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue