Commit 5b0f3680 authored by octal's avatar octal

Client: now handling server disconnection

parent 20cb334d
......@@ -35,7 +35,9 @@ int main(int argc, char *argv[]) {
resp.then([](Response response) {
std::cout << "Response code = " << response.code() << std::endl;
std::cout << "Response body = " << response.body() << std::endl;
auto body = response.body();
if (!body.empty())
std::cout << "Response body = " << body << std::endl;
}, Async::NoExcept);
std::this_thread::sleep_for(std::chrono::seconds(1));
......
......@@ -284,6 +284,11 @@ Transport::handleIncoming(const std::shared_ptr<Connection>& connection) {
break;
}
else if (bytes == 0) {
if (totalBytes > 0) {
handleResponsePacket(connection, buffer, totalBytes);
}
connections.erase(connection->fd);
connection->close();
break;
}
......@@ -371,6 +376,7 @@ Connection::isConnected() const {
void
Connection::close() {
connectionState_ = NotConnected;
::close(fd);
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment