mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Upgrade http-parser
This commit is contained in:
1 parent
b3349eb33a
commit
c9e21435c0
7 files changed
+137
-118
No files matched your search
+4
-11
@@ -127,13 +127,9 @@ HTTPConnection::OnReceive (const void *buf, size_t len)
|
||||
HandleScope scope;
|
||||
|
||||
assert(refs_);
|
||||
size_t nparsed;
|
||||
size_t nparsed;
|
||||
|
||||
if (type_ == HTTP_REQUEST) {
|
||||
nparsed = http_parse_requests(&parser_, static_cast<const char*>(buf), len);
|
||||
} else {
|
||||
nparsed = http_parse_responses(&parser_, static_cast<const char*>(buf), len);
|
||||
}
|
||||
nparsed = http_parser_execute(&parser_, static_cast<const char*>(buf), len);
|
||||
|
||||
if (nparsed != len) {
|
||||
ForceClose();
|
||||
@@ -145,11 +141,8 @@ HTTPConnection::OnEOF ()
|
||||
{
|
||||
HandleScope scope;
|
||||
assert(refs_);
|
||||
if (type_ == HTTP_REQUEST) {
|
||||
http_parse_requests(&parser_, NULL, 0);
|
||||
} else {
|
||||
http_parse_responses(&parser_, NULL, 0);
|
||||
}
|
||||
size_t nparsed;
|
||||
nparsed = http_parser_execute(&parser_, NULL, 0);
|
||||
Emit(eof_symbol, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
+3
-7
@@ -7,8 +7,6 @@
|
||||
|
||||
namespace node {
|
||||
|
||||
enum http_connection_type { HTTP_RESPONSE, HTTP_REQUEST };
|
||||
|
||||
class HTTPConnection : public Connection {
|
||||
public:
|
||||
static void Initialize (v8::Handle<v8::Object> target);
|
||||
@@ -21,7 +19,7 @@ protected:
|
||||
static v8::Handle<v8::Value> NewServer (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> ResetParser(const v8::Arguments& args);
|
||||
|
||||
HTTPConnection (enum http_connection_type t)
|
||||
HTTPConnection (enum http_parser_type t)
|
||||
: Connection()
|
||||
{
|
||||
type_ = t;
|
||||
@@ -29,7 +27,7 @@ protected:
|
||||
}
|
||||
|
||||
void ResetParser() {
|
||||
http_parser_init (&parser_);
|
||||
http_parser_init (&parser_, type_);
|
||||
parser_.on_message_begin = on_message_begin;
|
||||
parser_.on_url = on_url;
|
||||
parser_.on_path = on_path;
|
||||
@@ -57,10 +55,8 @@ protected:
|
||||
static int on_body (http_parser *parser, const char *buf, size_t len);
|
||||
static int on_message_complete (http_parser *parser);
|
||||
|
||||
enum http_parser_type type_;
|
||||
http_parser parser_;
|
||||
enum http_connection_type type_; // should probably use subclass
|
||||
// but going to refactor this all soon
|
||||
// so won't worry about it.
|
||||
friend class HTTPServer;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user