opal-up 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/up_ext/App.h +665 -544
- data/ext/up_ext/AsyncSocket.h +307 -284
- data/ext/up_ext/AsyncSocketData.h +35 -51
- data/ext/up_ext/BloomFilter.h +37 -42
- data/ext/up_ext/ChunkedEncoding.h +174 -175
- data/ext/up_ext/ClientApp.h +20 -23
- data/ext/up_ext/HttpContext.h +476 -381
- data/ext/up_ext/HttpContextData.h +20 -20
- data/ext/up_ext/HttpErrors.h +14 -10
- data/ext/up_ext/HttpParser.h +631 -563
- data/ext/up_ext/HttpResponse.h +526 -460
- data/ext/up_ext/HttpResponseData.h +59 -55
- data/ext/up_ext/HttpRouter.h +328 -310
- data/ext/up_ext/Loop.h +174 -168
- data/ext/up_ext/LoopData.h +60 -67
- data/ext/up_ext/MoveOnlyFunction.h +71 -80
- data/ext/up_ext/PerMessageDeflate.h +218 -198
- data/ext/up_ext/ProxyParser.h +100 -99
- data/ext/up_ext/QueryParser.h +91 -84
- data/ext/up_ext/TopicTree.h +273 -268
- data/ext/up_ext/Utilities.h +25 -25
- data/ext/up_ext/WebSocket.h +376 -310
- data/ext/up_ext/WebSocketContext.h +487 -372
- data/ext/up_ext/WebSocketContextData.h +74 -62
- data/ext/up_ext/WebSocketData.h +53 -46
- data/ext/up_ext/WebSocketExtensions.h +194 -178
- data/ext/up_ext/WebSocketHandshake.h +115 -110
- data/ext/up_ext/WebSocketProtocol.h +441 -398
- data/ext/up_ext/up_ext.c +43 -5
- data/lib/up/ruby/cluster.rb +29 -6
- data/lib/up/version.rb +1 -1
- metadata +2 -2
@@ -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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
47
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
93
|
+
ProxyParser proxyParser;
|
90
94
|
#endif
|
91
95
|
};
|
92
96
|
|
93
|
-
}
|
97
|
+
} // namespace uWS
|
94
98
|
|
95
99
|
#endif // UWS_HTTPRESPONSEDATA_H
|