Minor changes
This commit is contained in:
parent
b1a91fb923
commit
c12e026e0e
1 changed files with 7 additions and 7 deletions
|
|
@ -71,8 +71,8 @@ namespace SimpleWeb {
|
||||||
std::vector<resource_type::iterator> all_resources;
|
std::vector<resource_type::iterator> all_resources;
|
||||||
|
|
||||||
ServerBase(unsigned short port, size_t num_threads, size_t timeout_request, size_t timeout_send_or_receive) : endpoint(boost::asio::ip::tcp::v4(), port),
|
ServerBase(unsigned short port, size_t num_threads, size_t timeout_request, size_t timeout_send_or_receive) : endpoint(boost::asio::ip::tcp::v4(), port),
|
||||||
acceptor(m_io_service, endpoint), num_threads(num_threads), timeout_request(timeout_request),
|
acceptor(m_io_service, endpoint), num_threads(num_threads), timeout_request(timeout_request),
|
||||||
timeout_content(timeout_send_or_receive) {}
|
timeout_content(timeout_send_or_receive) {}
|
||||||
|
|
||||||
virtual void accept()=0;
|
virtual void accept()=0;
|
||||||
|
|
||||||
|
|
@ -111,8 +111,8 @@ namespace SimpleWeb {
|
||||||
|
|
||||||
boost::asio::async_read(*socket, *read_buffer,
|
boost::asio::async_read(*socket, *read_buffer,
|
||||||
boost::asio::transfer_exactly(stoull(request->header["Content-Length"])-num_additional_bytes),
|
boost::asio::transfer_exactly(stoull(request->header["Content-Length"])-num_additional_bytes),
|
||||||
[this, socket, read_buffer, request, timer](const boost::system::error_code& ec,
|
[this, socket, read_buffer, request, timer]
|
||||||
size_t bytes_transferred) {
|
(const boost::system::error_code& ec, size_t bytes_transferred) {
|
||||||
timer->cancel();
|
timer->cancel();
|
||||||
if(!ec) {
|
if(!ec) {
|
||||||
//Store pointer to read_buffer as istream object
|
//Store pointer to read_buffer as istream object
|
||||||
|
|
@ -180,8 +180,8 @@ namespace SimpleWeb {
|
||||||
|
|
||||||
//Capture write_buffer in lambda so it is not destroyed before async_write is finished
|
//Capture write_buffer in lambda so it is not destroyed before async_write is finished
|
||||||
boost::asio::async_write(*socket, *write_buffer,
|
boost::asio::async_write(*socket, *write_buffer,
|
||||||
[this, socket, request, write_buffer, timer](const boost::system::error_code& ec,
|
[this, socket, request, write_buffer, timer]
|
||||||
size_t bytes_transferred) {
|
(const boost::system::error_code& ec, size_t bytes_transferred) {
|
||||||
timer->cancel();
|
timer->cancel();
|
||||||
//HTTP persistent connection (HTTP 1.1):
|
//HTTP persistent connection (HTTP 1.1):
|
||||||
if(!ec && stof(request->http_version)>1.05)
|
if(!ec && stof(request->http_version)>1.05)
|
||||||
|
|
@ -203,7 +203,7 @@ namespace SimpleWeb {
|
||||||
class Server<HTTP> : public ServerBase<HTTP> {
|
class Server<HTTP> : public ServerBase<HTTP> {
|
||||||
public:
|
public:
|
||||||
Server(unsigned short port, size_t num_threads=1, size_t timeout_request=5, size_t timeout_content=300) :
|
Server(unsigned short port, size_t num_threads=1, size_t timeout_request=5, size_t timeout_content=300) :
|
||||||
ServerBase<HTTP>::ServerBase(port, num_threads, timeout_request, timeout_content) {};
|
ServerBase<HTTP>::ServerBase(port, num_threads, timeout_request, timeout_content) {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void accept() {
|
void accept() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue