Skip to content

Commit af4821e

Browse files
committed
Changed chunked request test script
1 parent 80eb53b commit af4821e

File tree

2 files changed

+17
-78
lines changed

2 files changed

+17
-78
lines changed

cgi/client.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#include <sstream>
1010
#include <vector>
1111

12+
void write(int fd, std::string data) {
13+
::write(fd, data.c_str(), data.size());
14+
std::cout << data;
15+
}
16+
1217
int main(int, char **, char **) {
1318
int fd;
1419

@@ -27,30 +32,35 @@ int main(int, char **, char **) {
2732
}
2833
std::cout << "connected to: 127.0.0.1:8080" << std::endl;
2934
std::string msg;
30-
msg += "POST /dump.php HTTP/1.1\r\n";
35+
msg += "POST /listing/cgi/dump.php HTTP/1.1\r\n";
3136
msg += "Host: 127.0.0.1\r\n";
3237
msg += "Transfer-Encoding: chunked\r\n";
33-
msg += "Content-Type: application/x-www-form-urlencoded\r\n";
3438
msg += "\r\n";
3539

3640
std::vector<std::string> body;
3741
body.push_back("hello=world");
3842
body.push_back("&bla=blup");
3943
body.push_back("&newline=some text with a newline\r\nin the middle");
44+
45+
std::vector<std::string> trailer;
46+
trailer.push_back("Content-Type: application/x-www-form-urlencoded\r\n");
47+
trailer.push_back("Connection: close\r\n");
4048
// body.push_back("does it\r\n");
4149
// body.push_back("work ???????????????????????????????????");
4250

43-
write(fd, msg.c_str(), msg.size());
51+
write(fd, msg.c_str());
4452

4553
for (size_t i = 0; i < body.size(); ++i) {
4654
std::stringstream ss;
4755
ss << std::hex << body[i].size() << "\r\n";
4856
std::string size(ss.str());
49-
write(fd, size.c_str(), size.size());
50-
write(fd, body[i].c_str(), body[i].size());
51-
write(fd, "\r\n", 2);
57+
write(fd, size);
58+
write(fd, body[i]);
59+
write(fd, "\r\n");
5260
}
53-
write(fd, "0\r\n\r\n", 5);
61+
write(fd, "0\r\n", 3);
62+
for (size_t i = 0; i < trailer.size(); ++i) write(fd, trailer[i]);
63+
write(fd, "\r\n");
5464
char c;
5565
while (read(fd, &c, 1) == 1) {
5666
std::cout << c;

websites/config_test/listing/chunkClient.cpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)