Files
UnrealEngineUWP/Engine/Source/Runtime/Online/HTTP/Private/GenericPlatform/HttpRequestImpl.cpp
lorry li 0980390e94 Migrate retry system total timeout for http request, by adding total timeout feature in http request;
Deprecate HttpTimeout config, use HttpActivityTimeout or HttpTotalTimeout instead;
Deprecate HttpSendTimeout config, only use HttpActivityTimeout;
Make HttpActivityTimeout work on all platforms, not only CurlHttp;
Added corresponding http tests;
Now because timeout migrated, enable new flow by default in retry system to have non-game thread support.

#jira UE-197485, UE-202201
[REVIEW] [at]michael.atchison [at]michael.kirzinger [at]rafa.lecina
#rb michael.atchison, Michael.Kirzinger
#tests Tested through WebTests project on all platforms, also tried the game on PC.

[CL 30817277 by lorry li in ue5-main branch]
2024-01-23 16:08:08 -05:00

74 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "GenericPlatform/HttpRequestImpl.h"
#include "Stats/Stats.h"
#include "Http.h"
FHttpRequestCompleteDelegate& FHttpRequestImpl::OnProcessRequestComplete()
{
return RequestCompleteDelegate;
}
PRAGMA_DISABLE_DEPRECATION_WARNINGS
FHttpRequestProgressDelegate& FHttpRequestImpl::OnRequestProgress()
{
return RequestProgressDelegate;
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS
FHttpRequestProgressDelegate64& FHttpRequestImpl::OnRequestProgress64()
{
return RequestProgressDelegate64;
}
FHttpRequestStatusCodeReceivedDelegate& FHttpRequestImpl::OnStatusCodeReceived()
{
return StatusCodeReceivedDelegate;
}
FHttpRequestHeaderReceivedDelegate& FHttpRequestImpl::OnHeaderReceived()
{
return HeaderReceivedDelegate;
}
FHttpRequestWillRetryDelegate& FHttpRequestImpl::OnRequestWillRetry()
{
return OnRequestWillRetryDelegate;
}
void FHttpRequestImpl::Shutdown()
{
OnProcessRequestComplete().Unbind();
PRAGMA_DISABLE_DEPRECATION_WARNINGS
OnRequestProgress().Unbind();
PRAGMA_ENABLE_DEPRECATION_WARNINGS
OnRequestProgress64().Unbind();
OnStatusCodeReceived().Unbind();
OnHeaderReceived().Unbind();
}
void FHttpRequestImpl::BroadcastResponseHeadersReceived()
{
if (OnHeaderReceived().IsBound())
{
const FHttpResponsePtr Response = GetResponse();
if (Response.IsValid())
{
const FHttpRequestPtr ThisPtr(SharedThis(this));
const TArray<FString> AllHeaders = Response->GetAllHeaders();
for (const FString& Header : AllHeaders)
{
FString HeaderName;
FString HeaderValue;
if (Header.Split(TEXT(":"), &HeaderName, &HeaderValue))
{
HeaderValue.TrimStartInline();
QUICK_SCOPE_CYCLE_COUNTER(STAT_FHttpRequestImpl_BroadcastResponseHeadersReceived_OnHeaderReceived);
OnHeaderReceived().ExecuteIfBound(ThisPtr, HeaderName, HeaderValue);
}
}
}
}
}