2022-03-29 16:50:26 -04:00
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// HTTP Implementation.
|
|
|
|
|
//
|
|
|
|
|
// This is a fairly limited implementation of HTTP.
|
|
|
|
|
//
|
|
|
|
|
// It only supports HTTP 1.1
|
|
|
|
|
//
|
|
|
|
|
// It only supports GET, POST, and HEAD.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#ifndef HTTP_HPP
|
|
|
|
|
#define HTTP_HPP
|
|
|
|
|
|
|
|
|
|
#include "eng-malloc.hpp"
|
|
|
|
|
#include "wrap-string.hpp"
|
|
|
|
|
#include "wrap-vector.hpp"
|
|
|
|
|
#include "luastack.hpp"
|
|
|
|
|
|
|
|
|
|
class HttpRequest : public eng::nevernew {
|
|
|
|
|
public:
|
|
|
|
|
enum Method { INVALID, GET, POST, HEAD };
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
eng::string host_;
|
|
|
|
|
int port_;
|
|
|
|
|
Method method_;
|
|
|
|
|
eng::string encoded_url_;
|
|
|
|
|
eng::string content_type_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class HttpReply : public eng::nevernew {
|
|
|
|
|
public:
|
|
|
|
|
int error_code_;
|
|
|
|
|
eng::string error_message_;
|
|
|
|
|
eng::string mime_type_;
|
|
|
|
|
eng::string content_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // HTTP_HPP
|