Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ws-parser to latest version. #2054

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Sming/Components/.patches/ws_parser.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/ws_parser.c b/ws_parser.c
index 88e4810..e2d1147 100644
index d43adbe..beeb611 100644
--- a/ws_parser.c
+++ b/ws_parser.c
@@ -3,6 +3,7 @@
Expand All @@ -12,13 +12,13 @@ index 88e4810..e2d1147 100644
S_OPCODE = 0,
@@ -27,6 +28,7 @@ enum {
void
ws_parser_init(ws_parser_t* parser, const ws_parser_callbacks_t* callbacks)
ws_parser_init(ws_parser_t* parser)
{
+ memset(parser, 0, sizeof(ws_parser_t));
parser->user_data = NULL;
parser->callbacks = callbacks;
+ memset(parser, 0, sizeof(ws_parser_t));
parser->state = S_OPCODE;
@@ -244,7 +246,8 @@ ws_parser_execute(ws_parser_t* parser, /* mutates! */ char* buff, size_t len)
parser->fragment = 0;
}
@@ -247,7 +249,8 @@ ws_parser_execute(
}

if(parser->mask_flag) {
Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/ws_parser
8 changes: 3 additions & 5 deletions Sming/Core/Network/Http/Websocket/WebsocketConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ WebsocketConnection::WebsocketConnection(HttpConnection* connection, bool isClie
{
setConnection(connection, isClientConnection);

ws_parser_init(&parser, &parserSettings);
parser.user_data = this;
ws_parser_init(&parser);
}

bool WebsocketConnection::bind(HttpRequest& request, HttpResponse& response)
Expand Down Expand Up @@ -98,7 +97,7 @@ void WebsocketConnection::activate()

bool WebsocketConnection::processFrame(TcpClient& client, char* at, int size)
{
int rc = ws_parser_execute(&parser, at, size);
int rc = ws_parser_execute(&parser, &parserSettings, this, at, size);
if(rc != WS_OK) {
debug_e("WebsocketResource error: %d %s\n", rc, ws_parser_error(rc));
return false;
Expand Down Expand Up @@ -280,8 +279,7 @@ void WebsocketConnection::close()

void WebsocketConnection::reset()
{
ws_parser_init(&parser, &parserSettings);
parser.user_data = this;
ws_parser_init(&parser);

activated = false;
}