opal-up 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +66 -51
  3. data/ext/up_ext/App.h +665 -544
  4. data/ext/up_ext/AsyncSocket.h +307 -284
  5. data/ext/up_ext/AsyncSocketData.h +35 -51
  6. data/ext/up_ext/BloomFilter.h +37 -42
  7. data/ext/up_ext/ChunkedEncoding.h +174 -175
  8. data/ext/up_ext/ClientApp.h +20 -23
  9. data/ext/up_ext/HttpContext.h +476 -381
  10. data/ext/up_ext/HttpContextData.h +20 -20
  11. data/ext/up_ext/HttpErrors.h +14 -10
  12. data/ext/up_ext/HttpParser.h +631 -563
  13. data/ext/up_ext/HttpResponse.h +526 -460
  14. data/ext/up_ext/HttpResponseData.h +59 -55
  15. data/ext/up_ext/HttpRouter.h +328 -310
  16. data/ext/up_ext/Loop.h +174 -168
  17. data/ext/up_ext/LoopData.h +60 -67
  18. data/ext/up_ext/MoveOnlyFunction.h +71 -80
  19. data/ext/up_ext/PerMessageDeflate.h +218 -198
  20. data/ext/up_ext/ProxyParser.h +100 -99
  21. data/ext/up_ext/QueryParser.h +91 -84
  22. data/ext/up_ext/TopicTree.h +273 -268
  23. data/ext/up_ext/Utilities.h +25 -25
  24. data/ext/up_ext/WebSocket.h +376 -310
  25. data/ext/up_ext/WebSocketContext.h +487 -372
  26. data/ext/up_ext/WebSocketContextData.h +74 -62
  27. data/ext/up_ext/WebSocketData.h +53 -46
  28. data/ext/up_ext/WebSocketExtensions.h +194 -178
  29. data/ext/up_ext/WebSocketHandshake.h +115 -110
  30. data/ext/up_ext/WebSocketProtocol.h +441 -398
  31. data/ext/up_ext/extconf.rb +1 -1
  32. data/ext/up_ext/libuwebsockets.cpp +1262 -1292
  33. data/ext/up_ext/libuwebsockets.h +337 -201
  34. data/ext/up_ext/up_ext.c +853 -163
  35. data/lib/up/bun/rack_env.rb +1 -13
  36. data/lib/up/bun/server.rb +93 -19
  37. data/lib/up/cli.rb +3 -0
  38. data/lib/up/client.rb +68 -0
  39. data/lib/up/ruby/cluster.rb +62 -0
  40. data/lib/up/ruby/rack_cluster.rb +1 -1
  41. data/lib/up/ruby/rack_server.rb +0 -1
  42. data/lib/up/u_web_socket/cluster.rb +18 -3
  43. data/lib/up/u_web_socket/server.rb +108 -15
  44. data/lib/up/version.rb +1 -1
  45. metadata +4 -15
  46. data/bin/up_node +0 -12
  47. data/bin/up_node_cluster +0 -12
  48. data/lib/up/node/cluster.rb +0 -39
  49. data/lib/up/node/cluster_cli.rb +0 -15
  50. data/lib/up/node/rack_cluster.rb +0 -25
  51. data/lib/up/node/rack_env.rb +0 -106
  52. data/lib/up/node/rack_server.rb +0 -25
  53. data/lib/up/node/server.rb +0 -84
  54. data/lib/up/node/server_cli.rb +0 -15
  55. data/lib/up/ruby/rack_env.rb +0 -97
  56. data/lib/up/u_web_socket/rack_env.rb +0 -101
@@ -8,8 +8,8 @@
8
8
  * copies of the Software, and to permit persons to whom the Software is
9
9
  * furnished to do so, subject to the following conditions:
10
10
  *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
13
  *
14
14
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
15
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -23,235 +23,371 @@
23
23
  #ifndef LIBUWS_CAPI_HEADER
24
24
  #define LIBUWS_CAPI_HEADER
25
25
 
26
- #include <stddef.h>
26
+ #include "libusockets.h"
27
27
  #include <stdbool.h>
28
+ #include <stddef.h>
28
29
  #include <stdint.h>
29
- #include "libusockets.h"
30
30
 
31
31
  #ifdef __cplusplus
32
- extern "C"
33
- {
32
+ extern "C" {
34
33
  #endif
35
34
  #ifdef _WIN32
36
- # define DLL_EXPORT __declspec( dllexport )
35
+ #define DLL_EXPORT __declspec(dllexport)
37
36
  #else
38
- # define DLL_EXPORT
37
+ #define DLL_EXPORT
39
38
  #endif
40
39
 
41
- DLL_EXPORT typedef enum
42
- {
43
- /* These are not actual compression options */
44
- _COMPRESSOR_MASK = 0x00FF,
45
- _DECOMPRESSOR_MASK = 0x0F00,
46
- /* Disabled, shared, shared are "special" values */
47
- DISABLED = 0,
48
- SHARED_COMPRESSOR = 1,
49
- SHARED_DECOMPRESSOR = 1 << 8,
50
- /* Highest 4 bits describe decompressor */
51
- DEDICATED_DECOMPRESSOR_32KB = 15 << 8,
52
- DEDICATED_DECOMPRESSOR_16KB = 14 << 8,
53
- DEDICATED_DECOMPRESSOR_8KB = 13 << 8,
54
- DEDICATED_DECOMPRESSOR_4KB = 12 << 8,
55
- DEDICATED_DECOMPRESSOR_2KB = 11 << 8,
56
- DEDICATED_DECOMPRESSOR_1KB = 10 << 8,
57
- DEDICATED_DECOMPRESSOR_512B = 9 << 8,
58
- /* Same as 32kb */
59
- DEDICATED_DECOMPRESSOR = 15 << 8,
60
-
61
- /* Lowest 8 bit describe compressor */
62
- DEDICATED_COMPRESSOR_3KB = 9 << 4 | 1,
63
- DEDICATED_COMPRESSOR_4KB = 9 << 4 | 2,
64
- DEDICATED_COMPRESSOR_8KB = 10 << 4 | 3,
65
- DEDICATED_COMPRESSOR_16KB = 11 << 4 | 4,
66
- DEDICATED_COMPRESSOR_32KB = 12 << 4 | 5,
67
- DEDICATED_COMPRESSOR_64KB = 13 << 4 | 6,
68
- DEDICATED_COMPRESSOR_128KB = 14 << 4 | 7,
69
- DEDICATED_COMPRESSOR_256KB = 15 << 4 | 8,
70
- /* Same as 256kb */
71
- DEDICATED_COMPRESSOR = 15 << 4 | 8
72
- } uws_compress_options_t;
40
+ DLL_EXPORT typedef enum {
41
+ /* These are not actual compression options */
42
+ _COMPRESSOR_MASK = 0x00FF,
43
+ _DECOMPRESSOR_MASK = 0x0F00,
44
+ /* Disabled, shared, shared are "special" values */
45
+ DISABLED = 0,
46
+ SHARED_COMPRESSOR = 1,
47
+ SHARED_DECOMPRESSOR = 1 << 8,
48
+ /* Highest 4 bits describe decompressor */
49
+ DEDICATED_DECOMPRESSOR_32KB = 15 << 8,
50
+ DEDICATED_DECOMPRESSOR_16KB = 14 << 8,
51
+ DEDICATED_DECOMPRESSOR_8KB = 13 << 8,
52
+ DEDICATED_DECOMPRESSOR_4KB = 12 << 8,
53
+ DEDICATED_DECOMPRESSOR_2KB = 11 << 8,
54
+ DEDICATED_DECOMPRESSOR_1KB = 10 << 8,
55
+ DEDICATED_DECOMPRESSOR_512B = 9 << 8,
56
+ /* Same as 32kb */
57
+ DEDICATED_DECOMPRESSOR = 15 << 8,
73
58
 
74
- DLL_EXPORT typedef enum
75
- {
76
- CONTINUATION = 0,
77
- TEXT = 1,
78
- BINARY = 2,
79
- CLOSE = 8,
80
- PING = 9,
81
- PONG = 10
82
- } uws_opcode_t;
59
+ /* Lowest 8 bit describe compressor */
60
+ DEDICATED_COMPRESSOR_3KB = 9 << 4 | 1,
61
+ DEDICATED_COMPRESSOR_4KB = 9 << 4 | 2,
62
+ DEDICATED_COMPRESSOR_8KB = 10 << 4 | 3,
63
+ DEDICATED_COMPRESSOR_16KB = 11 << 4 | 4,
64
+ DEDICATED_COMPRESSOR_32KB = 12 << 4 | 5,
65
+ DEDICATED_COMPRESSOR_64KB = 13 << 4 | 6,
66
+ DEDICATED_COMPRESSOR_128KB = 14 << 4 | 7,
67
+ DEDICATED_COMPRESSOR_256KB = 15 << 4 | 8,
68
+ /* Same as 256kb */
69
+ DEDICATED_COMPRESSOR = 15 << 4 | 8
70
+ } uws_compress_options_t;
83
71
 
84
- DLL_EXPORT typedef enum
85
- {
86
- BACKPRESSURE,
87
- SUCCESS,
88
- DROPPED
89
- } uws_sendstatus_t;
72
+ DLL_EXPORT typedef enum {
73
+ CONTINUATION = 0,
74
+ TEXT = 1,
75
+ BINARY = 2,
76
+ CLOSE = 8,
77
+ PING = 9,
78
+ PONG = 10
79
+ } uws_opcode_t;
90
80
 
91
- DLL_EXPORT typedef struct
92
- {
81
+ DLL_EXPORT typedef enum { BACKPRESSURE, SUCCESS, DROPPED } uws_sendstatus_t;
93
82
 
94
- int port;
95
- const char *host;
96
- int options;
97
- } uws_app_listen_config_t;
83
+ DLL_EXPORT typedef struct {
84
+ int port;
85
+ const char *host;
86
+ int options;
87
+ } uws_app_listen_config_t;
98
88
 
99
- DLL_EXPORT typedef struct {
100
- bool ok;
101
- bool has_responded;
102
- } uws_try_end_result_t;
89
+ DLL_EXPORT typedef struct {
90
+ bool ok;
91
+ bool has_responded;
92
+ } uws_try_end_result_t;
103
93
 
104
- DLL_EXPORT struct uws_app_s;
105
- DLL_EXPORT struct uws_req_s;
106
- DLL_EXPORT struct uws_res_s;
107
- DLL_EXPORT struct uws_websocket_s;
108
- DLL_EXPORT struct uws_header_iterator_s;
109
- DLL_EXPORT typedef struct uws_app_s uws_app_t;
110
- DLL_EXPORT typedef struct uws_req_s uws_req_t;
111
- DLL_EXPORT typedef struct uws_res_s uws_res_t;
112
- DLL_EXPORT typedef struct uws_socket_context_s uws_socket_context_t;
113
- DLL_EXPORT typedef struct uws_websocket_s uws_websocket_t;
94
+ DLL_EXPORT struct uws_app_s;
95
+ DLL_EXPORT struct uws_req_s;
96
+ DLL_EXPORT struct uws_res_s;
97
+ DLL_EXPORT struct uws_websocket_s;
98
+ DLL_EXPORT struct uws_header_iterator_s;
99
+ DLL_EXPORT typedef struct uws_app_s uws_app_t;
100
+ DLL_EXPORT typedef struct uws_req_s uws_req_t;
101
+ DLL_EXPORT typedef struct uws_res_s uws_res_t;
102
+ DLL_EXPORT typedef struct uws_socket_context_s uws_socket_context_t;
103
+ DLL_EXPORT typedef struct uws_websocket_s uws_websocket_t;
114
104
 
115
- DLL_EXPORT typedef void (*uws_websocket_handler)(uws_websocket_t *ws, void* user_data);
116
- DLL_EXPORT typedef void (*uws_websocket_message_handler)(uws_websocket_t *ws, const char *message, size_t length, uws_opcode_t opcode, void* user_data);
117
- DLL_EXPORT typedef void (*uws_websocket_ping_pong_handler)(uws_websocket_t *ws, const char *message, size_t length, void* user_data);
118
- DLL_EXPORT typedef void (*uws_websocket_close_handler)(uws_websocket_t *ws, int code, const char *message, size_t length, void* user_data);
119
- DLL_EXPORT typedef void (*uws_websocket_upgrade_handler)(uws_res_t *response, uws_req_t *request, uws_socket_context_t *context, void* user_data);
120
- DLL_EXPORT typedef void (*uws_websocket_subscription_handler)(uws_websocket_t *ws, const char *topic_name, size_t topic_name_length, int new_number_of_subscriber, int old_number_of_subscriber, void* user_data);
105
+ DLL_EXPORT typedef void (*uws_websocket_handler)(uws_websocket_t *ws,
106
+ void *user_data);
107
+ DLL_EXPORT typedef void (*uws_websocket_message_handler)(uws_websocket_t *ws,
108
+ const char *message,
109
+ size_t length,
110
+ uws_opcode_t opcode,
111
+ void *user_data);
112
+ DLL_EXPORT typedef void (*uws_websocket_ping_pong_handler)(uws_websocket_t *ws,
113
+ const char *message,
114
+ size_t length,
115
+ void *user_data);
116
+ DLL_EXPORT typedef void (*uws_websocket_close_handler)(uws_websocket_t *ws,
117
+ int code,
118
+ const char *message,
119
+ size_t length,
120
+ void *user_data);
121
+ DLL_EXPORT typedef void (*uws_websocket_upgrade_handler)(
122
+ uws_res_t *response, uws_req_t *request, uws_socket_context_t *context,
123
+ void *user_data);
124
+ DLL_EXPORT typedef void (*uws_websocket_subscription_handler)(
125
+ uws_websocket_t *ws, const char *topic_name, size_t topic_name_length,
126
+ int new_number_of_subscriber, int old_number_of_subscriber,
127
+ void *user_data);
121
128
 
122
- DLL_EXPORT typedef struct
123
- {
124
- uws_compress_options_t compression;
125
- /* Maximum message size we can receive */
126
- unsigned int maxPayloadLength;
127
- /* 2 minutes timeout is good */
128
- unsigned short idleTimeout;
129
- /* 64kb backpressure is probably good */
130
- unsigned int maxBackpressure;
131
- bool closeOnBackpressureLimit;
132
- /* This one depends on kernel timeouts and is a bad default */
133
- bool resetIdleTimeoutOnSend;
134
- /* A good default, esp. for newcomers */
135
- bool sendPingsAutomatically;
136
- /* Maximum socket lifetime in seconds before forced closure (defaults to disabled) */
137
- unsigned short maxLifetime;
138
- uws_websocket_upgrade_handler upgrade;
139
- uws_websocket_handler open;
140
- uws_websocket_message_handler message;
141
- uws_websocket_handler drain;
142
- uws_websocket_ping_pong_handler ping;
143
- uws_websocket_ping_pong_handler pong;
144
- uws_websocket_close_handler close;
145
- uws_websocket_subscription_handler subscription;
146
- } uws_socket_behavior_t;
129
+ DLL_EXPORT typedef struct {
130
+ uws_compress_options_t compression;
131
+ /* Maximum message size we can receive */
132
+ unsigned int maxPayloadLength;
133
+ /* 2 minutes timeout is good */
134
+ unsigned short idleTimeout;
135
+ /* 64kb backpressure is probably good */
136
+ unsigned int maxBackpressure;
137
+ bool closeOnBackpressureLimit;
138
+ /* This one depends on kernel timeouts and is a bad default */
139
+ bool resetIdleTimeoutOnSend;
140
+ /* A good default, esp. for newcomers */
141
+ bool sendPingsAutomatically;
142
+ /* Maximum socket lifetime in seconds before forced closure (defaults to
143
+ * disabled) */
144
+ unsigned short maxLifetime;
145
+ uws_websocket_upgrade_handler upgrade;
146
+ uws_websocket_handler open;
147
+ uws_websocket_message_handler message;
148
+ uws_websocket_handler drain;
149
+ uws_websocket_ping_pong_handler ping;
150
+ uws_websocket_ping_pong_handler pong;
151
+ uws_websocket_close_handler close;
152
+ uws_websocket_subscription_handler subscription;
153
+ } uws_socket_behavior_t;
147
154
 
148
- DLL_EXPORT typedef void (*uws_listen_handler)(struct us_listen_socket_t *listen_socket, uws_app_listen_config_t config, void *user_data);
149
- DLL_EXPORT typedef void (*uws_listen_domain_handler)(struct us_listen_socket_t *listen_socket, const char* domain, size_t domain_length, int options, void *user_data);
150
- DLL_EXPORT typedef void (*uws_method_handler)(uws_res_t *response, uws_req_t *request, void *user_data);
151
- DLL_EXPORT typedef void (*uws_filter_handler)(uws_res_t *response, int, void *user_data);
152
- DLL_EXPORT typedef void (*uws_missing_server_handler)(const char *hostname, size_t hostname_length, void *user_data);
153
- DLL_EXPORT typedef void (*uws_get_headers_server_handler)(const char *header_name, size_t header_name_size, const char *header_value, size_t header_value_size, void *user_data);
154
- //Basic HTTP
155
- DLL_EXPORT uws_app_t *uws_create_app(int ssl, struct us_socket_context_options_t options);
156
- DLL_EXPORT void uws_app_destroy(int ssl, uws_app_t *app);
157
- DLL_EXPORT void uws_app_get(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
158
- DLL_EXPORT void uws_app_post(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
159
- DLL_EXPORT void uws_app_options(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
160
- DLL_EXPORT void uws_app_delete(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
161
- DLL_EXPORT void uws_app_patch(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
162
- DLL_EXPORT void uws_app_put(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
163
- DLL_EXPORT void uws_app_head(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
164
- DLL_EXPORT void uws_app_connect(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
165
- DLL_EXPORT void uws_app_trace(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
166
- DLL_EXPORT void uws_app_any(int ssl, uws_app_t *app, const char *pattern, uws_method_handler handler, void *user_data);
155
+ DLL_EXPORT typedef void (*uws_listen_handler)(
156
+ struct us_listen_socket_t *listen_socket, uws_app_listen_config_t config,
157
+ void *user_data);
158
+ DLL_EXPORT typedef void (*uws_listen_domain_handler)(
159
+ struct us_listen_socket_t *listen_socket, const char *domain,
160
+ size_t domain_length, int options, void *user_data);
161
+ DLL_EXPORT typedef void (*uws_method_handler)(uws_res_t *response,
162
+ uws_req_t *request,
163
+ void *user_data);
164
+ DLL_EXPORT typedef void (*uws_filter_handler)(uws_res_t *response, int,
165
+ void *user_data);
166
+ DLL_EXPORT typedef void (*uws_missing_server_handler)(const char *hostname,
167
+ size_t hostname_length,
168
+ void *user_data);
169
+ DLL_EXPORT typedef void (*uws_get_headers_server_handler)(
170
+ const char *header_name, size_t header_name_size, const char *header_value,
171
+ size_t header_value_size, void *user_data);
172
+ // Basic HTTP
173
+ DLL_EXPORT uws_app_t *
174
+ uws_create_app(int ssl, struct us_socket_context_options_t options);
175
+ DLL_EXPORT void uws_app_destroy(int ssl, uws_app_t *app);
176
+ DLL_EXPORT void uws_app_get(int ssl, uws_app_t *app, const char *pattern,
177
+ uws_method_handler handler, void *user_data);
178
+ DLL_EXPORT void uws_app_post(int ssl, uws_app_t *app, const char *pattern,
179
+ uws_method_handler handler, void *user_data);
180
+ DLL_EXPORT void uws_app_options(int ssl, uws_app_t *app, const char *pattern,
181
+ uws_method_handler handler, void *user_data);
182
+ DLL_EXPORT void uws_app_delete(int ssl, uws_app_t *app, const char *pattern,
183
+ uws_method_handler handler, void *user_data);
184
+ DLL_EXPORT void uws_app_patch(int ssl, uws_app_t *app, const char *pattern,
185
+ uws_method_handler handler, void *user_data);
186
+ DLL_EXPORT void uws_app_put(int ssl, uws_app_t *app, const char *pattern,
187
+ uws_method_handler handler, void *user_data);
188
+ DLL_EXPORT void uws_app_head(int ssl, uws_app_t *app, const char *pattern,
189
+ uws_method_handler handler, void *user_data);
190
+ DLL_EXPORT void uws_app_connect(int ssl, uws_app_t *app, const char *pattern,
191
+ uws_method_handler handler, void *user_data);
192
+ DLL_EXPORT void uws_app_trace(int ssl, uws_app_t *app, const char *pattern,
193
+ uws_method_handler handler, void *user_data);
194
+ DLL_EXPORT void uws_app_any(int ssl, uws_app_t *app, const char *pattern,
195
+ uws_method_handler handler, void *user_data);
167
196
 
168
- DLL_EXPORT void uws_app_run(int ssl, uws_app_t *);
197
+ DLL_EXPORT void uws_app_run(int ssl, uws_app_t *);
169
198
 
170
- DLL_EXPORT void uws_app_listen(int ssl, uws_app_t *app, int port, uws_listen_handler handler, void *user_data);
171
- DLL_EXPORT void uws_app_listen_with_config(int ssl, uws_app_t *app, uws_app_listen_config_t config, uws_listen_handler handler, void *user_data);
172
- DLL_EXPORT void uws_app_listen_domain(int ssl, uws_app_t *app, const char *domain, size_t domain_length, uws_listen_domain_handler handler, void *user_data);
173
- DLL_EXPORT void uws_app_listen_domain_with_options(int ssl, uws_app_t *app, const char *domain,size_t domain_length, int options, uws_listen_domain_handler handler, void *user_data);
174
- DLL_EXPORT void uws_app_domain(int ssl, uws_app_t *app, const char* server_name, size_t server_name_length);
175
- DLL_EXPORT void uws_app_close(int ssl, uws_app_t *app);
199
+ DLL_EXPORT void uws_app_listen(int ssl, uws_app_t *app, int port,
200
+ uws_listen_handler handler, void *user_data);
201
+ DLL_EXPORT void uws_app_listen_with_config(int ssl, uws_app_t *app,
202
+ uws_app_listen_config_t config,
203
+ uws_listen_handler handler,
204
+ void *user_data);
205
+ DLL_EXPORT void uws_app_listen_domain(int ssl, uws_app_t *app,
206
+ const char *domain, size_t domain_length,
207
+ uws_listen_domain_handler handler,
208
+ void *user_data);
209
+ DLL_EXPORT void uws_app_listen_domain_with_options(
210
+ int ssl, uws_app_t *app, const char *domain, size_t domain_length,
211
+ int options, uws_listen_domain_handler handler, void *user_data);
212
+ DLL_EXPORT void uws_app_domain(int ssl, uws_app_t *app, const char *server_name,
213
+ size_t server_name_length);
214
+ DLL_EXPORT void uws_app_close(int ssl, uws_app_t *app);
176
215
 
177
- DLL_EXPORT bool uws_constructor_failed(int ssl, uws_app_t *app);
178
- DLL_EXPORT unsigned int uws_num_subscribers(int ssl, uws_app_t *app, const char *topic, size_t topic_length);
179
- DLL_EXPORT bool uws_publish(int ssl, uws_app_t *app, const char *topic, size_t topic_length, const char *message, size_t message_length, uws_opcode_t opcode, bool compress);
180
- DLL_EXPORT void *uws_get_native_handle(int ssl, uws_app_t *app);
181
- DLL_EXPORT void uws_remove_server_name(int ssl, uws_app_t *app, const char *hostname_pattern, size_t hostname_pattern_length);
182
- DLL_EXPORT void uws_add_server_name(int ssl, uws_app_t *app, const char *hostname_pattern, size_t hostname_pattern_length);
183
- DLL_EXPORT void uws_add_server_name_with_options(int ssl, uws_app_t *app, const char *hostname_pattern, size_t hostname_pattern_length, struct us_socket_context_options_t options);
184
- DLL_EXPORT void uws_missing_server_name(int ssl, uws_app_t *app, uws_missing_server_handler handler, void *user_data);
185
- DLL_EXPORT void uws_filter(int ssl, uws_app_t *app, uws_filter_handler handler, void *user_data);
216
+ DLL_EXPORT bool uws_constructor_failed(int ssl, uws_app_t *app);
217
+ DLL_EXPORT unsigned int uws_num_subscribers(int ssl, uws_app_t *app,
218
+ const char *topic,
219
+ size_t topic_length);
220
+ DLL_EXPORT bool uws_publish(int ssl, uws_app_t *app, const char *topic,
221
+ size_t topic_length, const char *message,
222
+ size_t message_length, uws_opcode_t opcode,
223
+ bool compress);
224
+ DLL_EXPORT void *uws_get_native_handle(int ssl, uws_app_t *app);
225
+ DLL_EXPORT void uws_remove_server_name(int ssl, uws_app_t *app,
226
+ const char *hostname_pattern,
227
+ size_t hostname_pattern_length);
228
+ DLL_EXPORT void uws_add_server_name(int ssl, uws_app_t *app,
229
+ const char *hostname_pattern,
230
+ size_t hostname_pattern_length);
231
+ DLL_EXPORT void uws_add_server_name_with_options(
232
+ int ssl, uws_app_t *app, const char *hostname_pattern,
233
+ size_t hostname_pattern_length, struct us_socket_context_options_t options);
234
+ DLL_EXPORT void uws_missing_server_name(int ssl, uws_app_t *app,
235
+ uws_missing_server_handler handler,
236
+ void *user_data);
237
+ DLL_EXPORT void uws_filter(int ssl, uws_app_t *app, uws_filter_handler handler,
238
+ void *user_data);
186
239
 
187
- //WebSocket
188
- DLL_EXPORT void uws_ws(int ssl, uws_app_t *app, const char *pattern, uws_socket_behavior_t behavior, void* user_data);
189
- DLL_EXPORT void *uws_ws_get_user_data(int ssl, uws_websocket_t *ws);
190
- DLL_EXPORT void uws_ws_close(int ssl, uws_websocket_t *ws);
191
- DLL_EXPORT uws_sendstatus_t uws_ws_send(int ssl, uws_websocket_t *ws, const char *message, size_t length, uws_opcode_t opcode);
192
- DLL_EXPORT uws_sendstatus_t uws_ws_send_with_options(int ssl, uws_websocket_t *ws, const char *message, size_t length, uws_opcode_t opcode, bool compress, bool fin);
193
- DLL_EXPORT uws_sendstatus_t uws_ws_send_fragment(int ssl, uws_websocket_t *ws, const char *message, size_t length, bool compress);
194
- DLL_EXPORT uws_sendstatus_t uws_ws_send_first_fragment(int ssl, uws_websocket_t *ws, const char *message, size_t length, bool compress);
195
- DLL_EXPORT uws_sendstatus_t uws_ws_send_first_fragment_with_opcode(int ssl, uws_websocket_t *ws, const char *message, size_t length, uws_opcode_t opcode, bool compress);
196
- DLL_EXPORT uws_sendstatus_t uws_ws_send_last_fragment(int ssl, uws_websocket_t *ws, const char *message, size_t length, bool compress);
197
- DLL_EXPORT void uws_ws_end(int ssl, uws_websocket_t *ws, int code, const char *message, size_t length);
198
- DLL_EXPORT void uws_ws_cork(int ssl, uws_websocket_t *ws, void (*handler)(void *user_data), void *user_data);
240
+ // WebSocket
241
+ DLL_EXPORT void uws_ws(int ssl, uws_app_t *app, const char *pattern,
242
+ uws_socket_behavior_t behavior, void *user_data);
243
+ DLL_EXPORT void *uws_ws_get_user_data(int ssl, uws_websocket_t *ws);
244
+ DLL_EXPORT void uws_ws_close(int ssl, uws_websocket_t *ws);
245
+ DLL_EXPORT uws_sendstatus_t uws_ws_send(int ssl, uws_websocket_t *ws,
246
+ const char *message, size_t length,
247
+ uws_opcode_t opcode);
248
+ DLL_EXPORT uws_sendstatus_t uws_ws_send_with_options(
249
+ int ssl, uws_websocket_t *ws, const char *message, size_t length,
250
+ uws_opcode_t opcode, bool compress, bool fin);
251
+ DLL_EXPORT uws_sendstatus_t uws_ws_send_fragment(int ssl, uws_websocket_t *ws,
252
+ const char *message,
253
+ size_t length, bool compress);
254
+ DLL_EXPORT uws_sendstatus_t uws_ws_send_first_fragment(int ssl,
255
+ uws_websocket_t *ws,
256
+ const char *message,
257
+ size_t length,
258
+ bool compress);
259
+ DLL_EXPORT uws_sendstatus_t uws_ws_send_first_fragment_with_opcode(
260
+ int ssl, uws_websocket_t *ws, const char *message, size_t length,
261
+ uws_opcode_t opcode, bool compress);
262
+ DLL_EXPORT uws_sendstatus_t uws_ws_send_last_fragment(int ssl,
263
+ uws_websocket_t *ws,
264
+ const char *message,
265
+ size_t length,
266
+ bool compress);
267
+ DLL_EXPORT void uws_ws_end(int ssl, uws_websocket_t *ws, int code,
268
+ const char *message, size_t length);
269
+ DLL_EXPORT void uws_ws_cork(int ssl, uws_websocket_t *ws,
270
+ void (*handler)(void *user_data), void *user_data);
199
271
 
200
- DLL_EXPORT bool uws_ws_subscribe(int ssl, uws_websocket_t *ws, const char *topic, size_t length);
201
- DLL_EXPORT bool uws_ws_unsubscribe(int ssl, uws_websocket_t *ws, const char *topic, size_t length);
202
- DLL_EXPORT bool uws_ws_is_subscribed(int ssl, uws_websocket_t *ws, const char *topic, size_t length);
203
- DLL_EXPORT void uws_ws_iterate_topics(int ssl, uws_websocket_t *ws, void (*callback)(const char *topic, size_t length, void *user_data), void *user_data);
204
- DLL_EXPORT bool uws_ws_publish(int ssl, uws_websocket_t *ws, const char *topic, size_t topic_length, const char *message, size_t message_length);
205
- DLL_EXPORT bool uws_ws_publish_with_options(int ssl, uws_websocket_t *ws, const char *topic, size_t topic_length, const char *message, size_t message_length, uws_opcode_t opcode, bool compress);
206
- DLL_EXPORT unsigned int uws_ws_get_buffered_amount(int ssl, uws_websocket_t *ws);
207
- DLL_EXPORT size_t uws_ws_get_remote_address(int ssl, uws_websocket_t *ws, const char **dest);
208
- DLL_EXPORT size_t uws_ws_get_remote_address_as_text(int ssl, uws_websocket_t *ws, const char **dest);
272
+ DLL_EXPORT bool uws_ws_subscribe(int ssl, uws_websocket_t *ws,
273
+ const char *topic, size_t length);
274
+ DLL_EXPORT bool uws_ws_unsubscribe(int ssl, uws_websocket_t *ws,
275
+ const char *topic, size_t length);
276
+ DLL_EXPORT bool uws_ws_is_subscribed(int ssl, uws_websocket_t *ws,
277
+ const char *topic, size_t length);
278
+ DLL_EXPORT void uws_ws_iterate_topics(int ssl, uws_websocket_t *ws,
279
+ void (*callback)(const char *topic,
280
+ size_t length,
281
+ void *user_data),
282
+ void *user_data);
283
+ DLL_EXPORT bool uws_ws_publish(int ssl, uws_websocket_t *ws, const char *topic,
284
+ size_t topic_length, const char *message,
285
+ size_t message_length);
286
+ DLL_EXPORT bool uws_ws_publish_with_options(int ssl, uws_websocket_t *ws,
287
+ const char *topic,
288
+ size_t topic_length,
289
+ const char *message,
290
+ size_t message_length,
291
+ uws_opcode_t opcode, bool compress);
292
+ DLL_EXPORT unsigned int uws_ws_get_buffered_amount(int ssl,
293
+ uws_websocket_t *ws);
294
+ DLL_EXPORT size_t uws_ws_get_remote_address(int ssl, uws_websocket_t *ws,
295
+ const char **dest);
296
+ DLL_EXPORT size_t uws_ws_get_remote_address_as_text(int ssl,
297
+ uws_websocket_t *ws,
298
+ const char **dest);
209
299
 
210
- //Response
211
- DLL_EXPORT void uws_res_end(int ssl, uws_res_t *res, const char *data, size_t length, bool close_connection);
212
- DLL_EXPORT uws_try_end_result_t uws_res_try_end(int ssl, uws_res_t *res, const char *data, size_t length, uintmax_t total_size, bool close_connection);
213
- DLL_EXPORT void uws_res_cork(int ssl, uws_res_t *res, void(*callback)(uws_res_t *res, void* user_data) ,void* user_data);
214
- DLL_EXPORT void uws_res_pause(int ssl, uws_res_t *res);
215
- DLL_EXPORT void uws_res_resume(int ssl, uws_res_t *res);
216
- DLL_EXPORT void uws_res_write_continue(int ssl, uws_res_t *res);
217
- DLL_EXPORT void uws_res_write_status(int ssl, uws_res_t *res, const char *status, size_t length);
218
- DLL_EXPORT void uws_res_write_header(int ssl, uws_res_t *res, const char *key, size_t key_length, const char *value, size_t value_length);
300
+ // Response
301
+ DLL_EXPORT void uws_res_end(int ssl, uws_res_t *res, const char *data,
302
+ size_t length, bool close_connection);
303
+ DLL_EXPORT uws_try_end_result_t uws_res_try_end(int ssl, uws_res_t *res,
304
+ const char *data, size_t length,
305
+ uintmax_t total_size,
306
+ bool close_connection);
307
+ DLL_EXPORT void uws_res_cork(int ssl, uws_res_t *res,
308
+ void (*callback)(uws_res_t *res, void *user_data),
309
+ void *user_data);
310
+ DLL_EXPORT void uws_res_pause(int ssl, uws_res_t *res);
311
+ DLL_EXPORT void uws_res_resume(int ssl, uws_res_t *res);
312
+ DLL_EXPORT void uws_res_write_continue(int ssl, uws_res_t *res);
313
+ DLL_EXPORT void uws_res_write_status(int ssl, uws_res_t *res,
314
+ const char *status, size_t length);
315
+ DLL_EXPORT void uws_res_write_header(int ssl, uws_res_t *res, const char *key,
316
+ size_t key_length, const char *value,
317
+ size_t value_length);
219
318
 
220
- DLL_EXPORT void uws_res_write_header_int(int ssl, uws_res_t *res, const char *key, size_t key_length, uint64_t value);
221
- DLL_EXPORT void uws_res_end_without_body(int ssl, uws_res_t *res, bool close_connection);
222
- DLL_EXPORT bool uws_res_write(int ssl, uws_res_t *res, const char *data, size_t length);
223
- DLL_EXPORT uintmax_t uws_res_get_write_offset(int ssl, uws_res_t *res);
224
- DLL_EXPORT void uws_res_override_write_offset(int ssl, uws_res_t *res, uintmax_t offset);
225
- DLL_EXPORT bool uws_res_has_responded(int ssl, uws_res_t *res);
226
- DLL_EXPORT void uws_res_on_writable(int ssl, uws_res_t *res, bool (*handler)(uws_res_t *res, uintmax_t, void *optional_data), void *user_data);
227
- DLL_EXPORT void uws_res_on_aborted(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, void *optional_data), void *optional_data);
228
- DLL_EXPORT void uws_res_on_data(int ssl, uws_res_t *res, void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length, bool is_end, void *optional_data), void *optional_data);
229
- DLL_EXPORT void uws_res_upgrade(int ssl, uws_res_t *res, void *data, const char *sec_web_socket_key, size_t sec_web_socket_key_length, const char *sec_web_socket_protocol, size_t sec_web_socket_protocol_length, const char *sec_web_socket_extensions, size_t sec_web_socket_extensions_length, uws_socket_context_t *ws);
230
- DLL_EXPORT size_t uws_res_get_remote_address(int ssl, uws_res_t *res, const char **dest);
231
- DLL_EXPORT size_t uws_res_get_remote_address_as_text(int ssl, uws_res_t *res, const char **dest);
319
+ DLL_EXPORT void uws_res_write_header_int(int ssl, uws_res_t *res,
320
+ const char *key, size_t key_length,
321
+ uint64_t value);
322
+ DLL_EXPORT void uws_res_end_without_body(int ssl, uws_res_t *res,
323
+ bool close_connection);
324
+ DLL_EXPORT bool uws_res_write(int ssl, uws_res_t *res, const char *data,
325
+ size_t length);
326
+ DLL_EXPORT uintmax_t uws_res_get_write_offset(int ssl, uws_res_t *res);
327
+ DLL_EXPORT void uws_res_override_write_offset(int ssl, uws_res_t *res,
328
+ uintmax_t offset);
329
+ DLL_EXPORT bool uws_res_has_responded(int ssl, uws_res_t *res);
330
+ DLL_EXPORT void uws_res_on_writable(int ssl, uws_res_t *res,
331
+ bool (*handler)(uws_res_t *res, uintmax_t,
332
+ void *optional_data),
333
+ void *user_data);
334
+ DLL_EXPORT void uws_res_on_aborted(int ssl, uws_res_t *res,
335
+ void (*handler)(uws_res_t *res,
336
+ void *optional_data),
337
+ void *optional_data);
338
+ DLL_EXPORT void uws_res_on_data(
339
+ int ssl, uws_res_t *res,
340
+ void (*handler)(uws_res_t *res, const char *chunk, size_t chunk_length,
341
+ bool is_end, void *optional_data),
342
+ void *optional_data);
343
+ DLL_EXPORT void uws_res_upgrade(int ssl, uws_res_t *res, void *data,
344
+ const char *sec_web_socket_key,
345
+ size_t sec_web_socket_key_length,
346
+ const char *sec_web_socket_protocol,
347
+ size_t sec_web_socket_protocol_length,
348
+ const char *sec_web_socket_extensions,
349
+ size_t sec_web_socket_extensions_length,
350
+ uws_socket_context_t *ws);
351
+ DLL_EXPORT size_t uws_res_get_remote_address(int ssl, uws_res_t *res,
352
+ const char **dest);
353
+ DLL_EXPORT size_t uws_res_get_remote_address_as_text(int ssl, uws_res_t *res,
354
+ const char **dest);
232
355
  #ifdef UWS_WITH_PROXY
233
- DLL_EXPORT size_t uws_res_get_proxied_remote_address(int ssl, uws_res_t *res, const char **dest);
234
- DLL_EXPORT size_t uws_res_get_proxied_remote_address_as_text(int ssl, uws_res_t *res, const char **dest);
356
+ DLL_EXPORT size_t uws_res_get_proxied_remote_address(int ssl, uws_res_t *res,
357
+ const char **dest);
358
+ DLL_EXPORT size_t uws_res_get_proxied_remote_address_as_text(int ssl,
359
+ uws_res_t *res,
360
+ const char **dest);
235
361
  #endif
236
- DLL_EXPORT void *uws_res_get_native_handle(int ssl, uws_res_t *res);
362
+ DLL_EXPORT void *uws_res_get_native_handle(int ssl, uws_res_t *res);
237
363
 
238
- //Request
239
- DLL_EXPORT bool uws_req_is_ancient(uws_req_t *res);
240
- DLL_EXPORT bool uws_req_get_yield(uws_req_t *res);
241
- DLL_EXPORT void uws_req_set_yield(uws_req_t *res, bool yield);
242
- DLL_EXPORT size_t uws_req_get_url(uws_req_t *res, const char **dest);
243
- DLL_EXPORT size_t uws_req_get_full_url(uws_req_t *res, const char **dest);
244
- DLL_EXPORT size_t uws_req_get_method(uws_req_t *res, const char **dest);
245
- DLL_EXPORT size_t uws_req_get_case_sensitive_method(uws_req_t *res, const char **dest);
364
+ // Request
365
+ DLL_EXPORT bool uws_req_is_ancient(uws_req_t *res);
366
+ DLL_EXPORT bool uws_req_get_yield(uws_req_t *res);
367
+ DLL_EXPORT void uws_req_set_yield(uws_req_t *res, bool yield);
368
+ DLL_EXPORT size_t uws_req_get_url(uws_req_t *res, const char **dest);
369
+ DLL_EXPORT size_t uws_req_get_full_url(uws_req_t *res, const char **dest);
370
+ DLL_EXPORT size_t uws_req_get_method(uws_req_t *res, const char **dest);
371
+ DLL_EXPORT size_t uws_req_get_case_sensitive_method(uws_req_t *res,
372
+ const char **dest);
246
373
 
247
- DLL_EXPORT size_t uws_req_get_header(uws_req_t *res, const char *lower_case_header, size_t lower_case_header_length, const char **dest);
248
- DLL_EXPORT void uws_req_for_each_header(uws_req_t *res, uws_get_headers_server_handler handler, void *user_data);
249
- DLL_EXPORT size_t uws_req_get_query(uws_req_t *res, const char *key, size_t key_length, const char **dest);
250
- DLL_EXPORT size_t uws_req_get_parameter(uws_req_t *res, unsigned short index, const char **dest);
374
+ DLL_EXPORT size_t uws_req_get_header(uws_req_t *res,
375
+ const char *lower_case_header,
376
+ size_t lower_case_header_length,
377
+ const char **dest);
378
+ DLL_EXPORT void uws_req_for_each_header(uws_req_t *res,
379
+ uws_get_headers_server_handler handler,
380
+ void *user_data);
381
+ DLL_EXPORT size_t uws_req_get_query(uws_req_t *res, const char *key,
382
+ size_t key_length, const char **dest);
383
+ DLL_EXPORT size_t uws_req_get_parameter(uws_req_t *res, unsigned short index,
384
+ const char **dest);
251
385
 
252
- DLL_EXPORT struct us_loop_t *uws_get_loop();
253
- DLL_EXPORT struct us_loop_t *uws_get_loop_with_native(void* existing_native_loop);
254
- DLL_EXPORT void uws_loop_defer(struct us_loop_t *loop, void( cb(void *user_data) ), void *user_data);
386
+ DLL_EXPORT struct us_loop_t *uws_get_loop();
387
+ DLL_EXPORT struct us_loop_t *
388
+ uws_get_loop_with_native(void *existing_native_loop);
389
+ DLL_EXPORT void uws_loop_defer(struct us_loop_t *loop,
390
+ void(cb(void *user_data)), void *user_data);
255
391
 
256
392
  #ifdef __cplusplus
257
393
  }