Autor Wątek: HTML5 - błąd podczas GET REQUEST  (Przeczytany 589 razy)

Offline Montjet

  • Użytkownik

# Marzec 04, 2018, 19:43:45
Cześć!
Tym razem mam problem z pobraniem zawartości pliku z podanego adresu URL z skompilowanym projektem do HTML5.

Kod cpp:
// Fill out your copyright notice in the Description page of Project Settings.

#include "HttpTest.h"
#include "Engine.h"

// Sets default values
AHttpTest::AHttpTest()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    UE_LOG(LogTemp, Warning, TEXT("Creating WebManager..."));
    PrimaryActorTick.bCanEverTick = true;

    // Get the HTTP module
    m_http = &FHttpModule::Get();
m_http->SetHttpTimeout(600);

}

void AHttpTest::Destroyed()
{
    UE_LOG(LogTemp, Warning, TEXT("Destroying WebManager..."));
}

// Http call
void AHttpTest::GetData()
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Getting  data..."));

TSharedRef<IHttpRequest> Request = m_http->CreateRequest();
Request->OnProcessRequestComplete().BindUObject(this, &AHttpTest::OnResponseReceived);
//Request->OnRequestProgress().BindUObject(this, &)

Request->SetURL("localhost/software/testData");
Request->SetVerb("GET");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->ProcessRequest();


}

// Assigned function on successfull http call
void AHttpTest::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Response received!"));

m_names.Empty();
m_names.Add(FString::FormatAsNumber(Request->GetStatus()));
m_listUpdated.Broadcast(m_urls, m_names);

}

Zwracany kod statusu: 2, co oznacza: "Failed because it was unable to connect (safe to retry) ".
Jakiś pomysł jak to naprawić?

W edytorze wszystko śmiga dobrze.
Próbowałem tez globalne adresy stron.

Offline Mr. Spam

  • Miłośnik przetworów mięsnych