From cbcc71db72efb91adf7d7dac275de8ba4e12af0c Mon Sep 17 00:00:00 2001 From: tiptorrent development team Date: Mon, 13 Sep 2021 11:32:21 +0200 Subject: add support for HEAD method --- src/core.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index b018207..c3d4c03 100644 --- a/src/core.c +++ b/src/core.c @@ -48,10 +48,12 @@ static void tip_client_release(struct ev_loop *loop, struct tip_client *cli) free((void *)cli->uri); free((void *)cli->path); - num_clients--; - if (tip_client_large_file(cli)) - tip_client_activate_pending(); + if (cli->method == TIP_METHOD_GET) { + num_clients--; + if (tip_client_large_file(cli)) + tip_client_activate_pending(); + } free(cli); } @@ -161,11 +163,15 @@ static void tip_client_read_cb(struct ev_loop *loop, struct ev_io *io, int event ntohs(cli->addr.sin_port)); goto close; } - - syslog(LOG_INFO, "client %s:%hu starts download for %s\n", - inet_ntoa(cli->addr.sin_addr), - ntohs(cli->addr.sin_port), cli->uri); - + if (cli->method == TIP_METHOD_GET) { + syslog(LOG_INFO, "client %s:%hu starts download for %s\n", + inet_ntoa(cli->addr.sin_addr), + ntohs(cli->addr.sin_port), cli->uri); + } else { + syslog(LOG_INFO, "client %s:%hu checks if %s exists\n", + inet_ntoa(cli->addr.sin_addr), + ntohs(cli->addr.sin_port), cli->uri); + } ev_io_stop(loop, &cli->io); ev_io_set(&cli->io, tip_client_socket(cli), EV_READ | EV_WRITE); ev_io_start(loop, &cli->io); -- cgit v1.2.3-18-g5258