本文整理汇总了C++中FHttpResponsePtr::GetContent方法的典型用法代码示例。如果您正苦于以下问题:C++ FHttpResponsePtr::GetContent方法的具体用法?C++ FHttpResponsePtr::GetContent怎么用?C++ FHttpResponsePtr::GetContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FHttpResponsePtr
的用法示例。
在下文中一共展示了FHttpResponsePtr::GetContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HttpDownloadHeaderFinished
void FHttpNetworkReplayStreamer::HttpDownloadHeaderFinished( FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded )
{
check( HttpState == EHttptate::DownloadingHeader );
check( StreamerState == EStreamerState::NeedToDownloadHeader );
check( StreamArchive.IsLoading() );
HttpState = EHttptate::Idle;
if ( bSucceeded && HttpResponse->GetResponseCode() == EHttpResponseCodes::Ok )
{
HeaderArchive.Buffer.Append( HttpResponse->GetContent() );
UE_LOG( LogHttpReplay, Log, TEXT( "FHttpNetworkReplayStreamer::HttpDownloadHeaderFinished. Size: %i" ), HeaderArchive.Buffer.Num() );
StartStreamingDelegate.ExecuteIfBound( true, StreamArchive.IsSaving() );
StreamerState = EStreamerState::StreamingDown;
}
else
{
// FAIL
UE_LOG( LogHttpReplay, Error, TEXT( "FHttpNetworkReplayStreamer::HttpDownloadHeaderFinished. FAILED." ) );
StreamArchive.Buffer.Empty();
StartStreamingDelegate.ExecuteIfBound( false, StreamArchive.IsSaving() );
SetLastError( ENetworkReplayError::ServiceUnavailable );
}
// Reset delegate
StartStreamingDelegate = FOnStreamReadyDelegate();
}
示例2: DownloadAsset_Response
void FSimplygonRESTClient::DownloadAsset_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!Response.IsValid())
{
SwarmTask->SetState(SRS_FAILED);
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
TArray<uint8> data = Response->GetContent();
if (!FFileHelper::SaveArrayToFile(data, *SwarmTask->OutputFilename))
{
UE_LOG(LogSimplygonRESTClient, Log, TEXT("Unable to save file %S"), *SwarmTask->OutputFilename);
SwarmTask->SetState(SRS_FAILED);
}
else
{
SwarmTask->OnAssetDownloaded().ExecuteIfBound(*SwarmTask);
SwarmTask->SetState(SRS_ASSETDOWNLOADED);
UE_LOG(LogSimplygonRESTClient, Log, TEXT("Asset downloaded"));
}
}
else
{
SwarmTask->SetState(SRS_FAILED);
UE_LOG(LogSimplygonRESTClient, Warning, TEXT("Response: %i"), Response->GetResponseCode());
}
}
示例3: HttpDownloadFinished
void FHttpNetworkReplayStreamer::HttpDownloadFinished( FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded )
{
check( HttpState == EHttptate::DownloadingStream );
check( StreamArchive.IsLoading() );
HttpState = EHttptate::Idle;
if ( bSucceeded && HttpResponse->GetResponseCode() == EHttpResponseCodes::Ok )
{
FString NumChunksString = HttpResponse->GetHeader( TEXT( "NumChunks" ) );
FString DemoTimeString = HttpResponse->GetHeader( TEXT( "Time" ) );
FString State = HttpResponse->GetHeader( TEXT( "State" ) );
bStreamIsLive = State == TEXT( "Live" );
NumDownloadChunks = FCString::Atoi( *NumChunksString );
DemoTimeInMS = FCString::Atoi( *DemoTimeString );
if ( HttpResponse->GetContent().Num() > 0 || bStreamIsLive )
{
if ( HttpResponse->GetContent().Num() > 0 )
{
StreamArchive.Buffer.Append( HttpResponse->GetContent() );
StreamFileCount++;
}
UE_LOG( LogHttpReplay, Verbose, TEXT( "FHttpNetworkReplayStreamer::HttpDownloadFinished. State: %s, Progress: %i / %i, DemoTime: %2.2f" ), *State, StreamFileCount, NumDownloadChunks, (float)DemoTimeInMS / 1000 );
}
else
{
UE_LOG( LogHttpReplay, Error, TEXT( "FHttpNetworkReplayStreamer::HttpDownloadFinished. FAILED." ) );
StreamArchive.Buffer.Empty();
SetLastError( ENetworkReplayError::ServiceUnavailable );
}
}
else
{
UE_LOG( LogHttpReplay, Error, TEXT( "FHttpNetworkReplayStreamer::HttpDownloadFinished. FAILED." ) );
StreamArchive.Buffer.Empty();
SetLastError( ENetworkReplayError::ServiceUnavailable );
}
}
示例4: ReadFile_HttpRequestComplete
void FSurveyTitleCdnStorage::ReadFile_HttpRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
bool bResult = false;
FString ResponseStr, ErrorStr;
// should have a pending Http request
FPendingFileRequest PendingRequest = FileRequests.FindChecked(HttpRequest.Get());
FileRequests.Remove(HttpRequest.Get());
// Cloud file being operated on
FCloudFile* CloudFile = GetCloudFile(PendingRequest.FileName, true);
CloudFile->AsyncState = EOnlineAsyncTaskState::Failed;
CloudFile->Data.Empty();
if (bSucceeded &&
HttpResponse.IsValid())
{
if (EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
UE_LOG(LogEpicSurvey, Verbose, TEXT("ReadFile request complete. url=%s code=%d"),
*HttpRequest->GetURL(), HttpResponse->GetResponseCode());
// update the memory copy of the file with data that was just downloaded
CloudFile = GetCloudFile(PendingRequest.FileName, true);
CloudFile->AsyncState = EOnlineAsyncTaskState::Done;
CloudFile->Data = HttpResponse->GetContent();
// cache to disk on successful download
SaveCloudFileToDisk(CloudFile->FileName,CloudFile->Data);
bResult = true;
}
else
{
ErrorStr = FString::Printf(TEXT("Invalid response. code=%d error=%s"),
HttpResponse->GetResponseCode(), *HttpResponse->GetContentAsString());
}
}
else
{
ErrorStr = TEXT("No response");
}
if (!ErrorStr.IsEmpty())
{
UE_LOG(LogEpicSurvey, Verbose, TEXT("ReadFile request failed. %s"), *ErrorStr);
}
TriggerOnReadFileCompleteDelegates(bResult, PendingRequest.FileName);
}
示例5: GetAnalyticsName
void FHttpServiceTracker::EndpointMetrics::TrackRequest(const FHttpRequestPtr& HttpRequest)
{
if(HttpRequest.IsValid())
{
// keep a histogram of response codes
const FHttpResponsePtr HttpResponse = HttpRequest->GetResponse();
const int32 ResponseCode = HttpResponse.IsValid() ? HttpResponse->GetResponseCode() : 0;
// track all responses in a histogram
ResponseCodes.FindOrAdd(ResponseCode)++;
const float ElapsedTime = HttpRequest->GetElapsedTime();
const int64 DownloadBytes = HttpResponse.IsValid() ? HttpResponse->GetContent().Num() : 0;
// track successes/fails separately
if (IsSuccessfulResponse(ResponseCode))
{
++SuccessCount;
// sum elapsed time for average calc
ElapsedTimeSuccessTotal += ElapsedTime;
ElapsedTimeSuccessMax = FMath::Max(ElapsedTimeSuccessMax, ElapsedTime);
ElapsedTimeSuccessMin = FMath::Min(ElapsedTimeSuccessMin, ElapsedTime);
// sum download rate for average calc
DownloadBytesSuccessTotal += DownloadBytes;
}
else
{
++FailCount;
// sum elapsed time for average calc
ElapsedTimeFailTotal += ElapsedTime;
ElapsedTimeFailMax = FMath::Max(ElapsedTimeFailMax, ElapsedTime);
ElapsedTimeFailMin = FMath::Min(ElapsedTimeFailMin, ElapsedTime);
// sum download rate for average calc
DownloadBytesFailTotal += DownloadBytes;
}
FString AnalyticsName = GetAnalyticsName(HttpRequest->GetURL());
if (LastAnalyticsName.Len() > 0 && AnalyticsName != LastAnalyticsName)
{
UE_LOG(LogAnalytics, Warning, TEXT("Endpoint analytics name has changed from '%s' to '%s', aggregated stats will be incorrect"),
*LastAnalyticsName, *AnalyticsName);
}
LastAnalyticsName = AnalyticsName;
}
}
示例6: OnResponseReceived
void UMasterServerFunctions::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
FString MessageBody = "";
if (!Response.IsValid()) { CurrentRequest.ResponseType = EHttpResponse::HR_NoData; Closed(MessageBody); return; }
if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
if (Response->GetContentType().Equals("application/json"))
{
MessageBody = DecompressBytes(Response->GetContent());
ProcessJSON(MessageBody);
}
}
else
{
MessageBody = FString::Printf(TEXT("{\"success\":\"HTTP Error: %d\"}"), Response->GetResponseCode());
}
Closed(MessageBody);
}
示例7: HandleImageRequest
void UAsyncTaskDownloadImage::HandleImageRequest(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
#if !UE_SERVER
RemoveFromRoot();
if ( bSucceeded && HttpResponse.IsValid() && HttpResponse->GetContentLength() > 0 )
{
IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
IImageWrapperPtr ImageWrappers[3] =
{
ImageWrapperModule.CreateImageWrapper(EImageFormat::PNG),
ImageWrapperModule.CreateImageWrapper(EImageFormat::JPEG),
ImageWrapperModule.CreateImageWrapper(EImageFormat::BMP),
};
for ( auto ImageWrapper : ImageWrappers )
{
if ( ImageWrapper.IsValid() && ImageWrapper->SetCompressed(HttpResponse->GetContent().GetData(), HttpResponse->GetContentLength()) )
{
const TArray<uint8>* RawData = NULL;
if ( ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, RawData) )
{
if ( UTexture2D* Texture = UTexture2D::CreateTransient(ImageWrapper->GetWidth(), ImageWrapper->GetHeight()) )
{
WriteRawToTexture(Texture, *RawData);
OnSuccess.Broadcast(Texture);
return;
}
}
}
}
}
OnFail.Broadcast(nullptr);
#endif
}
示例8: HandleFileRequest
void UBPDownloader::HandleFileRequest(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
RemoveFromRoot();
if (bSucceeded && HttpResponse.IsValid() && HttpResponse->GetContentLength() > 0)
{
TArray<uint8> data = HttpResponse->GetContent();
if (!FFileHelper::SaveArrayToFile(data, *FilePath))
{
OnFail.Broadcast(0.f);
UE_LOG(LogTemp, Warning, TEXT("Unable to save file!"));
}
else
{
OnProgressUpdate.Broadcast(1.f);
UE_LOG(LogTemp, Warning, TEXT("File download completed!"));
}
}
OnFail.Broadcast(0.f);//FilePath
}
示例9: HttpRequestComplete
void HttpRequestComplete( FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
if (HttpResponse.IsValid())
Out.Append(HttpResponse->GetContent());
}