Files
ppsspp/net/http_client.h
T
Kovensky b17119f2c6 Fixes for compatibility with FreeBSD
backtrace.cpp assumes that anything non-windows is linux.

stb_vorbis.c includes malloc.h which has been deprecated since the 90s
on all implementations other than MSVC.

The stat64 hack in file_util.cpp is only needed on linux.

http_client.h also assumes non-windows is linux.
2012-11-18 21:41:44 -03:00

71 lines
1.2 KiB
C++

#ifndef _NET_HTTP_HTTP_CLIENT
#define _NET_HTTP_HTTP_CLIENT
#include "base/basictypes.h"
#include "base/buffer.h"
#ifdef _WIN32
#include <winsock2.h>
#else
#ifdef __FreeBSD__
#include <netinet/in.h>
#else
#include <arpa/inet.h>
#endif
#include <sys/socket.h>
#endif
namespace net {
class Connection {
public:
Connection();
virtual ~Connection();
// Inits the sockaddr_in.
bool Resolve(const char *host, int port);
void Connect();
void Disconnect();
// Disconnects, and connects. Doesn't re-resolve.
void Reconnect();
// Only to be used for bring-up and debugging.
uintptr_t sock() const { return sock_; }
protected:
// Store the remote host here, so we can send it along through HTTP/1.1 requests.
// TODO: Move to http::client?
std::string host_;
int port_;
sockaddr_in remote_;
private:
uintptr_t sock_;
};
} // namespace net
namespace http {
class Client : public net::Connection {
public:
Client();
~Client();
void GET(const char *resource, Buffer *output);
// Return value is the HTTP return code.
int POST(const char *resource, const std::string &data, Buffer *output);
// HEAD, PUT, DELETE aren't implemented yet.
};
} // http
#endif // _NET_HTTP_HTTP_CLIENT