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

Side by Side Diff: net/websockets/websocket_extension_parser.h

Issue 23872029: Implement WebSocketExtensionParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
7
8 #include <string>
9 #include <vector>
tyoshino (SeeGerritForStatus) 2013/09/19 03:53:43 not used?
yhirano 2013/09/19 04:16:19 Done.
10
11 #include "base/strings/string_piece.h"
12 #include "net/base/net_export.h"
13 #include "net/websockets/websocket_extension.h"
14
15 namespace net {
16
17 class NET_EXPORT_PRIVATE WebSocketExtensionParser {
18 public:
19 WebSocketExtensionParser();
20 ~WebSocketExtensionParser();
21
22 // Parses the given string as a WebSocket extension header value.
23 // This parser assumes some preprocesses are made.
24 // - The parser parses single extension at a time. This means that
25 // the parser parses |extension| in RFC6455 9.1, not |extension-list|.
26 // - There is no newline characters in the input. LWS-concatenation must
27 // have already been done.
28 void Parse(const char* data, size_t size);
29 void Parse(const std::string& data) {
30 Parse(data.data(), data.size());
31 }
32
33 bool has_error() const { return has_error_; }
34 const WebSocketExtension& extension() const { return extension_; }
35
36 private:
37 void Consume(char c);
38 void ConsumeExtension(WebSocketExtension* extension);
39 void ConsumeExtensionParameter(WebSocketExtension::Parameter* parameter);
40 void ConsumeToken(base::StringPiece* token);
41 void ConsumeQuotedToken(std::string* token);
42 void ConsumeSpaces();
43 bool Lookahead(char c);
44 bool ConsumeIfMatch(char c);
45 size_t UnconsumedBytes() const { return end_ - current_; }
46
47 static bool IsControl(char c);
48 static bool IsSeparator(char c);
49
50 const char* current_;
51 const char* end_;
52 bool has_error_;
53 WebSocketExtension extension_;
54
55 DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);
56 };
57
58 } // namespace net
59
60 #endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698