File tree 2 files changed +5
-23
lines changed
2 files changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -508,28 +508,6 @@ void ssl_client::read_loop()
508
508
case SSL_ERROR_NONE:
509
509
/* Data received, add it to the buffer */
510
510
if (r > 0 ) {
511
- const std::string data (server_to_client_buffer, r);
512
- /* Split the data into an array for every line. */
513
- const std::vector<std::string> data_lines = utility::tokenize (data);
514
- /* Get the first line as we always know that's the HTTP response. */
515
- const std::string http_reponse (data_lines[0 ]);
516
-
517
- /* Does the first line begin with a http code? */
518
- if (http_reponse.rfind (" HTTP/1.1" , 0 ) != std::string::npos) {
519
- /* Now let's split the first line by every space, meaning we can check the actual HTTP code. */
520
- const std::vector<std::string> line_split_by_space = utility::tokenize (data_lines[0 ], " " );
521
-
522
- /* We need to make sure there's at least 3 elements in line_split_by_space. */
523
- if (line_split_by_space.size () >= 3 ) {
524
- const int http_code = std::stoi (line_split_by_space[1 ]);
525
-
526
- /* If the http_code isn't 204, 101, or 200, log it. */
527
- if (http_code != 204 && http_code != 101 && http_code != 200 ) {
528
- log (ll_warning, " Received unhandled code: " + http_reponse);
529
- }
530
- }
531
- }
532
-
533
511
buffer.append (server_to_client_buffer, r);
534
512
if (!this ->handle_buffer (buffer)) {
535
513
return ;
Original file line number Diff line number Diff line change @@ -156,7 +156,11 @@ bool websocket_client::handle_buffer(std::string &buffer)
156
156
}
157
157
158
158
state = CONNECTED;
159
- } else {
159
+ } else if (status.size () < 3 ) {
160
+ log (ll_warning, " Malformed HTTP response on websocket" );
161
+ return false ;
162
+ } else if (status[1 ] != " 200" && status[1 ] != " 204" ) {
163
+ log (ll_warning, " Received unhandled code: " + status[1 ]);
160
164
return false ;
161
165
}
162
166
}
You can’t perform that action at this time.
0 commit comments