Reusable HTTP Request

Reusable HTTP client.

I’m using the HTTP(experimental) plugin inside blueprints and have to setup each request to have user agent, token, and many other repetitive things.

I’d like to put all this into some sort of reusable client with functions like login, get character, etc… pass in endpoint and get back the status code and response body, but you can’t use events in functions inside blueprints.

void UHttpRequestProxyObject::ProcessRequest(
	const FString& InUrl,
	const FString& InVerb,
	FHttpHeader&& InHeader,
	const FString& InBody)
{
	FHttpModule& HttpModule = FHttpModule::Get();
	const TSharedRef<IHttpRequest> Request = HttpModule.CreateRequest();
	Request->SetURL(InUrl);
	Request->SetVerb(InVerb);
	Request->SetContentAsString(InBody);
	InHeader.AssignHeadersToRequest(Request);
	Request->ProcessRequest();

	Request->OnProcessRequestComplete().BindUObject(this, &ThisClass::ProcessComplete);
}

void UHttpRequestProxyObject::ProcessComplete(FHttpRequestPtr InRequest, FHttpResponsePtr InResponse, bool bInSuccessful)
{
	OnRequestComplete.Broadcast(InResponse->GetContentAsString(), bInSuccessful, MoveTemp(CachedHeader));
}

Looking at the code above I don’t see a way to make a request without the use of events, which cannot be used in blueprints.