From 42db8279986324d7722fb5d7961b09fe6a99b9c1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 28 Dec 2018 01:10:58 +1100 Subject: [PATCH] fix content length for 'do you want to download' overlay --- src/Http.c | 5 ++++- src/Http.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Http.c b/src/Http.c index 73ee82cfd..c48be16e8 100644 --- a/src/Http.c +++ b/src/Http.c @@ -149,6 +149,7 @@ static void Http_SysMakeHeaders(String* headers, struct HttpRequest* req) { /* Creates and sends a http req */ static ReturnCode Http_SysMakeRequest(struct HttpRequest* req, HINTERNET* handle) { struct HttpCacheEntry entry; + const char* verb; DWORD flags; String headers; char headersBuffer[STRING_SIZE * 3]; String path; char pathBuffer[URL_MAX_SIZE + 1]; @@ -166,7 +167,9 @@ static ReturnCode Http_SysMakeRequest(struct HttpRequest* req, HINTERNET* handle flags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD; if (entry.Https) flags |= INTERNET_FLAG_SECURE; - *handle = HttpOpenRequestA(entry.Handle, "GET", pathBuffer, NULL, NULL, NULL, flags, 0); + verb = req->RequestType == REQUEST_TYPE_GET ? "GET" : "HEAD"; + *handle = HttpOpenRequestA(entry.Handle, verb, pathBuffer, NULL, NULL, NULL, flags, 0); + return *handle && HttpSendRequestA(*handle, headers.buffer, headers.length, NULL, 0) ? 0 : GetLastError(); } diff --git a/src/Http.h b/src/Http.h index 8cd2fda30..f02c12244 100644 --- a/src/Http.h +++ b/src/Http.h @@ -24,7 +24,7 @@ enum HttpProgress { struct HttpRequest { char URL[URL_MAX_SIZE]; /* URL data is downloaded from/uploaded to. */ - char ID[STRING_SIZE]; /* Unique identifier for this request. */ + char ID[URL_MAX_SIZE]; /* Unique identifier for this request. */ TimeMS TimeAdded; /* Time this request was added to queue of requests. */ TimeMS TimeDownloaded; /* Time response contents were completely downloaded. */ int StatusCode; /* HTTP status code returned in the response. */