HTTP now automatically encodes jsonvalue content
This commit is contained in:
@@ -97,6 +97,7 @@ public:
|
||||
void set_url(LuaStack &LS, LuaSlot val);
|
||||
void set_mime_type(LuaStack &LS, LuaSlot val);
|
||||
void set_content(LuaStack &LS, LuaSlot val);
|
||||
void set_jsonvalue(LuaStack &LS, LuaSlot val);
|
||||
|
||||
// Set default values for method and port.
|
||||
// This must be done after setting regular values.
|
||||
@@ -126,6 +127,10 @@ public:
|
||||
//
|
||||
eng::string check() const;
|
||||
|
||||
// Get the method.
|
||||
//
|
||||
eng::string method() const { return method_; }
|
||||
|
||||
// Put the request into the stream, assuming HTTP/1.1
|
||||
//
|
||||
void send(StreamBuffer *target) const { send_internal(target, false); }
|
||||
@@ -186,6 +191,7 @@ public:
|
||||
//
|
||||
HttpServerResponse();
|
||||
|
||||
void set_method(const eng::string &method);
|
||||
void set_status(int status);
|
||||
void set_max_age(int max_age);
|
||||
void set_mime_type(const eng::string &mime_type);
|
||||
@@ -195,6 +201,7 @@ public:
|
||||
void set_max_age(LuaStack &LS, LuaSlot val);
|
||||
void set_mime_type(LuaStack &LS, LuaSlot val);
|
||||
void set_content(LuaStack &LS, LuaSlot val);
|
||||
void set_jsonvalue(LuaStack &LS, LuaSlot val);
|
||||
|
||||
// Set default values.
|
||||
//
|
||||
@@ -275,7 +282,7 @@ protected:
|
||||
// The protocol: true for HTTP/1.1, false for HTTP/1.0
|
||||
bool http11_;
|
||||
|
||||
// The method: always "GET". (only when parsing requests)
|
||||
// The method. In a response, this is assigned before parsing.
|
||||
eng::string method_;
|
||||
|
||||
// The URL path, not url-encoded. (only when parsing requests)
|
||||
@@ -383,7 +390,7 @@ public:
|
||||
|
||||
// The parser will not try to parse content longer than this.
|
||||
//
|
||||
const int64_t MAX_CONTENT_LENGTH = 1000000;
|
||||
static constexpr int64_t MAX_CONTENT_LENGTH = 1000000;
|
||||
|
||||
// Parse a request or a response.
|
||||
//
|
||||
@@ -391,7 +398,7 @@ public:
|
||||
// construct a new parser.
|
||||
//
|
||||
void parse_request(std::string_view view, bool closed);
|
||||
void parse_response(std::string_view view, bool closed);
|
||||
void parse_response(std::string_view view, bool closed, std::string_view method);
|
||||
|
||||
// Store a status code and an error message, and clear the content.
|
||||
// This is generally used when the client detects an error,
|
||||
@@ -428,6 +435,7 @@ using HttpParserVec = eng::vector<HttpParser>;
|
||||
class HttpChannel {
|
||||
public:
|
||||
SharedChannel channel_;
|
||||
eng::string method_;
|
||||
int64_t parsed_bytes_;
|
||||
|
||||
bool marked_for_deletion() const { return channel_ == nullptr; }
|
||||
|
||||
Reference in New Issue
Block a user