diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index b99e205041..8922c9ed1a 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -67,6 +67,7 @@ static Persistent put_sym; static Persistent connect_sym; static Persistent options_sym; static Persistent trace_sym; +static Persistent patch_sym; static Persistent copy_sym; static Persistent lock_sym; static Persistent mkcol_sym; @@ -153,6 +154,7 @@ method_to_str(unsigned short m) { case HTTP_CONNECT: return connect_sym; case HTTP_OPTIONS: return options_sym; case HTTP_TRACE: return trace_sym; + case HTTP_PATCH: return patch_sym; case HTTP_COPY: return copy_sym; case HTTP_LOCK: return lock_sym; case HTTP_MKCOL: return mkcol_sym; @@ -400,6 +402,7 @@ void InitHttpParser(Handle target) { connect_sym = NODE_PSYMBOL("CONNECT"); options_sym = NODE_PSYMBOL("OPTIONS"); trace_sym = NODE_PSYMBOL("TRACE"); + patch_sym = NODE_PSYMBOL("PATCH"); copy_sym = NODE_PSYMBOL("COPY"); lock_sym = NODE_PSYMBOL("LOCK"); mkcol_sym = NODE_PSYMBOL("MKCOL"); diff --git a/test/simple/test-http-patch.js b/test/simple/test-http-patch.js new file mode 100644 index 0000000000..142a0934d8 --- /dev/null +++ b/test/simple/test-http-patch.js @@ -0,0 +1,68 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var common = require('../common'); +var assert = require('assert'); +var net = require('net'); +var http = require('http'); + +// Test that the PATCH verb gets passed through correctly + +var server_response = ''; +var received_method = null; + +var server = http.createServer(function(req, res) { + received_method = req.method; + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.write('hello '); + res.write('world\n'); + res.end(); +}); +server.listen(common.PORT); + +server.on('listening', function() { + var c = net.createConnection(common.PORT); + + c.setEncoding('utf8'); + + c.on('connect', function() { + c.write('PATCH / HTTP/1.0\r\n\r\n'); + }); + + c.on('data', function(chunk) { + console.log(chunk); + server_response += chunk; + }); + + c.on('end', function() { + c.end(); + }); + + c.on('close', function() { + server.close(); + }); +}); + +process.on('exit', function() { + var m = server_response.split('\r\n\r\n'); + assert.equal(m[1], 'hello world\n'); + assert.equal(received_method, 'PATCH'); +});