passenger 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/NEWS +9 -0
- data/bin/passenger-install-nginx-module +1 -1
- data/build/basics.rb +0 -1
- data/build/cxx_tests.rb +5 -0
- data/build/rpm.rb +1 -1
- data/doc/Users guide Apache.html +1 -1
- data/doc/Users guide Nginx.html +1 -1
- data/ext/apache2/Configuration.cpp +12 -0
- data/ext/apache2/Configuration.hpp +12 -1
- data/ext/apache2/Hooks.cpp +2 -0
- data/ext/common/AgentsStarter.cpp +4 -0
- data/ext/common/AgentsStarter.h +2 -0
- data/ext/common/AgentsStarter.hpp +4 -0
- data/ext/common/Constants.h +1 -1
- data/ext/common/Logging.h +481 -261
- data/ext/common/LoggingAgent/LoggingServer.h +10 -4
- data/ext/common/LoggingAgent/Main.cpp +7 -2
- data/ext/common/LoggingAgent/RemoteSender.h +25 -3
- data/ext/common/MessageChannel.h +18 -227
- data/ext/common/MessageClient.h +95 -92
- data/ext/common/Utils/IOUtils.cpp +114 -1
- data/ext/common/Utils/IOUtils.h +57 -1
- data/ext/common/Utils/MessageIO.h +576 -0
- data/ext/nginx/Configuration.c +35 -0
- data/ext/nginx/Configuration.h +2 -0
- data/ext/nginx/ContentHandler.c +17 -6
- data/ext/nginx/ngx_http_passenger_module.c +8 -0
- data/lib/phusion_passenger.rb +2 -2
- data/lib/phusion_passenger/analytics_logger.rb +174 -117
- data/lib/phusion_passenger/app_process.rb +14 -2
- data/test/cxx/CxxTestMain.cpp +14 -19
- data/test/cxx/IOUtilsTest.cpp +68 -18
- data/test/cxx/LoggingTest.cpp +20 -24
- data/test/cxx/MessageChannelTest.cpp +1 -1
- data/test/cxx/MessageIOTest.cpp +310 -0
- data/test/cxx/TestSupport.cpp +47 -0
- data/test/cxx/TestSupport.h +8 -0
- data/test/ruby/analytics_logger_spec.rb +20 -28
- data/test/tut/tut.h +2 -0
- metadata +11 -11
- data/build/rdoctask.rb +0 -209
- data/test/cxx/HttpStatusExtractorTest.cpp +0 -198
@@ -1,198 +0,0 @@
|
|
1
|
-
#include "TestSupport.h"
|
2
|
-
#include "HttpStatusExtractor.h"
|
3
|
-
|
4
|
-
using namespace Passenger;
|
5
|
-
using namespace std;
|
6
|
-
|
7
|
-
namespace tut {
|
8
|
-
struct HttpStatusExtractorTest {
|
9
|
-
HttpStatusExtractor ex;
|
10
|
-
};
|
11
|
-
|
12
|
-
DEFINE_TEST_GROUP(HttpStatusExtractorTest);
|
13
|
-
|
14
|
-
/* TODO:
|
15
|
-
* "\r\n" in this test file should really be replaced with "\x0D\x0A".
|
16
|
-
* So far I haven't countered a platform on which "\r\n" is not equal
|
17
|
-
* to "\x0D\x0A" but the possibility that they're not equal exists.
|
18
|
-
*/
|
19
|
-
|
20
|
-
TEST_METHOD(1) {
|
21
|
-
// Status defaults to "200 OK" and buffer is initially empty.
|
22
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
23
|
-
ensure_equals(ex.getBuffer(), "");
|
24
|
-
}
|
25
|
-
|
26
|
-
TEST_METHOD(2) {
|
27
|
-
// Test feeding an entire HTTP response (header + body)
|
28
|
-
// in 1 pass. The first header is the status line.
|
29
|
-
const char data[] =
|
30
|
-
"Status: 201 OK\r\n"
|
31
|
-
"Content-Type: text/html\r\n"
|
32
|
-
"\r\n"
|
33
|
-
"hello world!";
|
34
|
-
ensure("Parsing completed.", ex.feed(data, sizeof(data) - 1));
|
35
|
-
ensure_equals("Status was properly extracted.",
|
36
|
-
ex.getStatusLine(), "201 OK\r\n");
|
37
|
-
ensure_equals("All data that we've fed so far has been buffered.",
|
38
|
-
ex.getBuffer(), data);
|
39
|
-
}
|
40
|
-
|
41
|
-
TEST_METHOD(3) {
|
42
|
-
// Test feeding a single byte initially, and the
|
43
|
-
// rest of the status line later.
|
44
|
-
ensure("Parsing is not complete.", !ex.feed("S", 1));
|
45
|
-
ensure_equals("Status line hasn't changed.",
|
46
|
-
ex.getStatusLine(), "200 OK\r\n");
|
47
|
-
ensure_equals("All data that we've fed so far has been buffered.",
|
48
|
-
ex.getBuffer(), "S");
|
49
|
-
|
50
|
-
const char data2[] = "tatus: 300 Abc\r\n";
|
51
|
-
ensure("Parsing not yet complete.", !ex.feed(data2, sizeof(data2) - 1));
|
52
|
-
|
53
|
-
// Parsing completes when full header has been fed.
|
54
|
-
ensure("Parsing is complete.", ex.feed("\r\n", 2));
|
55
|
-
ensure_equals("Status line recognized.",
|
56
|
-
ex.getStatusLine(), "300 Abc\r\n");
|
57
|
-
ensure_equals("All data that we've fed so far has been buffered.",
|
58
|
-
ex.getBuffer(), "Status: 300 Abc\r\n\r\n");
|
59
|
-
}
|
60
|
-
|
61
|
-
TEST_METHOD(4) {
|
62
|
-
// Test feeding an incomplete non-status line, which
|
63
|
-
// is completed later. The status line is feeded later.
|
64
|
-
const char data[] = "Content-Type: text/html";
|
65
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
66
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
67
|
-
ensure_equals(ex.getBuffer(), data);
|
68
|
-
|
69
|
-
const char data2[] = "\r\nStatus: 201 Hello\r\n\r\n";
|
70
|
-
ensure(ex.feed(data2, sizeof(data2) - 1));
|
71
|
-
ensure_equals(ex.getStatusLine(), "201 Hello\r\n");
|
72
|
-
ensure_equals(ex.getBuffer(),
|
73
|
-
"Content-Type: text/html\r\n"
|
74
|
-
"Status: 201 Hello\r\n"
|
75
|
-
"\r\n");
|
76
|
-
}
|
77
|
-
|
78
|
-
TEST_METHOD(5) {
|
79
|
-
// Test feeding multiple complete lines, none of which
|
80
|
-
// is the status line. The status line is feeded later.
|
81
|
-
const char data[] =
|
82
|
-
"Content-Type: text/html\r\n"
|
83
|
-
"Foo: bar\r\n";
|
84
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
85
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
86
|
-
ensure_equals(ex.getBuffer(), data);
|
87
|
-
|
88
|
-
const char data2[] = "Status: 404 Not Found\r\n";
|
89
|
-
ensure(!ex.feed(data2, sizeof(data2) - 1));
|
90
|
-
|
91
|
-
// Parsing completes when full header has been fed.
|
92
|
-
ensure(ex.feed("\r\n", 2));
|
93
|
-
ensure_equals(ex.getStatusLine(), "404 Not Found\r\n");
|
94
|
-
ensure_equals(ex.getBuffer(), string(data) + data2 + "\r\n");
|
95
|
-
}
|
96
|
-
|
97
|
-
TEST_METHOD(6) {
|
98
|
-
// Test feeding multiple complete lines and a single incomplete line,
|
99
|
-
// none of which is the status line. The header is completed
|
100
|
-
// later, but without status line.
|
101
|
-
const char data[] =
|
102
|
-
"Content-Type: text/html\r\n"
|
103
|
-
"Hello: world";
|
104
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
105
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
106
|
-
ensure_equals(ex.getBuffer(), data);
|
107
|
-
|
108
|
-
const char data2[] = "\r\n\r\nbody data";
|
109
|
-
ensure(ex.feed(data2, sizeof(data2) - 1));
|
110
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
111
|
-
ensure_equals(ex.getBuffer(), string(data) + data2);
|
112
|
-
}
|
113
|
-
|
114
|
-
TEST_METHOD(7) {
|
115
|
-
// Test feeding an incomplete status line which is larger
|
116
|
-
// than 3 bytes, which is completed later.
|
117
|
-
const char data[] = "Status: 500 Internal Se";
|
118
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
119
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
120
|
-
ensure_equals(ex.getBuffer(), data);
|
121
|
-
|
122
|
-
const char data2[] = "rver Error\r\n\r\n";
|
123
|
-
ensure(ex.feed(data2, sizeof(data2) - 1));
|
124
|
-
ensure_equals(ex.getStatusLine(), "500 Internal Server Error\r\n");
|
125
|
-
ensure_equals(ex.getBuffer(), string(data) + data2);
|
126
|
-
}
|
127
|
-
|
128
|
-
TEST_METHOD(8) {
|
129
|
-
// Test feeding an entire HTTP response (header + body)
|
130
|
-
// in 1 pass. There is a status line, but it is NOT the first
|
131
|
-
// header.
|
132
|
-
const char data[] =
|
133
|
-
"Content-Type: text/html\r\n"
|
134
|
-
"Status: 405 Testing\r\n"
|
135
|
-
"Hello: world\r\n"
|
136
|
-
"\r\n"
|
137
|
-
"bla bla";
|
138
|
-
ensure(ex.feed(data, sizeof(data) - 1));
|
139
|
-
ensure_equals(ex.getStatusLine(), "405 Testing\r\n");
|
140
|
-
ensure_equals(ex.getBuffer(), data);
|
141
|
-
}
|
142
|
-
|
143
|
-
TEST_METHOD(9) {
|
144
|
-
// Test feeding multiple complete lines and a single incomplete
|
145
|
-
// line. One of the complete lines is the status line, but it
|
146
|
-
// is not the first line.
|
147
|
-
// The response is completed later.
|
148
|
-
const char data[] =
|
149
|
-
"Content-Type: text/html\r\n"
|
150
|
-
"Status: 100 Foo\r\n"
|
151
|
-
"B";
|
152
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
153
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
154
|
-
ensure_equals(ex.getBuffer(), data);
|
155
|
-
|
156
|
-
const char data2[] = "la: bla\r\n\r\n";
|
157
|
-
ensure(ex.feed(data2, sizeof(data2) - 1));
|
158
|
-
ensure_equals(ex.getStatusLine(), "100 Foo\r\n");
|
159
|
-
ensure_equals(ex.getBuffer(), string(data) + data2);
|
160
|
-
}
|
161
|
-
|
162
|
-
TEST_METHOD(10) {
|
163
|
-
// Test feeding multiple complete lines and a single
|
164
|
-
// incomplete status line. The response is completed
|
165
|
-
// later
|
166
|
-
const char data[] =
|
167
|
-
"Content-Type: text/html\r\n"
|
168
|
-
"Statu";
|
169
|
-
ensure(!ex.feed(data, sizeof(data) - 1));
|
170
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
171
|
-
ensure_equals(ex.getBuffer(), data);
|
172
|
-
|
173
|
-
const char data2[] =
|
174
|
-
"s: 202 Blabla\r\n"
|
175
|
-
"Frobnicate: true\r\n"
|
176
|
-
"\r\n";
|
177
|
-
ensure(ex.feed(data2, sizeof(data2) - 1));
|
178
|
-
ensure_equals(ex.getStatusLine(), "202 Blabla\r\n");
|
179
|
-
ensure_equals(ex.getBuffer(), string(data) + data2);
|
180
|
-
}
|
181
|
-
|
182
|
-
TEST_METHOD(11) {
|
183
|
-
// If the status in the HTTP data doesn't contain a status text,
|
184
|
-
// then the status text is added.
|
185
|
-
const char data[] = "Status: 200\r\n\r\n";
|
186
|
-
ensure(ex.feed(data, sizeof(data) - 1));
|
187
|
-
ensure_equals(ex.getStatusLine(), "200 OK\r\n");
|
188
|
-
}
|
189
|
-
|
190
|
-
TEST_METHOD(12) {
|
191
|
-
// If the status in the HTTP data doesn't contain a status text,
|
192
|
-
// and the status code is not recognized, then the status text
|
193
|
-
// "Unknown Status Code" is added.
|
194
|
-
const char data[] = "Status: 999\r\n\r\n";
|
195
|
-
ensure(ex.feed(data, sizeof(data) - 1));
|
196
|
-
ensure_equals(ex.getStatusLine(), "999 Unknown Status Code\r\n");
|
197
|
-
}
|
198
|
-
}
|