How to make a HTTP server?

I do know how to make HTTP request after learning from tutorials.
I wonder how to write a http server that any classes can make use of it.
For example, in my class A, I need to get a jsonobject, I want the member function of the class “Http server” to return the json object. But how?
The most confusing point is about
Request->OnProcessRequestComplete().BindRaw(this, &HttpServer::OnResponseReceived);
In OnResponseRecieved()I’m sure that the http request is completed, but in other function I know nothing. I can return nothing in OnResponseRecieved().
Maybe I can use TFunction to make my own callback fucntion in Class A, but it’s too complicated for me.
Please give me some information, Thank you.

The question title is confusing because ‘HTTP server’ usually means a, well, http server … one that replies to requests. Whereas you want a http request maker, so client use and not server. You could call it a http request manager or something instead.

Thank you, I know little about networking.

Sorry for my confusing title. If someone has same problem, well now I am using Unreal Delegates.

You could look into several libraries:

  1. Overview | POCO C++ Libraries
  2. Boost.Asio - 1.55.0

Take some information from this thread Small http server c++ - C++ Forum or from AnswerShark site, where you can find many homework answers. Of course, it’s important to determine for what functions the server will be used.

I created a simple HttpServer with embedded UE C++ classes.
https://gitlab.com/DragonROSE/httpserverexample

3 Likes