add param to let the socket stay open even if not websockt, thanks Anthony
This commit is contained in:
parent
1f26712330
commit
602e82d483
|
@ -312,15 +312,15 @@ int ws_handshake(wsh_t *wsh)
|
|||
|
||||
err:
|
||||
|
||||
snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n"
|
||||
"Sec-WebSocket-Version: 13\r\n\r\n");
|
||||
if (!wsh->stay_open) {
|
||||
|
||||
//printf("ERR:\n%s\n", respond);
|
||||
snprintf(respond, sizeof(respond), "HTTP/1.1 400 Bad Request\r\n"
|
||||
"Sec-WebSocket-Version: 13\r\n\r\n");
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
|
||||
ws_raw_write(wsh, respond, strlen(respond));
|
||||
|
||||
ws_close(wsh, WS_NONE);
|
||||
ws_close(wsh, WS_NONE);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
|
@ -538,7 +538,7 @@ static int establish_logical_layer(wsh_t *wsh)
|
|||
}
|
||||
|
||||
|
||||
int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block)
|
||||
int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block, int stay_open)
|
||||
{
|
||||
memset(wsh, 0, sizeof(*wsh));
|
||||
|
||||
|
@ -546,6 +546,7 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int
|
|||
wsh->block = block;
|
||||
wsh->sanity = 5000;
|
||||
wsh->ssl_ctx = ssl_ctx;
|
||||
wsh->stay_open = stay_open;
|
||||
|
||||
if (!ssl_ctx) {
|
||||
ssl_ctx = ws_globals.ssl_ctx;
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef struct wsh_s {
|
|||
int sanity;
|
||||
int secure_established;
|
||||
int logical_established;
|
||||
int stay_open;
|
||||
int x;
|
||||
void *write_buffer;
|
||||
size_t write_buffer_len;
|
||||
|
@ -101,7 +102,7 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes, int block);
|
|||
ssize_t ws_raw_write(wsh_t *wsh, void *data, size_t bytes);
|
||||
ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data);
|
||||
ssize_t ws_write_frame(wsh_t *wsh, ws_opcode_t oc, void *data, size_t bytes);
|
||||
int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block);
|
||||
int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock, int block, int stay_open);
|
||||
ssize_t ws_close(wsh_t *wsh, int16_t reason);
|
||||
void ws_destroy(wsh_t *wsh);
|
||||
void init_ssl(void);
|
||||
|
|
Loading…
Reference in New Issue