Skip to content

Commit

Permalink
Map Node v0.11's magic numbers for HTTP methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Dec 2, 2013
1 parent 6588928 commit 2dff35d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/websocket/driver/http_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var HttpParser = function(type) {
};

this._parser.onHeadersComplete = this._parser[HTTPParser.kOnHeadersComplete] = function(info) {
self.method = info.method;
self.method = (typeof info.method === 'number') ? HttpParser.METHODS[info.method] : info.method;
self.statusCode = info.statusCode;
self.url = info.url;

Expand All @@ -39,6 +39,30 @@ var HttpParser = function(type) {
};
};

HttpParser.METHODS = {
0: 'DELETE',
1: 'GET',
2: 'HEAD',
3: 'POST',
4: 'PUT',
5: 'CONNECT',
6: 'OPTIONS',
7: 'TRACE',
8: 'COPY',
9: 'LOCK',
10: 'MKCOL',
11: 'MOVE',
12: 'PROPFIND',
13: 'PROPPATCH',
14: 'SEARCH',
15: 'UNLOCK',
16: 'REPORT',
17: 'MKACTIVITY',
18: 'CHECKOUT',
19: 'MERGE',
24: 'PATCH'
};

HttpParser.prototype.isComplete = function() {
return this._complete;
};
Expand Down

0 comments on commit 2dff35d

Please sign in to comment.