I m new to HTTP, and developing an applicative proxy. I want to avoid defining timeouts for operations, and instead rely on the the client to close the connection. I m wondering if this is possible?
这里有一个非常哑哑的假代码
void handle_request(Request http_request, Response http_response)
{
string modified_request = parse(http_request);
response_from_server = remote_server->send_request(modified_request);
while(true) {
if(response_from_server ->wait_for_data(1000 /* milliseconds */)) {
http_response->write_data(response_from_server->read_data());
continue;
}
if(!http_response.check_if_the_client_connection_to_me_is_still_active()) // how to do this?
return;
}
}
}
另一种问法是:
- in an HTTP proxy, can I use the timeouts from the remote cilent and the remote server without adding yet another timeout?
- how do I detect that either the remote server or remote client have timed-out?
顺便说一句,我在C++使用Poco开发。