Report a failure
| 209 | |
| 210 | // Report a failure |
| 211 | void |
| 212 | fail(beast::error_code ec, char const* what) |
| 213 | { |
| 214 | // ssl::error::stream_truncated, also known as an SSL "short read", |
| 215 | // indicates the peer closed the connection without performing the |
| 216 | // required closing handshake (for example, Google does this to |
| 217 | // improve performance). Generally this can be a security issue, |
| 218 | // but if your communication protocol is self-terminated (as |
| 219 | // it is with both HTTP and WebSocket) then you may simply |
| 220 | // ignore the lack of close_notify. |
| 221 | // |
| 222 | // https://github.com/boostorg/beast/issues/38 |
| 223 | // |
| 224 | // https://security.stackexchange.com/questions/91435/how-to-handle-a-malicious-ssl-tls-shutdown |
| 225 | // |
| 226 | // When a short read would cut off the end of an HTTP message, |
| 227 | // Beast returns the error beast::http::error::partial_message. |
| 228 | // Therefore, if we see a short read here, it has occurred |
| 229 | // after the message has been completed, so it is safe to ignore it. |
| 230 | |
| 231 | if(ec == net::ssl::error::stream_truncated) |
| 232 | return; |
| 233 | |
| 234 | std::cerr << what << ": " << ec.message() << "\n"; |
| 235 | } |
| 236 | |
| 237 | // Handles an HTTP server connection |
| 238 | class session |