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

Unified Diff: net/websockets/websocket_extension_parser.h

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_basic_handshake_stream.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_extension_parser.h
diff --git a/net/websockets/websocket_extension_parser.h b/net/websockets/websocket_extension_parser.h
index ef7fe0366575c696f039008d4989246f6b5b43a2..6b2e4dc629873b50348d221283fe49d2afca5cc8 100644
--- a/net/websockets/websocket_extension_parser.h
+++ b/net/websockets/websocket_extension_parser.h
@@ -6,6 +6,7 @@
#define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
#include <string>
+#include <vector>
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
@@ -18,21 +19,24 @@ class NET_EXPORT_PRIVATE WebSocketExtensionParser {
WebSocketExtensionParser();
~WebSocketExtensionParser();
- // Parses the given string as a WebSocket extension header value.
- // This parser assumes some preprocesses are made.
- // - The parser parses single extension at a time. This means that
- // the parser parses |extension| in RFC6455 9.1, not |extension-list|.
- // - There is no newline characters in the input. LWS-concatenation must
- // have already been done.
+ // Parses the given string as a Sec-WebSocket-Extensions header value.
+ //
+ // There must be no newline characters in the input. LWS-concatenation must
+ // have already been done before calling this method.
void Parse(const char* data, size_t size);
void Parse(const std::string& data) {
Parse(data.data(), data.size());
}
+ // Returns true if the last Parse() method call encountered any syntax error.
bool has_error() const { return has_error_; }
- const WebSocketExtension& extension() const { return extension_; }
+ // Returns the result of the last Parse() method call.
+ const std::vector<WebSocketExtension>& extensions() const {
+ return extensions_;
+ }
private:
+ // TODO(tyoshino): Make the following methods return success/fail.
void Consume(char c);
void ConsumeExtension(WebSocketExtension* extension);
void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
@@ -46,10 +50,12 @@ class NET_EXPORT_PRIVATE WebSocketExtensionParser {
static bool IsControl(char c);
static bool IsSeparator(char c);
+ // The current position in the input string.
const char* current_;
+ // The pointer of the end of the input string.
const char* end_;
bool has_error_;
- WebSocketExtension extension_;
+ std::vector<WebSocketExtension> extensions_;
DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);
};
« no previous file with comments | « net/websockets/websocket_basic_handshake_stream.cc ('k') | net/websockets/websocket_extension_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698