opal-up 0.0.2 → 0.0.4

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +209 -0
  3. data/README.md +97 -29
  4. data/bin/up_ruby +4 -0
  5. data/bin/up_ruby_cluster +4 -0
  6. data/ext/up_ext/App.h +606 -0
  7. data/ext/up_ext/AsyncSocket.h +355 -0
  8. data/ext/up_ext/AsyncSocketData.h +87 -0
  9. data/ext/up_ext/BloomFilter.h +83 -0
  10. data/ext/up_ext/ChunkedEncoding.h +236 -0
  11. data/ext/up_ext/ClientApp.h +36 -0
  12. data/ext/up_ext/HttpContext.h +502 -0
  13. data/ext/up_ext/HttpContextData.h +56 -0
  14. data/ext/up_ext/HttpErrors.h +53 -0
  15. data/ext/up_ext/HttpParser.h +680 -0
  16. data/ext/up_ext/HttpResponse.h +578 -0
  17. data/ext/up_ext/HttpResponseData.h +95 -0
  18. data/ext/up_ext/HttpRouter.h +380 -0
  19. data/ext/up_ext/Loop.h +204 -0
  20. data/ext/up_ext/LoopData.h +112 -0
  21. data/ext/up_ext/MoveOnlyFunction.h +377 -0
  22. data/ext/up_ext/PerMessageDeflate.h +315 -0
  23. data/ext/up_ext/ProxyParser.h +163 -0
  24. data/ext/up_ext/QueryParser.h +120 -0
  25. data/ext/up_ext/TopicTree.h +363 -0
  26. data/ext/up_ext/Utilities.h +66 -0
  27. data/ext/up_ext/WebSocket.h +381 -0
  28. data/ext/up_ext/WebSocketContext.h +434 -0
  29. data/ext/up_ext/WebSocketContextData.h +109 -0
  30. data/ext/up_ext/WebSocketData.h +86 -0
  31. data/ext/up_ext/WebSocketExtensions.h +256 -0
  32. data/ext/up_ext/WebSocketHandshake.h +145 -0
  33. data/ext/up_ext/WebSocketProtocol.h +506 -0
  34. data/ext/up_ext/bsd.c +767 -0
  35. data/ext/up_ext/bsd.h +109 -0
  36. data/ext/up_ext/context.c +524 -0
  37. data/ext/up_ext/epoll_kqueue.c +458 -0
  38. data/ext/up_ext/epoll_kqueue.h +67 -0
  39. data/ext/up_ext/extconf.rb +5 -0
  40. data/ext/up_ext/internal.h +224 -0
  41. data/ext/up_ext/libusockets.h +350 -0
  42. data/ext/up_ext/libuwebsockets.cpp +1344 -0
  43. data/ext/up_ext/libuwebsockets.h +396 -0
  44. data/ext/up_ext/loop.c +386 -0
  45. data/ext/up_ext/loop_data.h +38 -0
  46. data/ext/up_ext/socket.c +231 -0
  47. data/ext/up_ext/up_ext.c +930 -0
  48. data/lib/up/bun/rack_env.rb +1 -13
  49. data/lib/up/bun/server.rb +93 -19
  50. data/lib/up/cli.rb +3 -0
  51. data/lib/up/client.rb +68 -0
  52. data/lib/up/ruby/cluster.rb +39 -0
  53. data/lib/up/ruby/cluster_cli.rb +10 -0
  54. data/lib/up/{node → ruby}/rack_cluster.rb +5 -4
  55. data/lib/up/{node → ruby}/rack_server.rb +4 -4
  56. data/lib/up/ruby/server_cli.rb +10 -0
  57. data/lib/up/u_web_socket/cluster.rb +18 -3
  58. data/lib/up/u_web_socket/server.rb +108 -15
  59. data/lib/up/version.rb +1 -1
  60. metadata +72 -30
  61. data/.gitignore +0 -5
  62. data/Gemfile +0 -2
  63. data/bin/up_node +0 -12
  64. data/bin/up_node_cluster +0 -12
  65. data/example_rack_app/Gemfile +0 -3
  66. data/example_rack_app/config.ru +0 -6
  67. data/example_rack_app/rack_app.rb +0 -5
  68. data/example_roda_app/Gemfile +0 -6
  69. data/example_roda_app/config.ru +0 -6
  70. data/example_roda_app/roda_app.rb +0 -37
  71. data/example_sinatra_app/Gemfile +0 -6
  72. data/example_sinatra_app/config.ru +0 -6
  73. data/example_sinatra_app/sinatra_app.rb +0 -7
  74. data/lib/up/node/cluster.rb +0 -39
  75. data/lib/up/node/cluster_cli.rb +0 -15
  76. data/lib/up/node/rack_env.rb +0 -106
  77. data/lib/up/node/server.rb +0 -84
  78. data/lib/up/node/server_cli.rb +0 -15
  79. data/lib/up/u_web_socket/rack_env.rb +0 -101
  80. data/opal-up.gemspec +0 -27
  81. data/up_logo.svg +0 -256
@@ -0,0 +1,396 @@
1
+ /*
2
+ * Copyright 2022 Ciro Spaciari
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ #ifndef LIBUWS_CAPI_HEADER
24
+ #define LIBUWS_CAPI_HEADER
25
+
26
+ #include "libusockets.h"
27
+ #include <stdbool.h>
28
+ #include <stddef.h>
29
+ #include <stdint.h>
30
+
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+ #ifdef _WIN32
35
+ #define DLL_EXPORT __declspec(dllexport)
36
+ #else
37
+ #define DLL_EXPORT
38
+ #endif
39
+
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,
58
+
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;
71
+
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;
80
+
81
+ DLL_EXPORT typedef enum { BACKPRESSURE, SUCCESS, DROPPED } uws_sendstatus_t;
82
+
83
+ DLL_EXPORT typedef struct {
84
+ int port;
85
+ const char *host;
86
+ int options;
87
+ } uws_app_listen_config_t;
88
+
89
+ DLL_EXPORT typedef struct {
90
+ bool ok;
91
+ bool has_responded;
92
+ } uws_try_end_result_t;
93
+
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;
104
+
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);
128
+
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;
154
+
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);
196
+
197
+ DLL_EXPORT void uws_app_run(int ssl, uws_app_t *);
198
+
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);
215
+
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);
239
+
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);
271
+
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);
299
+
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);
318
+
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);
355
+ #ifdef UWS_WITH_PROXY
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);
361
+ #endif
362
+ DLL_EXPORT void *uws_res_get_native_handle(int ssl, uws_res_t *res);
363
+
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);
373
+
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);
385
+
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);
391
+
392
+ #ifdef __cplusplus
393
+ }
394
+ #endif
395
+
396
+ #endif