opal-up 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -20,76 +20,80 @@
20
20
 
21
21
  /* This data belongs to the HttpResponse */
22
22
 
23
- #include "HttpParser.h"
24
23
  #include "AsyncSocketData.h"
24
+ #include "HttpParser.h"
25
25
  #include "ProxyParser.h"
26
26
 
27
27
  #include "MoveOnlyFunction.h"
28
28
 
29
29
  namespace uWS {
30
30
 
31
- template <bool SSL>
32
- struct HttpResponseData : AsyncSocketData<SSL>, HttpParser {
33
- template <bool> friend struct HttpResponse;
34
- template <bool> friend struct HttpContext;
35
-
36
- /* When we are done with a response we mark it like so */
37
- void markDone() {
38
- onAborted = nullptr;
39
- /* Also remove onWritable so that we do not emit when draining behind the scenes. */
40
- onWritable = nullptr;
41
-
42
- /* We are done with this request */
43
- state &= ~HttpResponseData<SSL>::HTTP_RESPONSE_PENDING;
31
+ template <bool SSL> struct HttpResponseData : AsyncSocketData<SSL>, HttpParser {
32
+ template <bool> friend struct HttpResponse;
33
+ template <bool> friend struct HttpContext;
34
+
35
+ /* When we are done with a response we mark it like so */
36
+ void markDone() {
37
+ onAborted = nullptr;
38
+ /* Also remove onWritable so that we do not emit when draining behind the
39
+ * scenes. */
40
+ onWritable = nullptr;
41
+
42
+ /* We are done with this request */
43
+ state &= ~HttpResponseData<SSL>::HTTP_RESPONSE_PENDING;
44
+ }
45
+
46
+ /* Caller of onWritable. It is possible onWritable calls markDone so we need
47
+ * to borrow it. */
48
+ bool callOnWritable(uintmax_t offset) {
49
+ /* Borrow real onWritable */
50
+ MoveOnlyFunction<bool(uintmax_t)> borrowedOnWritable =
51
+ std::move(onWritable);
52
+
53
+ /* Set onWritable to placeholder */
54
+ onWritable = [](uintmax_t) { return true; };
55
+
56
+ /* Run borrowed onWritable */
57
+ bool ret = borrowedOnWritable(offset);
58
+
59
+ /* If we still have onWritable (the placeholder) then move back the real one
60
+ */
61
+ if (onWritable) {
62
+ /* We haven't reset onWritable, so give it back */
63
+ onWritable = std::move(borrowedOnWritable);
44
64
  }
45
65
 
46
- /* Caller of onWritable. It is possible onWritable calls markDone so we need to borrow it. */
47
- bool callOnWritable(uintmax_t offset) {
48
- /* Borrow real onWritable */
49
- MoveOnlyFunction<bool(uintmax_t)> borrowedOnWritable = std::move(onWritable);
66
+ return ret;
67
+ }
50
68
 
51
- /* Set onWritable to placeholder */
52
- onWritable = [](uintmax_t) {return true;};
53
-
54
- /* Run borrowed onWritable */
55
- bool ret = borrowedOnWritable(offset);
56
-
57
- /* If we still have onWritable (the placeholder) then move back the real one */
58
- if (onWritable) {
59
- /* We haven't reset onWritable, so give it back */
60
- onWritable = std::move(borrowedOnWritable);
61
- }
62
-
63
- return ret;
64
- }
65
69
  private:
66
- /* Bits of status */
67
- enum {
68
- HTTP_STATUS_CALLED = 1, // used
69
- HTTP_WRITE_CALLED = 2, // used
70
- HTTP_END_CALLED = 4, // used
71
- HTTP_RESPONSE_PENDING = 8, // used
72
- HTTP_CONNECTION_CLOSE = 16 // used
73
- };
74
-
75
- /* Per socket event handlers */
76
- MoveOnlyFunction<bool(uintmax_t)> onWritable;
77
- MoveOnlyFunction<void()> onAborted;
78
- MoveOnlyFunction<void(std::string_view, bool)> inStream; // onData
79
- /* Outgoing offset */
80
- uintmax_t offset = 0;
81
-
82
- /* Let's track number of bytes since last timeout reset in data handler */
83
- unsigned int received_bytes_per_timeout = 0;
84
-
85
- /* Current state (content-length sent, status sent, write called, etc */
86
- int state = 0;
70
+ /* Bits of status */
71
+ enum {
72
+ HTTP_STATUS_CALLED = 1, // used
73
+ HTTP_WRITE_CALLED = 2, // used
74
+ HTTP_END_CALLED = 4, // used
75
+ HTTP_RESPONSE_PENDING = 8, // used
76
+ HTTP_CONNECTION_CLOSE = 16 // used
77
+ };
78
+
79
+ /* Per socket event handlers */
80
+ MoveOnlyFunction<bool(uintmax_t)> onWritable;
81
+ MoveOnlyFunction<void()> onAborted;
82
+ MoveOnlyFunction<void(std::string_view, bool)> inStream; // onData
83
+ /* Outgoing offset */
84
+ uintmax_t offset = 0;
85
+
86
+ /* Let's track number of bytes since last timeout reset in data handler */
87
+ unsigned int received_bytes_per_timeout = 0;
88
+
89
+ /* Current state (content-length sent, status sent, write called, etc */
90
+ int state = 0;
87
91
 
88
92
  #ifdef UWS_WITH_PROXY
89
- ProxyParser proxyParser;
93
+ ProxyParser proxyParser;
90
94
  #endif
91
95
  };
92
96
 
93
- }
97
+ } // namespace uWS
94
98
 
95
99
  #endif // UWS_HTTPRESPONSEDATA_H