Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Add support for UPnP-defined HTTP request methods. #345

Merged
2 commits merged into from
Nov 17, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static Persistent<String> report_sym;
static Persistent<String> mkactivity_sym;
static Persistent<String> checkout_sym;
static Persistent<String> merge_sym;
static Persistent<String> msearch_sym;
static Persistent<String> notify_sym;
static Persistent<String> subscribe_sym;
static Persistent<String> unsubscribe_sym;
static Persistent<String> unknown_method_sym;

static Persistent<String> method_sym;
Expand Down Expand Up @@ -138,6 +142,10 @@ method_to_str(unsigned short m) {
case HTTP_MKACTIVITY: return mkactivity_sym;
case HTTP_CHECKOUT: return checkout_sym;
case HTTP_MERGE: return merge_sym;
case HTTP_MSEARCH: return msearch_sym;
case HTTP_NOTIFY: return notify_sym;
case HTTP_SUBSCRIBE: return subscribe_sym;
case HTTP_UNSUBSCRIBE:return unsubscribe_sym;
default: return unknown_method_sym;
}
}
Expand Down Expand Up @@ -462,6 +470,10 @@ void InitHttpParser(Handle<Object> target) {
mkactivity_sym = NODE_PSYMBOL("MKACTIVITY");
checkout_sym = NODE_PSYMBOL("CHECKOUT");
merge_sym = NODE_PSYMBOL("MERGE");
msearch_sym = NODE_PSYMBOL("M-SEARCH");
notify_sym = NODE_PSYMBOL("NOTIFY");
subscribe_sym = NODE_PSYMBOL("SUBSCRIBE");
unsubscribe_sym = NODE_PSYMBOL("UNSUBSCRIBE");
unknown_method_sym = NODE_PSYMBOL("UNKNOWN_METHOD");

method_sym = NODE_PSYMBOL("method");
Expand Down
30 changes: 30 additions & 0 deletions test/simple/test-http-msearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
common = require("../common");
assert = common.assert;
net = require('net');
http = require('http');

server = http.createServer(function (req, res) {
assert.equal(req.method, "M-SEARCH");
assert.equal(req.url, "*");

res.writeHead(200, { Connection : 'close' });
res.end();
});
server.listen(common.PORT, function () {

stream = net.createConnection(common.PORT);
body = "";
stream.setEncoding("ascii");
stream.on("data", function (chunk) { body += chunk; });
stream.on("end", function () {
server.close();
});
stream.write(
'M-SEARCH * HTTP/1.1\r\n'+
'HOST: 239.255.255.250:1900\r\n'+
'MAN: "ssdp:discover"\r\n'+
'MX: 3\r\n'+
'ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\n'+
'\r\n'
);
});