Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: net/websockets/websocket_extension_parser.cc

Issue 1047623002: Support parsing a Sec-WebSocket-Extensions header with multiple elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed #12 Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/websockets/websocket_extension_parser.h ('k') | net/websockets/websocket_extension_parser_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_extension_parser.cc
diff --git a/net/websockets/websocket_extension_parser.cc b/net/websockets/websocket_extension_parser.cc
index 28a2db16f2775e3410a47e35d51ea12792f63682..109d330c3a1ff8e5f2396e3573177c79a03017b9 100644
--- a/net/websockets/websocket_extension_parser.cc
+++ b/net/websockets/websocket_extension_parser.cc
@@ -16,11 +16,26 @@ void WebSocketExtensionParser::Parse(const char* data, size_t size) {
current_ = data;
end_ = data + size;
has_error_ = false;
+ extensions_.clear();
- ConsumeExtension(&extension_);
- if (has_error_) return;
- ConsumeSpaces();
- has_error_ = has_error_ || (current_ != end_);
+ while (true) {
+ WebSocketExtension extension;
+ ConsumeExtension(&extension);
+ if (has_error_)
+ break;
+ extensions_.push_back(extension);
+
+ ConsumeSpaces();
+ DCHECK(!has_error_);
+
+ if (!ConsumeIfMatch(',')) {
+ break;
+ }
+ }
+
+ has_error_ = has_error_ || current_ != end_;
+ if (has_error_)
+ extensions_.clear();
}
void WebSocketExtensionParser::Consume(char c) {
« no previous file with comments | « net/websockets/websocket_extension_parser.h ('k') | net/websockets/websocket_extension_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698