* disconnect * close the TCP socket */
| 365 | * close the TCP socket |
| 366 | */ |
| 367 | void HTTPClient::disconnect(bool preserveClient) { |
| 368 | if (connected()) { |
| 369 | if (_client->available() > 0) { |
| 370 | log_d("still data in buffer (%d), clean up.\n", _client->available()); |
| 371 | _client->clear(); |
| 372 | } |
| 373 | |
| 374 | if (_reuse && _canReuse) { |
| 375 | log_d("tcp keep open for reuse"); |
| 376 | } else { |
| 377 | log_d("tcp stop"); |
| 378 | _client->stop(); |
| 379 | if (!preserveClient) { |
| 380 | _client = nullptr; |
| 381 | #ifdef HTTPCLIENT_1_1_COMPATIBLE |
| 382 | if (_tcpDeprecated) { |
| 383 | _transportTraits.reset(nullptr); |
| 384 | _tcpDeprecated.reset(nullptr); |
| 385 | } |
| 386 | #endif |
| 387 | } |
| 388 | } |
| 389 | } else { |
| 390 | log_d("tcp is closed\n"); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * connected |