mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Add a testcase for large response + Connection:close header
This commit is contained in:
parent
031f850b94
commit
60c16934cd
@ -150,6 +150,11 @@ int main()
|
|||||||
return crow::response{os.str()};
|
return crow::response{os.str()};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CROW_ROUTE(app, "/large")
|
||||||
|
([]{
|
||||||
|
return std::string(512*1024, ' ');
|
||||||
|
});
|
||||||
|
|
||||||
// ignore all log
|
// ignore all log
|
||||||
crow::logger::setLogLevel(crow::LogLevel::DEBUG);
|
crow::logger::setLogLevel(crow::LogLevel::DEBUG);
|
||||||
//crow::logger::setHandler(std::make_shared<ExampleLogHandler>());
|
//crow::logger::setHandler(std::make_shared<ExampleLogHandler>());
|
||||||
|
@ -18,11 +18,27 @@ for i in xrange(10):
|
|||||||
Host: localhost\r\n\r\n''');
|
Host: localhost\r\n\r\n''');
|
||||||
assert 'Hello World!' in s.recv(1024)
|
assert 'Hello World!' in s.recv(1024)
|
||||||
|
|
||||||
|
# test large
|
||||||
|
s = socket.socket()
|
||||||
|
s.connect(('localhost', 18080))
|
||||||
|
s.send('''GET /large HTTP/1.1
|
||||||
|
Host: localhost\r\nConnection: close\r\n\r\n''')
|
||||||
|
r = ''
|
||||||
|
while True:
|
||||||
|
d = s.recv(1024*1024)
|
||||||
|
if not d:
|
||||||
|
break;
|
||||||
|
r += d
|
||||||
|
print len(r), len(d)
|
||||||
|
print len(r), r[:100]
|
||||||
|
assert len(r) > 512*1024
|
||||||
|
|
||||||
# test timeout
|
# test timeout
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
s.connect(('localhost', 18080))
|
s.connect(('localhost', 18080))
|
||||||
print 'ERROR REQUEST'
|
# invalid request, connection will be closed after timeout
|
||||||
s.send('''GET / HTTP/1.1
|
s.send('''GET / HTTP/1.1
|
||||||
hHhHHefhwjkefhklwejfklwejf
|
hHhHHefhwjkefhklwejfklwejf
|
||||||
''')
|
''')
|
||||||
print s.recv(1024)
|
print s.recv(1024)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user