2018-01-08 16:22:45 +01:00
|
|
|
#pragma region Copyright (c) 2014-2018 OpenRCT2 Developers
|
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
|
|
|
|
2018-06-11 11:18:41 +02:00
|
|
|
#pragma once
|
2018-01-08 16:22:45 +01:00
|
|
|
|
|
|
|
#ifndef DISABLE_HTTP
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "../common.h"
|
|
|
|
|
2018-06-11 11:18:41 +02:00
|
|
|
namespace OpenRCT2::Network::Http
|
2018-01-08 16:22:45 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
enum class Status
|
|
|
|
{
|
|
|
|
OK = 200
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Method
|
|
|
|
{
|
|
|
|
GET,
|
|
|
|
POST,
|
|
|
|
PUT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Response
|
|
|
|
{
|
|
|
|
Status status;
|
|
|
|
std::string content_type;
|
2018-06-11 11:18:41 +02:00
|
|
|
std::string body = "";
|
|
|
|
std::map<std::string, std::string> header = {};
|
|
|
|
std::string error = "";
|
2018-01-08 16:22:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Request
|
|
|
|
{
|
|
|
|
std::string url;
|
2018-06-11 11:18:41 +02:00
|
|
|
std::map<std::string, std::string> header = {};
|
|
|
|
Method method = Method::GET;
|
|
|
|
std::string body = "";
|
|
|
|
bool forceIPv4 = false;
|
2018-01-08 16:22:45 +01:00
|
|
|
};
|
|
|
|
|
2018-06-11 11:18:41 +02:00
|
|
|
struct Http
|
2018-01-08 16:22:45 +01:00
|
|
|
{
|
2018-06-11 11:18:41 +02:00
|
|
|
Http();
|
|
|
|
~Http();
|
2018-01-08 16:22:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Response Do(const Request & req);
|
|
|
|
void DoAsync(const Request & req, std::function<void(Response & res)> fn);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Download a park via HTTP/S from the given URL into a memory buffer. This is
|
|
|
|
* a blocking operation.
|
|
|
|
* @param url The URL to download the park from.
|
|
|
|
* @param outData The data returned.
|
|
|
|
* @returns The size of the data or 0 if the download failed.
|
|
|
|
*/
|
2018-06-11 11:18:41 +02:00
|
|
|
size_t DownloadPark(const char * url, void ** outData);
|
2018-01-08 16:22:45 +01:00
|
|
|
|
|
|
|
} /* namespace http */
|
|
|
|
|
|
|
|
#endif // DISABLE_HTTP
|