Skip to content

Commit b968776

Browse files
committed
Support http sync client cancel request
1 parent 9308d5e commit b968776

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

http/client/HttpClient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ static int http_client_exec(http_client_t* cli, HttpRequest* req, HttpResponse*
345345
if (left_time != INFINITE) {
346346
so_sndtimeo(cli->fd, left_time);
347347
}
348+
if (req->cancel) goto disconnect;
348349
nsend = http_client_send_data(cli, data + total_nsend, len - total_nsend);
350+
if (req->cancel) goto disconnect;
349351
if (nsend <= 0) {
350352
CHECK_TIMEOUT
351353
err = socket_errno();
@@ -368,7 +370,9 @@ static int http_client_exec(http_client_t* cli, HttpRequest* req, HttpResponse*
368370
if (left_time != INFINITE) {
369371
so_rcvtimeo(cli->fd, left_time);
370372
}
373+
if (req->cancel) goto disconnect;
371374
nrecv = http_client_recv_data(cli, recvbuf, sizeof(recvbuf));
375+
if (req->cancel) goto disconnect;
372376
if (nrecv <= 0) {
373377
CHECK_TIMEOUT
374378
err = socket_errno();

0 commit comments

Comments
 (0)