x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Work with the HTTP protocol in UE4

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?

Product Version: Not Selected
Tags:
more ▼

asked Aug 12 '14 at 09:49 AM in C++ Programming

avatar image

Ferox
25 6 7 11

avatar image jmietola Aug 12 '14 at 07:51 PM

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.

avatar image Ferox Aug 13 '14 at 07:15 AM

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?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I actually had wrong http.h included so I used this to get it work.

 #include "Runtime/Online/HTTP/Public/Http.h"


,I

more ▼

answered Aug 13 '14 at 08:52 AM

avatar image

jmietola
63 12 8 13

avatar image Ferox Aug 13 '14 at 10:12 AM

What have you wrote in the code to download HTML page from the Internet?

avatar image jmietola Aug 13 '14 at 10:26 AM

I'm currently doing HTTP POST requests only.

avatar image jmietola Aug 13 '14 at 10:28 AM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question