mirror of
https://github.com/storytold/RuntimeFilesDownloader.git
synced 2026-10-09 00:09:42 +00:00
Fix content-length zero error
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
"BlacklistPlatforms": [
|
||||
"XboxOne",
|
||||
"PS4",
|
||||
"HTML5",
|
||||
"TVOS",
|
||||
"Switch"
|
||||
]
|
||||
|
||||
+8
-3
@@ -30,10 +30,11 @@ URuntimeFilesDownloaderLibrary* URuntimeFilesDownloaderLibrary::DownloadFile(con
|
||||
FileUrl = URL;
|
||||
FileSavePath = SavePath;
|
||||
|
||||
TSharedRef< IHttpRequest, ESPMode::ThreadSafe > HttpRequest = FHttpModule::Get().CreateRequest();
|
||||
TSharedRef< IHttpRequest > HttpRequest = FHttpModule::Get().CreateRequest();
|
||||
|
||||
HttpRequest->SetVerb("GET");
|
||||
HttpRequest->SetURL(URL);
|
||||
HttpRequest->SetHeader("Content-Type", TEXT("application/octet-stream"));
|
||||
HttpRequest->OnProcessRequestComplete().BindUObject(this, &URuntimeFilesDownloaderLibrary::OnReady_Internal);
|
||||
HttpRequest->OnRequestProgress().BindUObject(this, &URuntimeFilesDownloaderLibrary::OnProgress_Internal);
|
||||
|
||||
@@ -46,8 +47,12 @@ URuntimeFilesDownloaderLibrary* URuntimeFilesDownloaderLibrary::DownloadFile(con
|
||||
|
||||
void URuntimeFilesDownloaderLibrary::OnProgress_Internal(FHttpRequestPtr Request, int32 BytesSent, int32 BytesReceived)
|
||||
{
|
||||
int32 FullSize = Request->GetContentLength();
|
||||
OnProgress.Broadcast(BytesSent, BytesReceived, FullSize);
|
||||
FHttpResponsePtr Response = Request->GetResponse();
|
||||
if (Response.IsValid())
|
||||
{
|
||||
int32 FullSize = Response->GetContentLength();
|
||||
OnProgress.Broadcast(BytesSent, BytesReceived, FullSize);
|
||||
}
|
||||
}
|
||||
|
||||
void URuntimeFilesDownloaderLibrary::OnReady_Internal(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
|
||||
|
||||
+1
@@ -5,6 +5,7 @@
|
||||
#include "Http.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "HAL/PlatformFilemanager.h"
|
||||
#include "GenericPlatform/GenericPlatformFile.h"
|
||||
#include "RuntimeFilesDownloaderLibrary.generated.h"
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user