Samuel Kahn 9ab3463144
[cpp-ue4] Added UE4.26 support, (#8964)
* [cpp-ue4] Fixed enum values not being quoted. I'm not sure when this started breaking.

* [cpp-ue4] UE 4.26 Compatibility: Replaced TSharedRef<IHttpRequest by FHttpRequestRef for better portability

* [cpp-ue4] Improved DateTime parsing

* [cpp-ue4] Made HttpFileInput constructors explicit

* [cpp-ue4] Added the possibility to retry requests easily with AsyncRetry method on the response and SetAutoRetryCount on the request

WIP auto retry

[cpp-ue4] Adds support for instant retry

* [cpp-ue4] Using TaskGraph instead of TaskGraphMainThread for async retries

* update samples

* remove trailing spaces

Co-authored-by: Jean-Noel Gourdol <jngourdol@stormancer.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
2021-03-17 17:50:42 +08:00

40 lines
1.4 KiB
C++

/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* https://github.com/OpenAPITools/openapi-generator
* Do not edit the class manually.
*/
#include "OpenAPIBaseModel.h"
#include "Async/Async.h"
namespace OpenAPI
{
void Response::SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode)
{
ResponseCode = InHttpResponseCode;
SetSuccessful(EHttpResponseCodes::IsOk(InHttpResponseCode));
if(InHttpResponseCode == EHttpResponseCodes::RequestTimeout)
{
SetResponseString(TEXT("Request Timeout"));
}
}
void Response::AsyncRetry() const
{
// Unfortunately, it is currently usafe to call ProcessRequest() directly here.
// This is because the HttpManager will remove all references to this HttpRequest in FHttpManager::Tick including the new request we just added, instead of removing just one.
// This will lead to the request's destruction and eventually a crash.
// The only solution is therefore to ensure we are taking an extra reference to the request, and that the request is added after the queue is flushed.
Async(EAsyncExecution::TaskGraph, [AddRef = FHttpRequestPtr(GetHttpRequest())](){ AddRef->ProcessRequest(); });
}
}