fixed adding file problem
[c11concurrency-benchmarks.git] / gdax-orderbook-hpp / demo / dependencies / websocketpp-0.7.0 / websocketpp / config / minimal_server.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 WEBSOCKETPP_CONFIG_MINIMAL_HPP
29 #define WEBSOCKETPP_CONFIG_MINIMAL_HPP
30
31 // Non-Policy common stuff
32 #include <websocketpp/common/platforms.hpp>
33 #include <websocketpp/common/cpp11.hpp>
34 #include <websocketpp/common/stdint.hpp>
35
36 // Concurrency
37 #include <websocketpp/concurrency/none.hpp>
38
39 // Transport
40 #include <websocketpp/transport/stub/endpoint.hpp>
41
42 // HTTP
43 #include <websocketpp/http/request.hpp>
44 #include <websocketpp/http/response.hpp>
45
46 // Messages
47 #include <websocketpp/message_buffer/message.hpp>
48 #include <websocketpp/message_buffer/alloc.hpp>
49
50 // Loggers
51 #include <websocketpp/logger/stub.hpp>
52
53 // RNG
54 #include <websocketpp/random/none.hpp>
55
56 // User stub base classes
57 #include <websocketpp/endpoint_base.hpp>
58 #include <websocketpp/connection_base.hpp>
59
60 // Extensions
61 #include <websocketpp/extensions/permessage_deflate/disabled.hpp>
62
63 namespace websocketpp {
64 namespace config {
65
66 /// Server config with minimal dependencies
67 /**
68  * This config strips out as many dependencies as possible. It is suitable for
69  * use as a base class for custom configs that want to implement or choose their
70  * own policies for components that even the core config includes.
71  *
72  * NOTE: this config stubs out enough that it cannot be used directly. You must
73  * supply at least a transport policy for a config based on `minimal_server` to
74  * do anything useful.
75  *
76  * Present dependency list for minimal_server config:
77  *
78  * C++98 STL:
79  * <algorithm>
80  * <map>
81  * <sstream>
82  * <string>
83  * <vector>
84  *
85  * C++11 STL or Boost
86  * <memory>
87  * <functional>
88  * <system_error>
89  *
90  * Operating System:
91  * <stdint.h> or <boost/cstdint.hpp>
92  * <netinet/in.h> or <winsock2.h> (for ntohl.. could potentially bundle this)
93  *
94  * @since 0.4.0-dev
95  */
96 struct minimal_server {
97     typedef minimal_server type;
98
99     // Concurrency policy
100     typedef websocketpp::concurrency::none concurrency_type;
101
102     // HTTP Parser Policies
103     typedef http::parser::request request_type;
104     typedef http::parser::response response_type;
105
106     // Message Policies
107     typedef message_buffer::message<message_buffer::alloc::con_msg_manager>
108         message_type;
109     typedef message_buffer::alloc::con_msg_manager<message_type>
110         con_msg_manager_type;
111     typedef message_buffer::alloc::endpoint_msg_manager<con_msg_manager_type>
112         endpoint_msg_manager_type;
113
114     /// Logging policies
115     typedef websocketpp::log::stub elog_type;
116     typedef websocketpp::log::stub alog_type;
117
118     /// RNG policies
119     typedef websocketpp::random::none::int_generator<uint32_t> rng_type;
120
121     /// Controls compile time enabling/disabling of thread syncronization
122     /// code Disabling can provide a minor performance improvement to single
123     /// threaded applications
124     static bool const enable_multithreading = true;
125
126     struct transport_config {
127         typedef type::concurrency_type concurrency_type;
128         typedef type::elog_type elog_type;
129         typedef type::alog_type alog_type;
130         typedef type::request_type request_type;
131         typedef type::response_type response_type;
132
133         /// Controls compile time enabling/disabling of thread syncronization
134         /// code Disabling can provide a minor performance improvement to single
135         /// threaded applications
136         static bool const enable_multithreading = true;
137
138         /// Default timer values (in ms)
139
140         /// Length of time to wait for socket pre-initialization
141         /**
142          * Exactly what this includes depends on the socket policy in use
143          */
144         static const long timeout_socket_pre_init = 5000;
145
146         /// Length of time to wait before a proxy handshake is aborted
147         static const long timeout_proxy = 5000;
148
149         /// Length of time to wait for socket post-initialization
150         /**
151          * Exactly what this includes depends on the socket policy in use.
152          * Often this means the TLS handshake
153          */
154         static const long timeout_socket_post_init = 5000;
155
156         /// Length of time to wait for dns resolution
157         static const long timeout_dns_resolve = 5000;
158
159         /// Length of time to wait for TCP connect
160         static const long timeout_connect = 5000;
161
162         /// Length of time to wait for socket shutdown
163         static const long timeout_socket_shutdown = 5000;
164     };
165
166     /// Transport Endpoint Component
167     typedef websocketpp::transport::stub::endpoint<transport_config>
168         transport_type;
169
170     /// User overridable Endpoint base class
171     typedef websocketpp::endpoint_base endpoint_base;
172     /// User overridable Connection base class
173     typedef websocketpp::connection_base connection_base;
174
175     /// Default timer values (in ms)
176
177     /// Length of time before an opening handshake is aborted
178     static const long timeout_open_handshake = 5000;
179     /// Length of time before a closing handshake is aborted
180     static const long timeout_close_handshake = 5000;
181     /// Length of time to wait for a pong after a ping
182     static const long timeout_pong = 5000;
183
184     /// WebSocket Protocol version to use as a client
185     /**
186      * What version of the WebSocket Protocol to use for outgoing client
187      * connections. Setting this to a value other than 13 (RFC6455) is not
188      * recommended.
189      */
190     static const int client_version = 13; // RFC6455
191
192     /// Default static error logging channels
193     /**
194      * Which error logging channels to enable at compile time. Channels not
195      * enabled here will be unable to be selected by programs using the library.
196      * This option gives an optimizing compiler the ability to remove entirely
197      * code to test whether or not to print out log messages on a certain
198      * channel
199      *
200      * Default is all except for development/debug level errors
201      */
202     static const websocketpp::log::level elog_level =
203         websocketpp::log::elevel::none;
204
205     /// Default static access logging channels
206     /**
207      * Which access logging channels to enable at compile time. Channels not
208      * enabled here will be unable to be selected by programs using the library.
209      * This option gives an optimizing compiler the ability to remove entirely
210      * code to test whether or not to print out log messages on a certain
211      * channel
212      *
213      * Default is all except for development/debug level access messages
214      */
215     static const websocketpp::log::level alog_level =
216         websocketpp::log::alevel::none;
217
218     ///
219     static const size_t connection_read_buffer_size = 16384;
220
221     /// Drop connections immediately on protocol error.
222     /**
223      * Drop connections on protocol error rather than sending a close frame.
224      * Off by default. This may result in legit messages near the error being
225      * dropped as well. It may free up resources otherwise spent dealing with
226      * misbehaving clients.
227      */
228     static const bool drop_on_protocol_error = false;
229
230     /// Suppresses the return of detailed connection close information
231     /**
232      * Silence close suppresses the return of detailed connection close
233      * information during the closing handshake. This information is useful
234      * for debugging and presenting useful errors to end users but may be
235      * undesirable for security reasons in some production environments.
236      * Close reasons could be used by an attacker to confirm that the endpoint
237      * is out of resources or be used to identify the WebSocket implementation
238      * in use.
239      *
240      * Note: this will suppress *all* close codes, including those explicitly
241      * sent by local applications.
242      */
243     static const bool silent_close = false;
244
245     /// Default maximum message size
246     /**
247      * Default value for the processor's maximum message size. Maximum message size
248      * determines the point at which the library will fail a connection with the 
249      * message_too_big protocol error.
250      *
251      * The default is 32MB
252      *
253      * @since 0.4.0-alpha1
254      */
255     static const size_t max_message_size = 32000000;
256
257     /// Default maximum http body size
258     /**
259      * Default value for the http parser's maximum body size. Maximum body size
260      * determines the point at which the library will abort reading an HTTP
261      * connection with the 413/request entity too large error.
262      *
263      * The default is 32MB
264      *
265      * @since 0.5.0
266      */
267     static const size_t max_http_body_size = 32000000;
268
269     /// Global flag for enabling/disabling extensions
270     static const bool enable_extensions = true;
271
272     /// Extension specific settings:
273
274     /// permessage_compress extension
275     struct permessage_deflate_config {
276         typedef core::request_type request_type;
277
278         /// If the remote endpoint requests that we reset the compression
279         /// context after each message should we honor the request?
280         static const bool allow_disabling_context_takeover = true;
281
282         /// If the remote endpoint requests that we reduce the size of the
283         /// LZ77 sliding window size this is the lowest value that will be
284         /// allowed. Values range from 8 to 15. A value of 8 means we will
285         /// allow any possible window size. A value of 15 means do not allow
286         /// negotiation of the window size (ie require the default).
287         static const uint8_t minimum_outgoing_window_bits = 8;
288     };
289
290     typedef websocketpp::extensions::permessage_deflate::disabled
291         <permessage_deflate_config> permessage_deflate_type;
292
293     /// Autonegotiate permessage-deflate
294     /**
295      * Automatically enables the permessage-deflate extension.
296      *
297      * For clients this results in a permessage-deflate extension request being
298      * sent with every request rather than requiring it to be requested manually
299      *
300      * For servers this results in accepting the first set of extension settings
301      * requested by the client that we understand being used. The alternative is
302      * requiring the extension to be manually negotiated in `validate`. With
303      * auto-negotiate on, you may still override the auto-negotiate manually if
304      * needed.
305      */
306     //static const bool autonegotiate_compression = false;
307 };
308
309 } // namespace config
310 } // namespace websocketpp
311
312 #endif // WEBSOCKETPP_CONFIG_MINIMAL_HPP