Minor cleanups
This commit is contained in:
parent
1ae9f69b1f
commit
f39f21b56f
3 changed files with 15 additions and 17 deletions
|
|
@ -412,6 +412,20 @@ namespace SimpleWeb {
|
|||
return connection;
|
||||
}
|
||||
|
||||
std::pair<std::string, unsigned short> parse_host_port(const std::string &host_port, unsigned short default_port) const noexcept {
|
||||
std::pair<std::string, unsigned short> parsed_host_port;
|
||||
std::size_t host_end = host_port.find(':');
|
||||
if(host_end == std::string::npos) {
|
||||
parsed_host_port.first = host_port;
|
||||
parsed_host_port.second = default_port;
|
||||
}
|
||||
else {
|
||||
parsed_host_port.first = host_port.substr(0, host_end);
|
||||
parsed_host_port.second = static_cast<unsigned short>(stoul(host_port.substr(host_end + 1)));
|
||||
}
|
||||
return parsed_host_port;
|
||||
}
|
||||
|
||||
virtual std::shared_ptr<Connection> create_connection() noexcept = 0;
|
||||
virtual void connect(const std::shared_ptr<Session> &) = 0;
|
||||
|
||||
|
|
@ -434,20 +448,6 @@ namespace SimpleWeb {
|
|||
return streambuf;
|
||||
}
|
||||
|
||||
std::pair<std::string, unsigned short> parse_host_port(const std::string &host_port, unsigned short default_port) const noexcept {
|
||||
std::pair<std::string, unsigned short> parsed_host_port;
|
||||
std::size_t host_end = host_port.find(':');
|
||||
if(host_end == std::string::npos) {
|
||||
parsed_host_port.first = host_port;
|
||||
parsed_host_port.second = default_port;
|
||||
}
|
||||
else {
|
||||
parsed_host_port.first = host_port.substr(0, host_end);
|
||||
parsed_host_port.second = static_cast<unsigned short>(stoul(host_port.substr(host_end + 1)));
|
||||
}
|
||||
return parsed_host_port;
|
||||
}
|
||||
|
||||
void write(const std::shared_ptr<Session> &session) {
|
||||
session->connection->set_timeout();
|
||||
asio::async_write(*session->connection->socket, session->request_streambuf->data(), [this, session](const error_code &ec, std::size_t /*bytes_transferred*/) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue