本文整理汇总了C++中FHttpResponsePtr::GetResponseCode方法的典型用法代码示例。如果您正苦于以下问题:C++ FHttpResponsePtr::GetResponseCode方法的具体用法?C++ FHttpResponsePtr::GetResponseCode怎么用?C++ FHttpResponsePtr::GetResponseCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FHttpResponsePtr
的用法示例。
在下文中一共展示了FHttpResponsePtr::GetResponseCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleLightStateRequestComplete
void UPhilipsHueBridge::HandleLightStateRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
FString MessageBody = "";
if (!HttpResponse.IsValid())
{
MessageBody = "{\"success\":\"Error: Unable to process HTTP Request!\"}";
}
else if (EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
MessageBody = HttpResponse->GetContentAsString();
int32 idx = MessageBody.Find("error");
if (idx > 0){
//Send Error;
}
else
{
//Successfully sent!
}
}
else
{
MessageBody = FString::Printf(TEXT("{\"success\":\"HTTP Error: %d\"}"), HttpResponse->GetResponseCode());
}
}
示例2: UploadAsset_Response
void FSimplygonRESTClient::UploadAsset_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!Response.IsValid())
{
SwarmTask->SetState(SRS_FAILED);
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
FString msg = Response->GetContentAsString();
UE_LOG(LogSimplygonRESTClient, Log, TEXT("Upload asset response: %s"), *msg);
TSharedPtr<FJsonObject> JsonParsed;
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(msg);
if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
{
SwarmTask->InputAssetId = JsonParsed->GetStringField("AssetId");
UE_LOG(LogSimplygonRESTClient, Log, TEXT("AssetId: %s"), *SwarmTask->InputAssetId);
}
SwarmTask->SetState(SRS_ASSETUPLOADED);
}
else
{
SwarmTask->SetState(SRS_FAILED);
UE_LOG(LogSimplygonRESTClient, Warning, TEXT("Response: %i"), Response->GetResponseCode());
}
}
示例3: HandleUserIDTestRequestComplete
void UPhilipsHueBridge::HandleUserIDTestRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
FString MessageBody = "";
// If HTTP fails client-side, this will still be called but with a NULL shared pointer!
if (!HttpResponse.IsValid())
{
MessageBody = "{\"success\":\"Error: Unable to process HTTP Request!\"}";
}
else if (EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
MessageBody = HttpResponse->GetContentAsString();
int32 idx = MessageBody.Find("unauthorized user");
if (idx > 0){
//Remind push linking
OnPushLinkRequested.Broadcast(Id);
//AquireUserID(false);
}
else
{
Connected = true;
// Successfully tested the user id
OnHueUserAuthorized.Broadcast(ConnectedUser);
}
}
else
{
MessageBody = FString::Printf(TEXT("{\"success\":\"HTTP Error: %d\"}"), HttpResponse->GetResponseCode());
}
}
示例4: 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());
}
}
示例5: OnAuthResponseComplete
/**
* This is a callback function that is called when the "AttemptAuthentication" function
* has completed its request.
*
* @param Request
* @param Response Contains the data of the response, including the response code.
* @param bWasSuccessful Contains true if the request was successful. Else it contains false.
*
*/
void CloudyWebAPIImpl::OnAuthResponseComplete(FHttpRequestPtr Request,
FHttpResponsePtr Response, bool bWasSuccessful)
{
if (bWasSuccessful)
{
UE_LOG(CloudyWebAPILog, Warning, TEXT("Response Code = %d"), Response->GetResponseCode());
if (!Response.IsValid())
{
UE_LOG(CloudyWebAPILog, Warning, TEXT("Request failed!"));
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(Response->GetContentAsString());
FJsonSerializer::Deserialize(JsonReader, JsonObject);
Token = JsonObject->GetStringField("token");
UE_LOG(CloudyWebAPILog, Warning, TEXT("Token = %s"), *Token);
}
}
else
{
UE_LOG(CloudyWebAPILog, Error, TEXT("Request failed! Is the server up?"));
}
}
示例6: HandleUserIDRequestComplete
void UPhilipsHueBridge::HandleUserIDRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
FString MessageBody = "";
FString userid = "";
// If HTTP fails client-side, this will still be called but with a NULL shared pointer!
if (!HttpResponse.IsValid())
{
MessageBody = "{\"success\":\"Error: Unable to process HTTP Request!\"}";
}
else if (EHttpResponseCodes::IsOk(HttpResponse->GetResponseCode()))
{
MessageBody = HttpResponse->GetContentAsString();
TSharedRef< TJsonReader<> > JsonReader = TJsonReaderFactory<>::Create(*MessageBody);
int32 idx = MessageBody.Find("\"username\"");
if (idx > 0){
userid = MessageBody.Trim();
userid.RemoveFromStart("[{\"success\":{\"username\":\"");
userid.RemoveFromEnd("\"}}]");
ConnectedUser = userid;
SaveUserIDToFile();
OnHueUserAuthorized.Broadcast(userid);
}
else
{
OnPushLinkRequested.Broadcast(Id);
}
}
else
{
MessageBody = FString::Printf(TEXT("{\"success\":\"HTTP Error: %d\"}"), HttpResponse->GetResponseCode());
}
}
示例7: 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);
}
示例8:
bool FHttpRetrySystem::FManager::ShouldRetry(const FHttpRetryRequestEntry& HttpRetryRequestEntry)
{
bool bResult = false;
FHttpResponsePtr Response = HttpRetryRequestEntry.HttpRequest->GetResponse();
if (!Response.IsValid() ||
Response->GetResponseCode() == 0 ||
HttpRetryRequestEntry.HttpRequest->RetryResponseCodesOverride.Contains(Response->GetResponseCode()) ||
RetryResponseCodesDefault.Contains(Response->GetResponseCode()))
{
bResult = true;
}
return bResult;
}
示例9: HttpUploadFinished
void FHttpNetworkReplayStreamer::HttpUploadFinished( FHttpRequestPtr , FHttpResponsePtr HttpResponse, bool bSucceeded )
{
check( HttpState == EHttptate::UploadingStream );
check( StreamerState == EStreamerState::StreamingUp || StreamerState == EStreamerState::StreamingUpFinal );
HttpState = EHttptate::Idle;
if ( bSucceeded && HttpResponse->GetResponseCode() == EHttpResponseCodes::Ok )
{
UE_LOG( LogHttpReplay, Verbose, TEXT( "FHttpNetworkReplayStreamer::HttpUploadFinished." ) );
if ( StreamerState == EStreamerState::StreamingUpFinal )
{
// Create the Http request and add to pending request list
TSharedRef<class IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->OnProcessRequestComplete().BindRaw( this, &FHttpNetworkReplayStreamer::HttpStopUploadingFinished );
HttpState = EHttptate::StopUploading;
HttpRequest->SetURL( FString::Printf( TEXT( "%sstopuploading?Version=%s&Session=%s&NumChunks=%i&Time=%i" ), *ServerURL, *SessionVersion, *SessionName, StreamFileCount, DemoTimeInMS ) );
HttpRequest->SetVerb( TEXT( "POST" ) );
HttpRequest->SetHeader( TEXT( "Content-Type" ), TEXT( "application/octet-stream" ) );
HttpRequest->ProcessRequest();
}
}
else
{
UE_LOG( LogHttpReplay, Error, TEXT( "FHttpNetworkReplayStreamer::HttpUploadFinished. FAILED" ) );
SetLastError( ENetworkReplayError::ServiceUnavailable );
}
}
示例10: 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();
}
示例11: ProcessJob_Response
void FSimplygonRESTClient::ProcessJob_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!Response.IsValid())
{
SwarmTask->SetState(SRS_FAILED);
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
SwarmTask->SetState(SRS_JOBPROCESSING);
}
else
{
SwarmTask->SetState(SRS_FAILED);
UE_LOG(LogSimplygonRESTClient, Warning, TEXT("Process job response: %i"), Response->GetResponseCode());
}
}
示例12: if
bool FHttpRetrySystem::FManager::ShouldRetry(const FHttpRetryRequestEntry& HttpRetryRequestEntry)
{
bool bResult = false;
FHttpResponsePtr Response = HttpRetryRequestEntry.Request->GetResponse();
// invalid response means connection or network error but we need to know which one
if (!Response.IsValid())
{
// ONLY retry bad responses if they are connection errors (NOT protocol errors or unknown) otherwise request may be sent (and processed!) twice
EHttpRequestStatus::Type Status = HttpRetryRequestEntry.Request->GetStatus();
if (Status == EHttpRequestStatus::Failed_ConnectionError)
{
bResult = true;
}
else if (Status == EHttpRequestStatus::Failed)
{
// we will also allow retry for GET and HEAD requests even if they may duplicate on the server
FString Verb = HttpRetryRequestEntry.Request->GetVerb();
if (Verb == TEXT("GET") || Verb == TEXT("HEAD"))
{
bResult = true;
}
}
}
else
{
// this may be a successful response with one of the explicitly listed response codes we want to retry on
if (HttpRetryRequestEntry.Request->RetryResponseCodes.Contains(Response->GetResponseCode()))
{
bResult = true;
}
}
return bResult;
}
示例13: HttpStopUploadingFinished
void FHttpNetworkReplayStreamer::HttpStopUploadingFinished( FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded )
{
check( HttpState == EHttptate::StopUploading );
check( StreamerState == EStreamerState::StreamingUpFinal );
HttpState = EHttptate::Idle;
StreamerState = EStreamerState::Idle;
if ( bSucceeded && HttpResponse->GetResponseCode() == EHttpResponseCodes::Ok )
{
UE_LOG( LogHttpReplay, Log, TEXT( "FHttpNetworkReplayStreamer::HttpStopUploadingFinished. SessionName: %s" ), *SessionName );
}
else
{
UE_LOG( LogHttpReplay, Error, TEXT( "FHttpNetworkReplayStreamer::HttpStopUploadingFinished. FAILED" ) );
SetLastError( ENetworkReplayError::ServiceUnavailable );
}
StreamArchive.ArIsLoading = false;
StreamArchive.ArIsSaving = false;
StreamArchive.Buffer.Empty();
StreamArchive.Pos = 0;
StreamFileCount = 0;
bStopStreamingCalled = false;
SessionName.Empty();
}
示例14:
void FHttpServiceTracker::EndpointMetrics::TrackRequest(const FHttpRequestPtr& HttpRequest)
{
// 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 = HttpRequest->GetResponse()->GetContent().Num();
// 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;
}
}
示例15: AccountInfo_Response
void FSimplygonRESTClient::AccountInfo_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!Response.IsValid())
{
SwarmTask->SetState(SRS_FAILED);
}
else if (EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{
FString msg = Response->GetContentAsString();
UE_LOG(LogSimplygonRESTClient, Log, TEXT("Account info response: %s"), *msg);
}
else
{
SwarmTask->SetState(SRS_FAILED);
UE_LOG(LogSimplygonRESTClient, Warning, TEXT("Account info response: %i"), Response->GetResponseCode());
}
}