I have run into some trouble with the HttpRequest->OnProcessRequestComplete function when I test my project in HTML5.
The PostRequest function works just fine (because the data is logged in the database table) but the RequestComplete function doesn’t seem to fire.
Everything works fine in the dekstop builds. (UE 4.7.4 - binary, emscripten 1.29.0)
Could this be a bug or am I missing something?
PostRequest Functionality
void UConnection::PostRequest(UObject* WorldContextObject)
{
TSharedRef<IHttpRequest> HttpRequest = FHttpModule::Get().CreateRequest();
HttpRequest->SetVerb(TEXT("POST"));
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
HttpRequest->SetURL("url");
HttpRequest->SetContentAsString(TEXT("text"));
HttpRequest->OnProcessRequestComplete().BindUObject(this, &UConnection::RequestComplete);
HttpRequest->ProcessRequest();
}
RequestComplete Functionality
void UConnection::RequestComplete(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (!bWasSuccessful)
{
UE_LOG(ConnectionLog, Error, TEXT("Request unsuccessful, check the url"));
return;
}
Content = Response->GetContentAsString();
UE_LOG(ConnectionLog, Log, TEXT("Content: %s"), *Content);
}