summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 3e88308..7785150 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,6 +61,7 @@ struct tip_client {
int fd;
bool error;
bool redirected;
+ bool server_only;
struct timeval tv_start, tv_last;
const char *payload;
};
@@ -400,7 +401,10 @@ static void tip_client_connect_cb(struct ev_loop *loop, struct ev_io *io, int ev
case TIP_CLIENT_GET_HEADER:
syslog(LOG_INFO, "connected to %s to fetch file %s\n",
inet_ntoa(cli->addr.sin_addr), filename);
- snprintf(buf, sizeof(buf), "GET /%s HTTP/1.1\r\n\r\n", filename);
+ if (cli->server_only)
+ snprintf(buf, sizeof(buf), "GET /%s HTTP/1.1\r\nX-Accept-Redirect: off\r\n\r\n", filename);
+ else
+ snprintf(buf, sizeof(buf), "GET /%s HTTP/1.1\r\n\r\n", filename);
break;
case TIP_CLIENT_HEAD_HEADER:
syslog(LOG_INFO, "connected to %s to get file size of %s\n",
@@ -581,6 +585,19 @@ int main(int argc, char *argv[])
ret = tip_client_request_file(&_cli, addr, filename);
} while (ret > 0);
+ if (ret < 0) {
+ memset(&_cli, 0, sizeof(_cli));
+ _cli.chunk_offset = chunk_size * k;
+ _cli.fd = fd;
+ _cli.server_only = true;
+
+ do {
+ syslog(LOG_INFO, "Requesting file %s to server only\n", filename);
+ _cli.state = TIP_CLIENT_GET_HEADER;
+ ret = tip_client_request_file(&_cli, addr, filename);
+ } while (ret > 0);
+ }
+
if (ret < 0)
goto err_max_retries;