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