Ferox (Ferox) 1 How do I download code page from the Internet using HTTP.
UObject* WorldContextObject; UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject); UServerLoader* obj = (UServerLoader*)StaticConstructObject(UServerLoader::StaticClass()); TSharedRef< IHttpRequest > HttpRequest = FHttpModule::Get().CreateRequest(); HttpRequest->SetVerb("GET"); HttpRequest->SetURL(FString("http://example.com")); HttpRequest->OnProcessRequestComplete().BindUObject(obj, [](FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { if (!bWasSuccessful) { UE_LOG(LogTemp, Error, TEXT("Response was invalid! Please check the URL.")); return; } FString responseData = Response->GetContentAsString(); }); HttpRequest->ProcessRequest();
This code produces the error. What am I doing wrong?
jmietola (jmietola) 2 This is a bit off-topic but how did you managed to get HTTP work? I get FHttpModule is undefined eventhough I added these two line in Project.Build.cs
PrivateDependencyModuleNames.AddRange(new string[] { "HTTP" }); PrivateIncludePathModuleNames.AddRange(new string[] { "HTTP" });
and of course included http.h.
Ferox (Ferox) 3 I also included http.h and added HTTP module and I were errors during compilation. How can I get the HTML source of page with this module?
jmietola (jmietola) 4 I actually had wrong http.h included so I used this to get it work.
#include "Runtime/Online/HTTP/Public/Http.h"
,I
Ferox (Ferox) 5 What have you wrote in the code to download HTML page from the Internet?
jmietola (jmietola) 6 I’m currently doing HTTP POST requests only.
jmietola (jmietola) 7 Trying to follow the
UE4与WEB服务器交互(json)