HTTP Request

HTTP GET and POST requests.

Example

#include <r8/core/http-request.h>
#include <r8/core/http-response.h>
using namespace R8;

class MyRequest
   : private Core::IHttpRequestListener
{
public:
   void doRequest() {
      Core::HttpRequest request;
      request.setListener(this);
      request.setMethod(Core::HttpRequest::Method::Get);
      request.setUrl("https://example.com");
      request.setHeader("Content-Type", "application/json");
      request.process();
   }

private:
   void onHttpRequestResponse(const Core::HttpResponse& response) override {
      if (response.error != nullptr) {
         LogError("network error: %s", response.error);
      } else {
         LogInfo("network data: %s", response.content);
      }
   }
}