mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 15:06:33 +01:00
Remove HTTP parser callbacks for fragment, query_string, path.
Instead we're going to just get a single callback for the URI. This can be parsed additionally in javascript using parseuri: http://blog.stevenlevithan.com/archives/parseuri I haven't added that yet, but it will come soon.
This commit is contained in:
parent
91bd3124ad
commit
175223d5d7
@ -131,10 +131,7 @@ HTTPConnection::name (http_parser *parser, const char *buf, size_t len) \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
DEFINE_PARSER_CALLBACK(on_path, ON_PATH_SYMBOL)
|
||||
DEFINE_PARSER_CALLBACK(on_query_string, ON_QUERY_STRING_SYMBOL)
|
||||
DEFINE_PARSER_CALLBACK(on_uri, ON_URI_SYMBOL)
|
||||
DEFINE_PARSER_CALLBACK(on_fragment, ON_FRAGMENT_SYMBOL)
|
||||
DEFINE_PARSER_CALLBACK(on_header_field, ON_HEADER_FIELD_SYMBOL)
|
||||
DEFINE_PARSER_CALLBACK(on_header_value, ON_HEADER_VALUE_SYMBOL)
|
||||
|
||||
@ -275,10 +272,7 @@ HTTPConnection::HTTPConnection (Handle<Object> handle, enum http_parser_type typ
|
||||
{
|
||||
http_parser_init (&parser_, type);
|
||||
parser_.on_message_begin = on_message_begin;
|
||||
parser_.on_path = on_path;
|
||||
parser_.on_query_string = on_query_string;
|
||||
parser_.on_uri = on_uri;
|
||||
parser_.on_fragment = on_fragment;
|
||||
parser_.on_header_field = on_header_field;
|
||||
parser_.on_header_value = on_header_value;
|
||||
parser_.on_headers_complete = on_headers_complete;
|
||||
|
@ -25,10 +25,7 @@ protected:
|
||||
void OnReceive (const void *buf, size_t len);
|
||||
|
||||
static int on_message_begin (http_parser *parser);
|
||||
static int on_path (http_parser *parser, const char *at, size_t length);
|
||||
static int on_query_string (http_parser *parser, const char *at, size_t length);
|
||||
static int on_uri (http_parser *parser, const char *at, size_t length);
|
||||
static int on_fragment (http_parser *parser, const char *at, size_t length);
|
||||
static int on_header_field (http_parser *parser, const char *buf, size_t len);
|
||||
static int on_header_value (http_parser *parser, const char *buf, size_t len);
|
||||
static int on_headers_complete (http_parser *parser);
|
||||
|
@ -211,16 +211,10 @@ node.http.Server = function (RequestHandler, options) {
|
||||
connection.onMessage = function ( ) {
|
||||
var msg = new Message();
|
||||
|
||||
msg.path = "";
|
||||
msg.uri = "";
|
||||
msg.query_string = "";
|
||||
msg.fragment = "";
|
||||
var headers = msg.headers = [];
|
||||
|
||||
this.onPath = function (data) { msg.path += data; return true };
|
||||
this.onURI = function (data) { msg.uri += data; return true };
|
||||
this.onQueryString = function (data) { msg.query_string += data; return true; };
|
||||
this.onFragment = function (data) { msg.fragment += data; return true; };
|
||||
|
||||
var last_was_value = false;
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
fixed = ""
|
||||
for (var i = 0; i < 20*1024; i++) {
|
||||
fixed += "C";
|
||||
}
|
||||
stored = {};
|
||||
new node.http.Server(function (msg) {
|
||||
var commands = msg.path.split("/");
|
||||
var body = "";
|
||||
var commands = msg.uri.split("/");
|
||||
var command = commands[1];
|
||||
var body = "";
|
||||
var arg = commands[2];
|
||||
var status = 200;
|
||||
|
||||
@ -11,16 +16,21 @@ new node.http.Server(function (msg) {
|
||||
var n = parseInt(arg, 10)
|
||||
if (n <= 0)
|
||||
throw "bytes called with n <= 0"
|
||||
for (var i = 0; i < n; i++) {
|
||||
body += "C"
|
||||
if (stored[n] === undefined) {
|
||||
puts("create stored[n]");
|
||||
stored[n] = "";
|
||||
for (var i = 0; i < n; i++) {
|
||||
stored[n] += "C"
|
||||
}
|
||||
}
|
||||
body = stored[n];
|
||||
|
||||
} else if (command == "quit") {
|
||||
msg.connection.server.close();
|
||||
body = "quitting";
|
||||
|
||||
} else if (command == "fixed") {
|
||||
body = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
|
||||
body = fixed;
|
||||
|
||||
} else {
|
||||
status = 404;
|
||||
|
Loading…
Reference in New Issue
Block a user