#ifndef NETWORK_H
#define NETWORK_H
#include <map>
#include "Utils.h"
#include "Url.h"
#include "Namespace.h"
BEGIN_NAMESPACE
typedef uintptr_t SocketId;
class Socket
{
public:
Socket();
~Socket();
bool connect(const String& a_hostName, int a_port);
int send(const String& a_string);
String receive(int a_length);
String receiveAll();
private:
SocketId m_sockfd;
};
enum HttpMethod
{
HM_GET,
HM_PUT,
HM_POST
};
class HttpRequest
{
public:
HttpRequest(const Url& a_url, HttpMethod a_method = HM_GET);
~HttpRequest();
void setHeader(String a_field, String a_value);
String data();
private:
String m_request;
std::map<String,String> m_headers;
};
class Network
{
public:
static String wget(const String& a_url);
};
END_NAMESPACE
#endif // NETWORK_H