forked from TamLem/Webserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurl_example.cpp
559 lines (495 loc) · 22.1 KB
/
curl_example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
#include <iostream>
#include <string>
#include <curl/curl.h>
// Colors and Printing
#define RESET "\033[0m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define RED "\033[31m"
#define BOLD "\033[1m"
#define UNDERLINED "\033[4m"
#define FILE_LINE (std::string(__FILE__) + std::string(":") + std::to_string(__LINE__))
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
// #include <string.h>
#include <arpa/inet.h>
#define PORT 80
#define NONE -1
#define EMPTY -2
static long nothrow_stol(const std::string& string)
{
long ret;
try {
ret = stol(string);
}
catch (std::exception &e)
{
return (NONE);
}
return (ret);
}
static void evaluation(const std::string& testcase, const std::string& readBuffer, const std::string& expected, long statuscode, const std::string &testLocation)
{
static int i = 1;
std::cout << YELLOW << "Test " << i << ": " << testcase << BLUE << "\tfrom: " << testLocation << RESET << std::endl;
if (readBuffer.compare(expected) == 0)
std::cout << GREEN << "OK" << RESET << std::endl;
else if (nothrow_stol(expected) == statuscode)
std::cout << GREEN << "OK" << RESET << " status code: " << statuscode << std::endl;
else if (readBuffer.find(expected) != std::string::npos)
std::cout << GREEN << "OK" << RESET << " found: " << expected << std::endl;
else
{
std::cout << RED << "KO" << RESET << std::endl;
std::cout << "expected: " << expected << std::endl;
std::cout << "recieved: " << readBuffer << std::endl;
}
i++;
}
static void my_request(const std::string& request, const std::string& expected, const std::string &testLocation)
{
int sock = 0;
long valread;
struct sockaddr_in serv_addr;
char readBuffer[1024] = {0};
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
std::cout << "\n Socket creation error" << std::endl;
return ;
}
memset(&serv_addr, '0', sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
// Convert IPv4 and IPv6 addresses from text to binary form
if(inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)<=0)
{
std::cout << "\nInvalid address/ Address not supported" << std::endl;
return ;
}
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
{
std::cout << "\nConnection Failed" << std::endl;
return ;
}
send(sock, request.c_str(), request.length(), 0);
valread = read( sock , readBuffer, 1024);
evaluation(request.substr(0, request.find_first_of('\n') - 1), readBuffer, expected, EMPTY, testLocation);
}
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
static void curl_delete(const std::string& url, const std::string& expected, const std::string &testLocation)
{
long statuscode;
CURL *curl;
struct curl_slist *host = NULL;
host = curl_slist_append(NULL, "webserv:80:127.0.0.1");
curl_slist_append(host, "webserv:5500:127.0.0.1");
curl_slist_append(host, "server1:6000:127.0.0.1");
curl_slist_append(host, "server2:80:127.0.0.1");
curl_slist_append(host, "server2:8080:127.0.0.1");
curl_slist_append(host, "server2:8081:127.0.0.1");
curl_slist_append(host, "server2:127.0.0.1");
curl_slist_append(host, "nonexistingserver:8080:127.0.0.1");
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statuscode);
res = curl_easy_perform(curl);
if(res == CURLE_OK)
{
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statuscode);
}
curl_easy_cleanup(curl);
evaluation(url, readBuffer, expected, statuscode, testLocation);
}
else
std::cout << RED << "ERROR with curl" << RESET << std::endl;
}
static void curl_post(const std::string& url, const std::string& expected, const std::string &testLocation)
{
long statuscode;
CURL *curl;
struct curl_slist *host = NULL;
host = curl_slist_append(NULL, "webserv:80:127.0.0.1");
curl_slist_append(host, "webserv:5500:127.0.0.1");
curl_slist_append(host, "server1:6000:127.0.0.1");
curl_slist_append(host, "server2:80:127.0.0.1");
curl_slist_append(host, "server2:8080:127.0.0.1");
curl_slist_append(host, "server2:8081:127.0.0.1");
curl_slist_append(host, "server2:127.0.0.1");
curl_slist_append(host, "nonexistingserver:8080:127.0.0.1");
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "This is the content of my new file.");
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
if(res == CURLE_OK)
{
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statuscode);
}
curl_easy_cleanup(curl);
evaluation(url, readBuffer, expected, statuscode, testLocation);
}
else
std::cout << RED << "ERROR with curl" << RESET << std::endl;
}
static void curl_get(const std::string& url, const std::string& expected, const std::string &testLocation)
{
long statuscode;
CURL *curl;
struct curl_slist *host = NULL;
host = curl_slist_append(NULL, "webserv:80:127.0.0.1");
curl_slist_append(host, "webserv:5500:127.0.0.1");
curl_slist_append(host, "server1:6000:127.0.0.1");
curl_slist_append(host, "server2:80:127.0.0.1");
curl_slist_append(host, "server2:8080:127.0.0.1");
curl_slist_append(host, "server2:8081:127.0.0.1");
curl_slist_append(host, "server2:127.0.0.1");
curl_slist_append(host, "nonexistingserver:8080:127.0.0.1");
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
if(res == CURLE_OK)
{
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statuscode);
}
curl_easy_cleanup(curl);
evaluation(url, readBuffer, expected, statuscode, testLocation);
}
else
std::cout << RED << "ERROR with curl" << RESET << std::endl;
}
int main(void)
{
// BAD REQUEST TESTS
std::cout << BLUE << "<<<<<<<<<<<<<<<<<<<<<<INPUT>>>>>>>>>>>>>>>>>>>>>>" << RESET << std::endl;
my_request("GET / HTTP/1.1\r\nHost: webserv\r\n\r\n", "content of index.html in root", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request(" GET / HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost:webserv\r\n\r\n", "content of index.html in root", FILE_LINE);
my_request("GET / HTTP/1.1\r\n Host: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv \r\n\r\n", "content of index.html in root", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv \r\n\r\n", "400", FILE_LINE); // AE only one whitespace
my_request("GET / HTTP/1.1\r\nHost: webserv \r\n\r\n", "400", FILE_LINE); // AE only one whitespace
my_request("GET / HTTP/1.1\r\nHost:webserv \r\n\r\n", "400", FILE_LINE); // AE only one whitespace
my_request("GET / HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE); // AE only one whitespace
my_request("GET / HTTP/1.1\r\nHost : webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET /route/dir/%25file HTTP/1.1\r\nHost: webserv\r\n\r\n", "content of %file in dir", FILE_LINE);
my_request("GET /route/dir/%2myfile HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET /ü-ei HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE); //not encoded
// my_request("", "408", FILE_LINE); // timeout
my_request("\n", "400", FILE_LINE);
my_request(" ", "400", FILE_LINE); // AE problem
my_request("GET . HTTP/1.1\r\nHost: webserv\r\n\r\n", "content of index.html in root", FILE_LINE); // AE garbage
my_request("GET .. HTTP/1.1\r\nHost: webserv\r\n\r\n", "content of index.html in root", FILE_LINE); // AE garbage
my_request("GET ... HTTP/1.1\r\nHost: webserv\r\n\r\n", "404", FILE_LINE); // AE garbage
my_request("GET .../README.md HTTP/1.1\r\nHost: webserv\r\n\r\n", "404", FILE_LINE); // AE ultra dangerous!!!
my_request("GET HTTP/1.1\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET / HTTP/1.0\r\nHost: webserv\r\n\r\n", "505", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv\r\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("GET / HTTP/1.1\r\nHost: webserv\r\ncontent-length: 0\r\ntransfer-encoding: chunked\r\n\r\n", "400", FILE_LINE); // AE is this even imlemented?
my_request("GET / HTTP/1.1\r\nUser-Agent: Go-http-client/1.1\r\n\r\n", "400", FILE_LINE);
// my_request("GET / HTTP/1.1\r\nHost: webserv\r\n\r", "408", FILE_LINE); // timeout
my_request("GET / HTTP/1.1\nHost: webserv\r\n\r\n", "400", FILE_LINE);
my_request("PST / HTTP/1.1\r\nHost: webserv\r\n\r\n", "501", FILE_LINE);
my_request("POST /new.txt HTTP/1.1\r\nHost: webserv\r\n\r\n", "411", FILE_LINE);
my_request("GET 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 HTTP/1.1\r\nHost: webserv\r\n\r\n", "414", FILE_LINE);
my_request("POST /uploads/big.txt HTTP/1.1\r\nHost: webserv\r\ncontent-length: 200\r\n\r\n01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", "413", FILE_LINE);
//////// GET
std::cout << BLUE << "<<<<<<<<<<<<<<<<<<<<<<GET>>>>>>>>>>>>>>>>>>>>>>" << RESET << std::endl;
curl_get("http://webserv", "content of index.html in root", FILE_LINE);
curl_get("http://webserv:80", "content of index.html in root", FILE_LINE);
curl_get("http://webserv/route/lol/", "content of different.html in lol", FILE_LINE);
curl_get("http://webserv/route/lol/troll/", "content of index.html in troll", FILE_LINE);
curl_get("http://webserv:5500", "", FILE_LINE); // can't connect
curl_get("http://webserv/route/dir/file", "content of file in dir", FILE_LINE);
curl_get("http://webserv/route/cgi/file", "content of file in cgi", FILE_LINE);
curl_get("http://server1:6000/route/file", "content of file in server1", FILE_LINE);
curl_get("http://server1:6000/route/doesnotexist", "MY_CUSTOM_PAGE", FILE_LINE);
curl_get("http://server2/route/file", "405", FILE_LINE); // going for default server
curl_get("http://nonexistingserver:8080/route/file", "405", FILE_LINE); // going for default server
curl_get("http://server2:8080/route/file", "content of file in server2", FILE_LINE);
curl_get("http://server2:8081/route/file", "content of file in server2", FILE_LINE);
curl_get("http://webserv/route/dir/file.cgi", "CONTENT OF FILE.CGI IN DIR", FILE_LINE); // only POST triggers cgi, GET only returns file WRONG!
curl_get("http://webserv/route/dir/file.ext", "content of file.ext in extdir", FILE_LINE);
curl_get("http://webserv/route/dir/norfile", "403", FILE_LINE);
curl_get("http://webserv/route/nordir/file", "content of file in nordir", FILE_LINE);
curl_get("http://webserv/route/nowdir/file", "content of file in nowdir", FILE_LINE);
curl_get("http://webserv/route/noxdir/file", "403", FILE_LINE);
curl_get("http://webserv/route/nordir/subdir/file", "content of file in nordirsubdir", FILE_LINE);
curl_get("http://webserv/route/nowdir/subdir/file", "content of file in nowdirsubdir", FILE_LINE);
curl_get("http://webserv/route/noxdir/subdir/file", "403", FILE_LINE);
curl_get("http://webserv/route/dir/nowfile", "content of nowfile in dir", FILE_LINE);
curl_get("http://webserv/route/dir/nonexistingfile", "404", FILE_LINE);
curl_get("http://webserv/route/dir/nonexistingdir/", "404", FILE_LINE);
curl_get("http://webserv/index", "404", FILE_LINE);
curl_get("http://webserv/index/", "content of index.html in index", FILE_LINE);
curl_get("http://webserv/index/custom/", "content of custom_index.html in custom", FILE_LINE);
curl_get("http://webserv/index/no/autoindex/", "autoindex123", FILE_LINE);
curl_get("http://webserv/index/no/autoindex/nopermission/", "403", FILE_LINE);
curl_get("http://webserv/index/no/autoindex/nonexisting/", "404", FILE_LINE);
curl_get("http://webserv/index/no/noautoindex/", "404", FILE_LINE);
//////// POST
std::cout << BLUE << "<<<<<<<<<<<<<<<<<<<<<<POST>>>>>>>>>>>>>>>>>>>>>>" << RESET << std::endl;
curl_post("http://server2:8080/new.txt", "405", FILE_LINE);
curl_post("http://webserv/uploads/new.txt", "201", FILE_LINE);
curl_post("http://webserv/uploads/.ext", "201", FILE_LINE); // not an extension
curl_post("http://webserv/uploads/new.txt", "201", FILE_LINE);
curl_post("http://webserv/uploads/newdir/", "400", FILE_LINE); // create directory is not possible
curl_post("http://webserv/uploads/doesnotexist/new.txt", "404", FILE_LINE); // changed to be 404 instead of 400
curl_post("http://webserv/uploads/cgi/new.txt", "403", FILE_LINE); // 403 because cgi directory has no permissions
curl_post("http://webserv/uploads/new.cgi", "THIS IS THE CONTENT OF MY NEW FILE.", FILE_LINE);
curl_post("http://webserv/uploads/new.cgi", "200", FILE_LINE); // RFC says 201 should only be returned on cration of a ressource, so no reason to return 201 on a cgi POST
curl_post("http://webserv/uploads/file.cgi.not", "201", FILE_LINE);
curl_post("http://webserv/uploads/.cgi", "201", FILE_LINE);
curl_post("http://server1:6000/route/file.cgi", "500", FILE_LINE); //no executepermission for cgi executable
curl_post("http://server2:8080/route/file.cgi", "500", FILE_LINE); //cgi executable doesn't exist
//no cgi executable
// no cgi permission
//////// DELETE
std::cout << BLUE << "<<<<<<<<<<<<<<<<<<<<<<DELETE>>>>>>>>>>>>>>>>>>>>>>" << RESET << std::endl;
curl_delete("http://webserv/uploads/new.txt", "204", FILE_LINE);
curl_delete("http://webserv/uploads/.ext", "204", FILE_LINE);
curl_delete("http://webserv/uploads/newdir/", "204", FILE_LINE); // would have to be created first
curl_delete("http://webserv/uploads/cgi/new.txt", "404", FILE_LINE); // cgi directory has no permissions
curl_delete("http://webserv/uploads/file.cgi.not", "204", FILE_LINE);
curl_delete("http://webserv/uploads/.cgi", "204", FILE_LINE);
curl_delete("http://webserv/uploads/doesnotexist", "404", FILE_LINE);
curl_delete("http://webserv/uploads/nonexisting.cgi", "404", FILE_LINE); // file to call the cgi on is not existing
curl_get("http://webserv/uploads/nopermissionfile.cgi", "403", FILE_LINE); // file to call the cgi on has no permissions
curl_post("http://webserv/uploads/nopermissionfile.cgi", "THIS IS THE CONTENT OF MY NEW FILE.", FILE_LINE); // file to call the cgi on has no permissions
curl_delete("http://webserv/uploads/cgi/nopermissionfile.cgi", "404", FILE_LINE); // has no permissions inside the cgi directory
curl_delete("http://webserv/uploads/todelete.cgi", "204", FILE_LINE);
}
//c++ curl_example.cpp -o curl_example -lcurl && ./curl_example
/*
42teser testcases
_________________________________________________
Test 1 GET http://localhost:8080/
GET / HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 2 POST http://localhost:8080/ with a size of 0
POST / HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
Response:
HTTP/1.1 405 Method Not Allowed
_________________________________________________
Test 3 HEAD http://localhost:8080/
HEAD / HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Response:
HTTP/1.1 405 Method Not Allowed
_________________________________________________
Test 4 GET http://localhost:8080/directory
GET /directory HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 5 GET http://localhost:8080/directory/youpi.bad_extension
GET /directory/youpi.bad_extension HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 6 GET http://localhost:8080/directory/youpi.bla
GET /directory/youpi.bla HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 201 Created
_________________________________________________
Test 7 GET Expected 404 on http://localhost:8080/directory/oulalala
GET /directory/oulalala HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 404 Not Found
_________________________________________________
Test 8 GET http://localhost:8080/directory/nop
GET /directory/nop HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 9 GET http://localhost:8080/directory/nop/
GET /directory/nop/ HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 10 GET http://localhost:8080/directory/nop/other.pouic
GET /directory/nop/other.pouic HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 11 GET Expected 404 on http://localhost:8080/directory/nop/other.pouac
GET /directory/nop/other.pouac HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 404 Not Found
_________________________________________________
Test 12 GET Expected 404 on http://localhost:8080/directory/Yeah
GET /directory/Yeah HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 404 Not Found
_________________________________________________
Test 13 GET http://localhost:8080/directory/Yeah/not_happy.bad_extension
GET /directory/Yeah/not_happy.bad_extension HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
Response:
HTTP/1.1 200 OK
_________________________________________________
Test 14 Put http://localhost:8080/put_test/file_should_exist_after with a size of 1000
PUT /put_test/file_should_exist_after HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Accept-Encoding: gzip
Response:
HTTP/1.1 201 Created
_________________________________________________
Test 15 Put http://localhost:8080/put_test/file_should_exist_after with a size of 10000000
PUT /put_test/file_should_exist_after HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Accept-Encoding: gzip
Response:
HTTP/1.1 201 Created
_________________________________________________
Test 16 POST http://localhost:8080/directory/youpi.bla with a size of 100000000
POST /directory/youpi.bla HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 17 POST http://localhost:8080/directory/youpla.bla with a size of 100000000
POST /directory/youpla.bla HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 18 POST http://localhost:8080/directory/youpi.bla with a size of 100000 with special headers
POST /directory/youpi.bla HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
X-Secret-Header-For-Test: 1
Accept-Encoding: gzip
_________________________________________________
Test 19 POST http://localhost:8080/post_body with a size of 0
POST /post_body HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 20 POST http://localhost:8080/post_body with a size of 100
POST /post_body HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 21 POST http://localhost:8080/post_body with a size of 200
POST /post_body HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 22 POST http://localhost:8080/post_body with a size of 101
POST /post_body HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Content-Type: test/file
Accept-Encoding: gzip
_________________________________________________
Test 23 multiple workers(5) doing multiple times(15): GET on /
GET / HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip
_________________________________________________
Test 24 multiple workers(20) doing multiple times(5000): GET on /
_________________________________________________
Test 25 multiple workers(128) doing multiple times(50): GET on /directory/nop
_________________________________________________
Test 26 multiple workers(20) doing multiple times(5): Put on /put_test/multiple_same with size 1000000
PUT /put_test/multiple_same HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Transfer-Encoding: chunked
Accept-Encoding: gzip
_________________________________________________
Test 27 multiple workers(20) doing multiple times(5): Post on /directory/youpi.bla with size 100000000
*/