diff options
author | Cam Swords <cam.swords@gmail.com> | 2013-09-23 00:06:58 +1000 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-20 17:55:08 +0400 |
commit | 7ffe2ad6167e193c7eda46a2db31c153e07d97bd (patch) | |
tree | a13887d2ae30fd4ee875f31d190342be88b373f8 /src/node_http_parser.cc | |
parent | a35a2f0192f78c762ed1009025e673cf09862d4d (diff) | |
download | node-new-7ffe2ad6167e193c7eda46a2db31c153e07d97bd.tar.gz |
http: parse the status message in a http response.
Diffstat (limited to 'src/node_http_parser.cc')
-rw-r--r-- | src/node_http_parser.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 37840d85e6..738358be63 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -181,6 +181,7 @@ class Parser : public BaseObject { HTTP_CB(on_message_begin) { num_fields_ = num_values_ = 0; url_.Reset(); + status_message_.Reset(); return 0; } @@ -191,6 +192,12 @@ class Parser : public BaseObject { } + HTTP_DATA_CB(on_status) { + status_message_.Update(at, length); + return 0; + } + + HTTP_DATA_CB(on_header_field) { if (num_fields_ == num_values_) { // start of new field name @@ -259,6 +266,8 @@ class Parser : public BaseObject { if (parser_.type == HTTP_RESPONSE) { message_info->Set(env()->status_code_string(), Integer::New(parser_.status_code, node_isolate)); + message_info->Set(env()->status_message_string(), + status_message_.ToString()); } // VERSION @@ -349,6 +358,7 @@ class Parser : public BaseObject { void Save() { url_.Save(); + status_message_.Save(); for (int i = 0; i < num_fields_; i++) { fields_[i].Save(); @@ -515,6 +525,7 @@ class Parser : public BaseObject { void Init(enum http_parser_type type) { http_parser_init(&parser_, type); url_.Reset(); + status_message_.Reset(); num_fields_ = 0; num_values_ = 0; have_flushed_ = false; @@ -526,6 +537,7 @@ class Parser : public BaseObject { StringPtr fields_[32]; // header fields StringPtr values_[32]; // header values StringPtr url_; + StringPtr status_message_; int num_fields_; int num_values_; bool have_flushed_; @@ -540,6 +552,7 @@ class Parser : public BaseObject { const struct http_parser_settings Parser::settings = { Parser::on_message_begin, Parser::on_url, + Parser::on_status, Parser::on_header_field, Parser::on_header_value, Parser::on_headers_complete, |