| 1185 | } |
| 1186 | |
| 1187 | Future<Nothing> disconnect(const Option<string>& message = None()) |
| 1188 | { |
| 1189 | Try<Nothing, SocketError> shutdown = socket.shutdown( |
| 1190 | network::Socket::Shutdown::READ_WRITE); |
| 1191 | |
| 1192 | // If a response is still streaming, we send EOF to |
| 1193 | // the decoder in order to fail the pipe reader. |
| 1194 | if (decoder.writingBody()) { |
| 1195 | decoder.decode("", 0); |
| 1196 | } |
| 1197 | |
| 1198 | // Fail any remaining pipelined responses. |
| 1199 | while (!pipeline.empty()) { |
| 1200 | std::get<1>(pipeline.front()).fail( |
| 1201 | message.isSome() ? message.get() : "Disconnected"); |
| 1202 | pipeline.pop(); |
| 1203 | } |
| 1204 | |
| 1205 | disconnection.set(Nothing()); |
| 1206 | |
| 1207 | return shutdown.isSome() ? Future<Nothing>(Nothing()) |
| 1208 | : Failure(shutdown.error().message); |
| 1209 | } |
| 1210 | |
| 1211 | Future<Nothing> disconnected() |
| 1212 | { |