WebSocket++ 0.8.2
C++ websocket client/server library
Loading...
Searching...
No Matches
parser.hpp
1/*
2 * Copyright (c) 2014, Peter Thorson. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the WebSocket++ Project nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28#ifndef HTTP_PARSER_HPP
29#define HTTP_PARSER_HPP
30
31#include <algorithm>
32#include <map>
33#include <string>
34#include <utility>
35
36#include <websocketpp/utilities.hpp>
37#include <websocketpp/http/constants.hpp>
38
39namespace websocketpp {
40namespace http {
41namespace parser {
42
43namespace state {
44 enum value {
45 method,
46 resource,
47 version,
48 headers
49 };
50}
51
52namespace body_encoding {
53 enum value {
54 unknown,
55 plain,
56 chunked
57 };
58}
59
60typedef std::map<std::string, std::string, utility::ci_less > header_list;
61
62/// Read and return the next token in the stream
63/**
64 * Read until a non-token character is found and then return the token and
65 * iterator to the next character to read
66 *
67 * @param begin An iterator to the beginning of the sequence
68 * @param end An iterator to the end of the sequence
69 * @return A pair containing the token and an iterator to the next character in
70 * the stream
71 */
72template <typename InputIterator>
73std::pair<std::string,InputIterator> extract_token(InputIterator begin,
74 InputIterator end)
75{
76 InputIterator it = std::find_if(begin,end,&is_not_token_char);
77 return std::make_pair(std::string(begin,it),it);
78}
79
80/// Read and return the next quoted string in the stream
81/**
82 * Read a double quoted string starting at `begin`. The quotes themselves are
83 * stripped. The quoted value is returned along with an iterator to the next
84 * character to read
85 *
86 * @param begin An iterator to the beginning of the sequence
87 * @param end An iterator to the end of the sequence
88 * @return A pair containing the string read and an iterator to the next
89 * character in the stream
90 */
91template <typename InputIterator>
92std::pair<std::string,InputIterator> extract_quoted_string(InputIterator begin,
93 InputIterator end)
94{
95 std::string s;
96
97 if (end == begin) {
98 return std::make_pair(s,begin);
99 }
100
101 if (*begin != '"') {
102 return std::make_pair(s,begin);
103 }
104
105 InputIterator cursor = begin+1;
106 InputIterator marker = cursor;
107
108 cursor = std::find(cursor,end,'"');
109
110 while (cursor != end) {
111 // either this is the end or a quoted string
112 if (*(cursor-1) == '\\') {
113 s.append(marker,cursor-1);
114 s.append(1,'"');
115 ++cursor;
116 marker = cursor;
117 } else {
118 s.append(marker,cursor);
119 ++cursor;
120 return std::make_pair(s,cursor);
121 }
122
123 cursor = std::find(cursor,end,'"');
124 }
125
126 return std::make_pair("",begin);
127}
128
129/// Read and discard one unit of linear whitespace
130/**
131 * Read one unit of linear white space and return the iterator to the character
132 * afterwards. If `begin` is returned, no whitespace was extracted.
133 *
134 * @param begin An iterator to the beginning of the sequence
135 * @param end An iterator to the end of the sequence
136 * @return An iterator to the character after the linear whitespace read
137 */
138template <typename InputIterator>
139InputIterator extract_lws(InputIterator begin, InputIterator end) {
140 InputIterator it = begin;
141
142 // strip leading CRLF
143 if (end-begin > 2 && *begin == '\r' && *(begin+1) == '\n' &&
144 is_whitespace_char(static_cast<unsigned char>(*(begin+2))))
145 {
146 it+=3;
147 }
148
149 it = std::find_if(it,end,&is_not_whitespace_char);
150 return it;
151}
152
153/// Read and discard linear whitespace
154/**
155 * Read linear white space until a non-lws character is read and return an
156 * iterator to that character. If `begin` is returned, no whitespace was
157 * extracted.
158 *
159 * @param begin An iterator to the beginning of the sequence
160 * @param end An iterator to the end of the sequence
161 * @return An iterator to the character after the linear whitespace read
162 */
163template <typename InputIterator>
164InputIterator extract_all_lws(InputIterator begin, InputIterator end) {
165 InputIterator old_it;
166 InputIterator new_it = begin;
167
168 do {
169 // Pull value from previous iteration
170 old_it = new_it;
171
172 // look ahead another pass
173 new_it = extract_lws(old_it,end);
174 } while (new_it != end && old_it != new_it);
175
176 return new_it;
177}
178
179/// Extract HTTP attributes
180/**
181 * An http attributes list is a semicolon delimited list of key value pairs in
182 * the format: *( ";" attribute "=" value ) where attribute is a token and value
183 * is a token or quoted string.
184 *
185 * Attributes extracted are appended to the supplied attributes list
186 * `attributes`.
187 *
188 * @param [in] begin An iterator to the beginning of the sequence
189 * @param [in] end An iterator to the end of the sequence
190 * @param [out] attributes A reference to the attributes list to append
191 * attribute/value pairs extracted to
192 * @return An iterator to the character after the last atribute read
193 */
194template <typename InputIterator>
195InputIterator extract_attributes(InputIterator begin, InputIterator end,
196 attribute_list & attributes)
197{
198 InputIterator cursor;
199 bool first = true;
200
201 if (begin == end) {
202 return begin;
203 }
204
205 cursor = begin;
206 std::pair<std::string,InputIterator> ret;
207
208 while (cursor != end) {
209 std::string name;
210
211 cursor = http::parser::extract_all_lws(cursor,end);
212 if (cursor == end) {
213 break;
214 }
215
216 if (first) {
217 // ignore this check for the very first pass
218 first = false;
219 } else {
220 if (*cursor == ';') {
221 // advance past the ';'
222 ++cursor;
223 } else {
224 // non-semicolon in this position indicates end end of the
225 // attribute list, break and return.
226 break;
227 }
228 }
229
230 cursor = http::parser::extract_all_lws(cursor,end);
231 ret = http::parser::extract_token(cursor,end);
232
233 if (ret.first.empty()) {
234 // error: expected a token
235 return begin;
236 } else {
237 name = ret.first;
238 cursor = ret.second;
239 }
240
241 cursor = http::parser::extract_all_lws(cursor,end);
242 if (cursor == end || *cursor != '=') {
243 // if there is an equals sign, read the attribute value. Otherwise
244 // record a blank value and continue
245 attributes[name].clear();
246 continue;
247 }
248
249 // advance past the '='
250 ++cursor;
251
252 cursor = http::parser::extract_all_lws(cursor,end);
253 if (cursor == end) {
254 // error: expected a token or quoted string
255 return begin;
256 }
257
258 ret = http::parser::extract_quoted_string(cursor,end);
259 if (ret.second != cursor) {
260 attributes[name] = ret.first;
261 cursor = ret.second;
262 continue;
263 }
264
265 ret = http::parser::extract_token(cursor,end);
266 if (ret.first.empty()) {
267 // error : expected token or quoted string
268 return begin;
269 } else {
270 attributes[name] = ret.first;
271 cursor = ret.second;
272 }
273 }
274
275 return cursor;
276}
277
278/// Extract HTTP parameters
279/**
280 * An http parameters list is a comma delimited list of tokens followed by
281 * optional semicolon delimited attributes lists.
282 *
283 * Parameters extracted are appended to the supplied parameters list
284 * `parameters`.
285 *
286 * @param [in] begin An iterator to the beginning of the sequence
287 * @param [in] end An iterator to the end of the sequence
288 * @param [out] parameters A reference to the parameters list to append
289 * paramter values extracted to
290 * @return An iterator to the character after the last parameter read
291 */
292template <typename InputIterator>
293InputIterator extract_parameters(InputIterator begin, InputIterator end,
294 parameter_list &parameters)
295{
296 InputIterator cursor;
297
298 if (begin == end) {
299 // error: expected non-zero length range
300 return begin;
301 }
302
303 cursor = begin;
304 std::pair<std::string,InputIterator> ret;
305
306 /**
307 * LWS
308 * token
309 * LWS
310 * *(";" method-param)
311 * LWS
312 * ,=loop again
313 */
314 while (cursor != end) {
315 std::string parameter_name;
316 attribute_list attributes;
317
318 // extract any stray whitespace
319 cursor = http::parser::extract_all_lws(cursor,end);
320 if (cursor == end) {break;}
321
322 ret = http::parser::extract_token(cursor,end);
323
324 if (ret.first.empty()) {
325 // error: expected a token
326 return begin;
327 } else {
328 parameter_name = ret.first;
329 cursor = ret.second;
330 }
331
332 // Safe break point, insert parameter with blank attributes and exit
333 cursor = http::parser::extract_all_lws(cursor,end);
334 if (cursor == end) {
335 //parameters[parameter_name] = attributes;
336 parameters.push_back(std::make_pair(parameter_name,attributes));
337 break;
338 }
339
340 // If there is an attribute list, read it in
341 if (*cursor == ';') {
342 InputIterator acursor;
343
344 ++cursor;
345 acursor = http::parser::extract_attributes(cursor,end,attributes);
346
347 if (acursor == cursor) {
348 // attribute extraction ended in syntax error
349 return begin;
350 }
351
352 cursor = acursor;
353 }
354
355 // insert parameter into output list
356 //parameters[parameter_name] = attributes;
357 parameters.push_back(std::make_pair(parameter_name,attributes));
358
359 cursor = http::parser::extract_all_lws(cursor,end);
360 if (cursor == end) {break;}
361
362 // if next char is ',' then read another parameter, else stop
363 if (*cursor != ',') {
364 break;
365 }
366
367 // advance past comma
368 ++cursor;
369
370 if (cursor == end) {
371 // expected more bytes after a comma
372 return begin;
373 }
374 }
375
376 return cursor;
377}
378
379inline std::string strip_lws(std::string const & input) {
380 std::string::const_iterator begin = extract_all_lws(input.begin(),input.end());
381 if (begin == input.end()) {
382 return std::string();
383 }
384
385 std::string::const_reverse_iterator rbegin = extract_all_lws(input.rbegin(),input.rend());
386 if (rbegin == input.rend()) {
387 return std::string();
388 }
389
390 return std::string(begin,rbegin.base());
391}
392
393/// Base HTTP parser
394/**
395 * Includes methods and data elements common to all types of HTTP messages such
396 * as headers, versions, bodies, etc.
397 */
398class parser {
399public:
400 parser()
401 : m_header_bytes(0)
402 , m_body_bytes_needed(0)
403 , m_body_bytes_max(max_body_size)
404 , m_body_encoding(body_encoding::unknown) {}
405
406 /// Get the HTTP version string
407 /**
408 * @return The version string for this parser
409 */
410 std::string const & get_version() const {
411 return m_version;
412 }
413
414 /// Set HTTP parser Version
415 /**
416 * Input should be in format: HTTP/x.y where x and y are positive integers.
417 * @todo Does this method need any validation?
418 *
419 * @param [in] version The value to set the HTTP version to.
420 */
421 void set_version(std::string const & version);
422
423 /// Get the value of an HTTP header
424 /**
425 * @todo Make this method case insensitive.
426 *
427 * @param [in] key The name/key of the header to get.
428 * @return The value associated with the given HTTP header key.
429 */
430 std::string const & get_header(std::string const & key) const;
431
432 /// Extract an HTTP parameter list from a parser header.
433 /**
434 * If the header requested doesn't exist or exists and is empty the
435 * parameter list is valid (but empty).
436 *
437 * @param [in] key The name/key of the HTTP header to use as input.
438 * @param [out] out The parameter list to store extracted parameters in.
439 * @return Whether or not the input was a valid parameter list.
440 */
441 bool get_header_as_plist(std::string const & key, parameter_list & out)
442 const;
443
444 /// Return a list of all HTTP headers
445 /**
446 * Return a list of all HTTP headers
447 *
448 * @since 0.8.0
449 *
450 * @return A list of all HTTP headers
451 */
452 header_list const & get_headers() const;
453
454 /// Append a value to an existing HTTP header
455 /**
456 * This method will set the value of the HTTP header `key` with the
457 * indicated value. If a header with the name `key` already exists, `val`
458 * will be appended to the existing value.
459 *
460 * @todo Make this method case insensitive.
461 * @todo Should there be any restrictions on which keys are allowed?
462 * @todo Exception free varient
463 *
464 * @see replace_header
465 *
466 * @param [in] key The name/key of the header to append to.
467 * @param [in] val The value to append.
468 */
469 void append_header(std::string const & key, std::string const & val);
470
471 /// Set a value for an HTTP header, replacing an existing value
472 /**
473 * This method will set the value of the HTTP header `key` with the
474 * indicated value. If a header with the name `key` already exists, `val`
475 * will replace the existing value.
476 *
477 * @todo Make this method case insensitive.
478 * @todo Should there be any restrictions on which keys are allowed?
479 * @todo Exception free varient
480 *
481 * @see append_header
482 *
483 * @param [in] key The name/key of the header to append to.
484 * @param [in] val The value to append.
485 */
486 void replace_header(std::string const & key, std::string const & val);
487
488 /// Remove a header from the parser
489 /**
490 * Removes the header entirely from the parser. This is different than
491 * setting the value of the header to blank.
492 *
493 * @todo Make this method case insensitive.
494 *
495 * @param [in] key The name/key of the header to remove.
496 */
497 void remove_header(std::string const & key);
498
499 /// Get HTTP body
500 /**
501 * Gets the body of the HTTP object
502 *
503 * @return The body of the HTTP message.
504 */
505 std::string const & get_body() const {
506 return m_body;
507 }
508
509 /// Set body content
510 /**
511 * Set the body content of the HTTP response to the parameter string. Note
512 * set_body will also set the Content-Length HTTP header to the appropriate
513 * value. If you want the Content-Length header to be something else, do so
514 * via replace_header("Content-Length") after calling set_body()
515 *
516 * @param value String data to include as the body content.
517 */
518 void set_body(std::string const & value);
519
520 /// Get body size limit
521 /**
522 * Retrieves the maximum number of bytes to parse & buffer before canceling
523 * a request.
524 *
525 * @since 0.5.0
526 *
527 * @return The maximum length of a message body.
528 */
529 size_t get_max_body_size() const {
530 return m_body_bytes_max;
531 }
532
533 /// Set body size limit
534 /**
535 * Set the maximum number of bytes to parse and buffer before canceling a
536 * request.
537 *
538 * @since 0.5.0
539 *
540 * @param value The size to set the max body length to.
541 */
542 void set_max_body_size(size_t value) {
543 m_body_bytes_max = value;
544 }
545
546 /// Extract an HTTP parameter list from a string.
547 /**
548 * @param [in] in The input string.
549 * @param [out] out The parameter list to store extracted parameters in.
550 * @return Whether or not the input was a valid parameter list.
551 */
552 bool parse_parameter_list(std::string const & in, parameter_list & out)
553 const;
554protected:
555 /// Process a header line
556 /**
557 * @todo Update this method to be exception free.
558 *
559 * @param [in] begin An iterator to the beginning of the sequence.
560 * @param [in] end An iterator to the end of the sequence.
561 */
562 void process_header(std::string::iterator begin, std::string::iterator end);
563
564 /// Prepare the parser to begin parsing body data
565 /**
566 * Inspects headers to determine if the message has a body that needs to be
567 * read. If so, sets up the necessary state, otherwise returns false. If
568 * this method returns true and loading the message body is desired call
569 * `process_body` until it returns zero bytes or an error.
570 *
571 * Must not be called until after all headers have been processed.
572 *
573 * @since 0.5.0
574 *
575 * @return True if more bytes are needed to load the body, false otherwise.
576 */
577 bool prepare_body();
578
579 /// Process body data
580 /**
581 * Parses body data.
582 *
583 * @since 0.5.0
584 *
585 * @param [in] begin An iterator to the beginning of the sequence.
586 * @param [in] end An iterator to the end of the sequence.
587 * @return The number of bytes processed
588 */
589 size_t process_body(char const * buf, size_t len);
590
591 /// Check if the parser is done parsing the body
592 /**
593 * Behavior before a call to `prepare_body` is undefined.
594 *
595 * @since 0.5.0
596 *
597 * @return True if the message body has been completed loaded.
598 */
599 bool body_ready() const {
600 return (m_body_bytes_needed == 0);
601 }
602
603 /// Generate and return the HTTP headers as a string
604 /**
605 * Each headers will be followed by the \r\n sequence including the last one.
606 * A second \r\n sequence (blank header) is not appended by this method
607 *
608 * @return The HTTP headers as a string.
609 */
610 std::string raw_headers() const;
611
612 std::string m_version;
613 header_list m_headers;
614
615 size_t m_header_bytes;
616
617 std::string m_body;
618 size_t m_body_bytes_needed;
619 size_t m_body_bytes_max;
620 body_encoding::value m_body_encoding;
621};
622
623} // namespace parser
624} // namespace http
625} // namespace websocketpp
626
627#include <websocketpp/http/impl/parser.hpp>
628
629#endif // HTTP_PARSER_HPP
#define _WEBSOCKETPP_CPP11_FUNCTIONAL_
#define _WEBSOCKETPP_CPP11_THREAD_
#define _WEBSOCKETPP_CPP11_MEMORY_
#define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_
Concurrency policy that uses std::mutex / boost::mutex.
Definition basic.hpp:37
Stub for user supplied base class.
Stub for user supplied base class.
Stub class for use when disabling permessage_deflate extension.
Definition disabled.hpp:53
header_list const & get_headers() const
Return a list of all HTTP headers.
Definition parser.hpp:179
size_t process_body(char const *buf, size_t len)
Process body data.
Definition parser.hpp:145
std::string const & get_body() const
Get HTTP body.
Definition parser.hpp:505
void process_header(std::string::iterator begin, std::string::iterator end)
Process a header line.
Definition parser.hpp:161
bool body_ready() const
Check if the parser is done parsing the body.
Definition parser.hpp:599
bool prepare_body()
Prepare the parser to begin parsing body data.
Definition parser.hpp:119
void set_max_body_size(size_t value)
Set body size limit.
Definition parser.hpp:542
std::string raw_headers() const
Generate and return the HTTP headers as a string.
Definition parser.hpp:183
std::string const & get_version() const
Get the HTTP version string.
Definition parser.hpp:410
size_t get_max_body_size() const
Get body size limit.
Definition parser.hpp:529
Stores, parses, and manipulates HTTP requests.
Definition request.hpp:50
std::string raw() const
Returns the full raw request (including the body)
Definition request.hpp:131
std::string const & get_uri() const
Return the requested URI.
Definition request.hpp:104
std::string const & get_method() const
Return the request method.
Definition request.hpp:96
size_t consume(char const *buf, size_t len)
Process bytes in the input buffer.
Definition request.hpp:41
bool ready() const
Returns whether or not the request is ready for reading.
Definition request.hpp:82
std::string raw_head() const
Returns the raw request headers only (similar to an HTTP HEAD request)
Definition request.hpp:141
Stores, parses, and manipulates HTTP responses.
Definition response.hpp:57
Basic logger that outputs to an ostream.
Definition basic.hpp:59
Thread safe stub "random" integer generator.
Definition none.hpp:46
Server endpoint role based on the given config.
Basic ASIO endpoint socket component.
Definition none.hpp:317
Asio based endpoint transport component.
Definition endpoint.hpp:54
lib::shared_ptr< type > ptr
Type of a shared pointer to this connection transport component.
connection_hdl get_handle() const
Get the connection handle.
config::alog_type alog_type
Type of this transport's access logging policy.
lib::error_code dispatch(dispatch_handler handler)
Call given handler back within the transport's event system (if present)
void async_shutdown(transport::shutdown_handler handler)
Perform cleanup on socket shutdown_handler.
void set_write_handler(write_handler h)
Sets the write handler.
void set_secure(bool value)
Set whether or not this connection is secure.
void set_shutdown_handler(shutdown_handler h)
Sets the shutdown handler.
connection< config > type
Type of this connection transport component.
config::elog_type elog_type
Type of this transport's error logging policy.
void fatal_error()
Signal transport error.
size_t read_some(char const *buf, size_t len)
Manual input supply (read some)
size_t read_all(char const *buf, size_t len)
Manual input supply (read all)
void async_write(char const *buf, size_t len, transport::write_handler handler)
Asyncronous Transport Write.
size_t readsome(char const *buf, size_t len)
Manual input supply (DEPRECATED)
config::concurrency_type concurrency_type
transport concurrency policy
void init(init_handler handler)
Initialize the connection transport.
timer_ptr set_timer(long, timer_handler)
Call back a function after a period of time.
friend std::istream & operator>>(std::istream &in, type &t)
Overloaded stream input operator.
void set_vector_write_handler(vector_write_handler h)
Sets the vectored write handler.
bool is_secure() const
Tests whether or not the underlying transport is secure.
std::string get_remote_endpoint() const
Get human readable remote endpoint address.
void set_handle(connection_hdl hdl)
Set Connection Handle.
void register_ostream(std::ostream *o)
Register a std::ostream with the transport for writing output.
void async_read_at_least(size_t num_bytes, char *buf, size_t len, read_handler handler)
Initiate an async_read for at least num_bytes bytes into buf.
void async_write(std::vector< buffer > const &bufs, transport::write_handler handler)
Asyncronous Transport Write (scatter-gather)
ptr get_shared()
Get a shared pointer to this component.
iostream::connection< config > transport_con_type
Definition endpoint.hpp:62
config::elog_type elog_type
Type of this endpoint's error logging policy.
Definition endpoint.hpp:56
void set_write_handler(write_handler h)
Sets the write handler.
Definition endpoint.hpp:134
void set_shutdown_handler(shutdown_handler h)
Sets the shutdown handler.
Definition endpoint.hpp:154
bool is_secure() const
Tests whether or not the underlying transport is secure.
Definition endpoint.hpp:116
lib::shared_ptr< type > ptr
Type of a pointer to this endpoint transport component.
Definition endpoint.hpp:51
transport_con_type::ptr transport_con_ptr
Definition endpoint.hpp:65
void async_connect(transport_con_ptr, uri_ptr, connect_handler cb)
Initiate a new connection.
Definition endpoint.hpp:183
lib::error_code init(transport_con_ptr tcon)
Initialize a connection.
Definition endpoint.hpp:197
void init_logging(lib::shared_ptr< alog_type > a, lib::shared_ptr< elog_type > e)
Initialize logging.
Definition endpoint.hpp:171
endpoint type
Type of this endpoint transport component.
Definition endpoint.hpp:49
void register_ostream(std::ostream *o)
Register a default output stream.
Definition endpoint.hpp:80
config::concurrency_type concurrency_type
Type of this endpoint's concurrency policy.
Definition endpoint.hpp:54
void set_secure(bool value)
Set whether or not endpoint can create secure connections.
Definition endpoint.hpp:102
config::alog_type alog_type
Type of this endpoint's access logging policy.
Definition endpoint.hpp:58
iostream transport error category
Definition base.hpp:85
std::string get_query() const
Return the query portion.
Definition uri.hpp:294
#define _WEBSOCKETPP_NOEXCEPT_TOKEN_
Definition cpp11.hpp:113
#define __has_extension
Definition cpp11.hpp:40
#define __has_feature(x)
Definition cpp11.hpp:37
Concurrency handling support.
Definition basic.hpp:34
Library level error codes.
Definition error.hpp:44
@ general
Catch-all library error.
Definition error.hpp:47
@ unrequested_subprotocol
Selected subprotocol was not requested by the client.
Definition error.hpp:102
@ invalid_port
Invalid port in URI.
Definition error.hpp:120
@ client_only
Attempted to use a client specific feature on a server endpoint.
Definition error.hpp:105
@ http_connection_ended
HTTP connection ended.
Definition error.hpp:111
@ operation_canceled
The requested operation was canceled.
Definition error.hpp:127
@ no_outgoing_buffers
The endpoint is out of outgoing message buffers.
Definition error.hpp:68
@ http_parse_error
HTTP parse error.
Definition error.hpp:143
@ reserved_close_code
Close code is in a reserved range.
Definition error.hpp:80
@ con_creation_failed
Connection creation attempted failed.
Definition error.hpp:99
@ no_incoming_buffers
The endpoint is out of incoming message buffers.
Definition error.hpp:71
@ invalid_state
The connection was in the wrong state for this operation.
Definition error.hpp:74
@ extension_neg_failed
Extension negotiation failed.
Definition error.hpp:146
@ rejected
Connection rejected.
Definition error.hpp:130
@ unsupported_version
Unsupported WebSocket protocol version.
Definition error.hpp:140
@ invalid_utf8
Invalid UTF-8.
Definition error.hpp:86
@ invalid_close_code
Close code is invalid.
Definition error.hpp:83
@ server_only
Attempted to use a server specific feature on a client endpoint.
Definition error.hpp:108
@ endpoint_not_secure
Attempted to open a secure connection with an insecure endpoint.
Definition error.hpp:57
@ close_handshake_timeout
WebSocket close handshake timed out.
Definition error.hpp:117
@ invalid_subprotocol
Invalid subprotocol.
Definition error.hpp:89
@ bad_close_code
Unable to parse close code.
Definition error.hpp:77
@ open_handshake_timeout
WebSocket opening handshake timed out.
Definition error.hpp:114
@ invalid_version
Invalid WebSocket protocol version.
Definition error.hpp:137
@ send_queue_full
send attempted when endpoint write queue was full
Definition error.hpp:50
@ test
Unit testing utility error code.
Definition error.hpp:96
@ invalid_uri
An invalid uri was supplied.
Definition error.hpp:65
Implementation of RFC 7692, the permessage-deflate WebSocket extension.
Definition disabled.hpp:44
HTTP handling support.
Definition request.hpp:37
std::vector< std::pair< std::string, attribute_list > > parameter_list
The type of an HTTP parameter list.
Definition constants.hpp:53
bool is_not_token_char(unsigned char c)
Is the character a non-token.
bool is_whitespace_char(unsigned char c)
Is the character whitespace.
bool is_not_whitespace_char(unsigned char c)
Is the character non-whitespace.
std::map< std::string, std::string > attribute_list
The type of an HTTP attribute list.
Definition constants.hpp:45
Stub RNG policy that always returns 0.
Definition none.hpp:35
Random number generation policies.
Transport policy that uses asio.
Definition endpoint.hpp:46
Generic transport related errors.
@ pass_through
underlying transport pass through
@ operation_not_supported
Operation not supported.
@ operation_aborted
Operation aborted.
@ invalid_num_bytes
async_read_at_least call requested more bytes than buffer can store
@ action_after_shutdown
read or write after shutdown
@ tls_short_read
TLS short read.
@ double_read
async_read called while another async_read was in progress
iostream transport errors
Definition base.hpp:64
@ invalid_num_bytes
async_read_at_least call requested more bytes than buffer can store
Definition base.hpp:71
@ double_read
async_read called while another async_read was in progress
Definition base.hpp:74
lib::error_code make_error_code(error::value e)
Get an error code with the given value and the iostream transport category.
Definition base.hpp:118
lib::error_category const & get_category()
Get a reference to a static copy of the iostream transport error category.
Definition base.hpp:112
Transport policy that uses STL iostream for I/O and does not support timers.
Definition endpoint.hpp:43
lib::function< lib::error_code(connection_hdl, std::vector< transport::buffer > const &bufs)> vector_write_handler
Definition base.hpp:57
lib::function< lib::error_code(connection_hdl)> shutdown_handler
Definition base.hpp:61
lib::function< lib::error_code(connection_hdl, char const *, size_t)> write_handler
The type and signature of the callback used by iostream transport to write.
Definition base.hpp:48
Transport policies provide network connectivity and timers.
Definition endpoint.hpp:45
lib::function< void(lib::error_code const &, size_t)> read_handler
The type and signature of the callback passed to the read method.
lib::function< void()> dispatch_handler
The type and signature of the callback passed to the dispatch method.
lib::function< void()> interrupt_handler
The type and signature of the callback passed to the interrupt method.
lib::function< void(lib::error_code const &)> accept_handler
The type and signature of the callback passed to the accept method.
Definition endpoint.hpp:69
lib::function< void(lib::error_code const &)> timer_handler
The type and signature of the callback passed to the read method.
lib::function< void(lib::error_code const &)> connect_handler
The type and signature of the callback passed to the connect method.
Definition endpoint.hpp:72
lib::function< void(lib::error_code const &)> write_handler
The type and signature of the callback passed to the write method.
lib::function< void(lib::error_code const &)> init_handler
The type and signature of the callback passed to the init hook.
lib::function< void(lib::error_code const &)> shutdown_handler
The type and signature of the callback passed to the shutdown method.
Namespace for the WebSocket++ project.
static uint16_t const uri_default_secure_port
Default port for wss://.
Definition uri.hpp:47
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
static uint16_t const uri_default_port
Default port for ws://.
Definition uri.hpp:45
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
Definition uri.hpp:352
std::pair< lib::error_code, std::string > err_str_pair
Combination error code / string type for returning two values.
Definition error.hpp:41
Server config with asio transport and TLS disabled.
static const long timeout_socket_shutdown
Length of time to wait for socket shutdown.
Definition core.hpp:137
static const long timeout_connect
Length of time to wait for TCP connect.
Definition core.hpp:134
static const long timeout_dns_resolve
Length of time to wait for dns resolution.
Definition core.hpp:131
static const long timeout_proxy
Length of time to wait before a proxy handshake is aborted.
Definition core.hpp:121
static const long timeout_socket_pre_init
Default timer values (in ms)
Definition core.hpp:118
static const long timeout_socket_post_init
Length of time to wait for socket post-initialization.
Definition core.hpp:128
Server config with iostream transport.
Definition core.hpp:68
websocketpp::random::none::int_generator< uint32_t > rng_type
RNG policies.
Definition core.hpp:93
static const websocketpp::log::level elog_level
Default static error logging channels.
Definition core.hpp:176
websocketpp::transport::iostream::endpoint< transport_config > transport_type
Transport Endpoint Component.
Definition core.hpp:142
static const size_t max_http_body_size
Default maximum http body size.
Definition core.hpp:252
static const long timeout_open_handshake
Default timer values (in ms)
Definition core.hpp:152
static const size_t max_message_size
Default maximum message size.
Definition core.hpp:240
static const bool drop_on_protocol_error
Drop connections immediately on protocol error.
Definition core.hpp:213
static const long timeout_close_handshake
Length of time before a closing handshake is aborted.
Definition core.hpp:154
static const websocketpp::log::level alog_level
Default static access logging channels.
Definition core.hpp:189
websocketpp::log::basic< concurrency_type, websocketpp::log::elevel > elog_type
Logging policies.
Definition core.hpp:88
static const long timeout_pong
Length of time to wait for a pong after a ping.
Definition core.hpp:156
static const bool silent_close
Suppresses the return of detailed connection close information.
Definition core.hpp:228
static bool const enable_multithreading
Definition core.hpp:98
static const size_t connection_read_buffer_size
Size of the per-connection read buffer.
Definition core.hpp:204
static const bool enable_extensions
Global flag for enabling/disabling extensions.
Definition core.hpp:255
static const int client_version
WebSocket Protocol version to use as a client.
Definition core.hpp:164
Package of log levels for logging access events.
Definition levels.hpp:112
static char const * channel_name(level channel)
Get the textual name of a channel given a channel id.
Definition levels.hpp:164
static level const fail
One line for each failed WebSocket connection with details.
Definition levels.hpp:147
static level const none
Special aggregate value representing "no levels".
Definition levels.hpp:114
static level const debug_handshake
Extra information about opening handshakes.
Definition levels.hpp:137
static level const devel
Development messages (warning: very chatty)
Definition levels.hpp:141
static level const all
Special aggregate value representing "all levels".
Definition levels.hpp:152
static level const debug_close
Extra information about closing handshakes.
Definition levels.hpp:139
static level const frame_payload
One line per frame, includes the full message payload (warning: chatty)
Definition levels.hpp:129
static level const connect
Information about new connections.
Definition levels.hpp:121
static level const app
Special channel for application specific logs. Not used by the library.
Definition levels.hpp:143
static level const frame_header
One line per frame, includes the full frame header.
Definition levels.hpp:127
static level const message_payload
Reserved.
Definition levels.hpp:133
static level const endpoint
Reserved.
Definition levels.hpp:135
static level const message_header
Reserved.
Definition levels.hpp:131
static level const control
One line per control frame.
Definition levels.hpp:125
static level const disconnect
One line for each closed connection. Includes closing codes and reasons.
Definition levels.hpp:123
static level const access_core
Definition levels.hpp:150
static level const http
Access related to HTTP requests.
Definition levels.hpp:145
Package of values for hinting at the nature of a given logger.
Definition levels.hpp:46
static value const none
No information.
Definition levels.hpp:51
static value const access
Access log.
Definition levels.hpp:53
static value const error
Error log.
Definition levels.hpp:55
uint32_t value
Type of a channel type hint value.
Definition levels.hpp:48
Package of log levels for logging errors.
Definition levels.hpp:59
static level const devel
Low level debugging information (warning: very chatty)
Definition levels.hpp:63
static char const * channel_name(level channel)
Get the textual name of a channel given a channel id.
Definition levels.hpp:91
static level const library
Definition levels.hpp:66
static level const info
Definition levels.hpp:69
static level const all
Special aggregate value representing "all levels".
Definition levels.hpp:80
static level const fatal
Definition levels.hpp:78
static level const none
Special aggregate value representing "no levels".
Definition levels.hpp:61
static level const rerror
Definition levels.hpp:75
static level const warn
Definition levels.hpp:72
A simple utility buffer class.
#define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_
#define _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_