本文整理汇总了C++中FHttpResponsePtr::GetAllHeaders方法的典型用法代码示例。如果您正苦于以下问题:C++ FHttpResponsePtr::GetAllHeaders方法的具体用法?C++ FHttpResponsePtr::GetAllHeaders怎么用?C++ FHttpResponsePtr::GetAllHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FHttpResponsePtr
的用法示例。
在下文中一共展示了FHttpResponsePtr::GetAllHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnProcessRequestComplete
void USIOJRequestJSON::OnProcessRequestComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
// Be sure that we have no data from previous response
ResetResponseData();
// Check we have a response and save response code as int32
if(Response.IsValid())
{
ResponseCode = Response->GetResponseCode();
}
// Check we have result to process futher
if (!bWasSuccessful || !Response.IsValid())
{
UE_LOG(LogSIOJ, Error, TEXT("Request failed (%d): %s"), ResponseCode, *Request->GetURL());
// Broadcast the result event
OnRequestFail.Broadcast(this);
OnStaticRequestFail.Broadcast(this);
return;
}
// Save response data as a string
ResponseContent = Response->GetContentAsString();
// Log response state
UE_LOG(LogSIOJ, Log, TEXT("Response (%d): %s"), ResponseCode, *ResponseContent);
// Process response headers
TArray<FString> Headers = Response->GetAllHeaders();
for (FString Header : Headers)
{
FString Key;
FString Value;
if (Header.Split(TEXT(": "), &Key, &Value))
{
ResponseHeaders.Add(Key, Value);
}
}
// Try to deserialize data to JSON
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(ResponseContent);
FJsonSerializer::Deserialize(JsonReader, ResponseJsonObj->GetRootObject());
// Decide whether the request was successful
bIsValidJsonResponse = bWasSuccessful && ResponseJsonObj->GetRootObject().IsValid();
// Log errors
if (!bIsValidJsonResponse)
{
if (!ResponseJsonObj->GetRootObject().IsValid())
{
// As we assume it's recommended way to use current class, but not the only one,
// it will be the warning instead of error
UE_LOG(LogSIOJ, Warning, TEXT("JSON could not be decoded!"));
}
}
// Broadcast the result event
OnRequestComplete.Broadcast(this);
OnStaticRequestComplete.Broadcast(this);
// Finish the latent action
if (ContinueAction)
{
FSIOJLatentAction<USIOJsonObject*> *K = ContinueAction;
ContinueAction = nullptr;
K->Call(ResponseJsonObj);
}
}