http: support PURGE request method
This commit is contained in:
parent
f0c5165f81
commit
de5e3f6a6f
@ -60,6 +60,7 @@ static Persistent<String> delete_sym;
|
|||||||
static Persistent<String> get_sym;
|
static Persistent<String> get_sym;
|
||||||
static Persistent<String> head_sym;
|
static Persistent<String> head_sym;
|
||||||
static Persistent<String> post_sym;
|
static Persistent<String> post_sym;
|
||||||
|
static Persistent<String> purge_sym;
|
||||||
static Persistent<String> put_sym;
|
static Persistent<String> put_sym;
|
||||||
static Persistent<String> connect_sym;
|
static Persistent<String> connect_sym;
|
||||||
static Persistent<String> options_sym;
|
static Persistent<String> options_sym;
|
||||||
@ -126,6 +127,7 @@ method_to_str(unsigned short m) {
|
|||||||
case HTTP_GET: return get_sym;
|
case HTTP_GET: return get_sym;
|
||||||
case HTTP_HEAD: return head_sym;
|
case HTTP_HEAD: return head_sym;
|
||||||
case HTTP_POST: return post_sym;
|
case HTTP_POST: return post_sym;
|
||||||
|
case HTTP_PURGE: return purge_sym;
|
||||||
case HTTP_PUT: return put_sym;
|
case HTTP_PUT: return put_sym;
|
||||||
case HTTP_CONNECT: return connect_sym;
|
case HTTP_CONNECT: return connect_sym;
|
||||||
case HTTP_OPTIONS: return options_sym;
|
case HTTP_OPTIONS: return options_sym;
|
||||||
@ -613,6 +615,7 @@ void InitHttpParser(Handle<Object> target) {
|
|||||||
get_sym = NODE_PSYMBOL("GET");
|
get_sym = NODE_PSYMBOL("GET");
|
||||||
head_sym = NODE_PSYMBOL("HEAD");
|
head_sym = NODE_PSYMBOL("HEAD");
|
||||||
post_sym = NODE_PSYMBOL("POST");
|
post_sym = NODE_PSYMBOL("POST");
|
||||||
|
purge_sym = NODE_PSYMBOL("PURGE");
|
||||||
put_sym = NODE_PSYMBOL("PUT");
|
put_sym = NODE_PSYMBOL("PUT");
|
||||||
connect_sym = NODE_PSYMBOL("CONNECT");
|
connect_sym = NODE_PSYMBOL("CONNECT");
|
||||||
options_sym = NODE_PSYMBOL("OPTIONS");
|
options_sym = NODE_PSYMBOL("OPTIONS");
|
||||||
|
@ -24,7 +24,10 @@ var assert = require('assert');
|
|||||||
var net = require('net');
|
var net = require('net');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
|
||||||
// Test that the PATCH verb gets passed through correctly
|
// Test that the PATCH and PURGE verbs get passed through correctly
|
||||||
|
|
||||||
|
['PATCH', 'PURGE'].forEach(function(method, index) {
|
||||||
|
var port = common.PORT + index;
|
||||||
|
|
||||||
var server_response = '';
|
var server_response = '';
|
||||||
var received_method = null;
|
var received_method = null;
|
||||||
@ -36,15 +39,15 @@ var server = http.createServer(function(req, res) {
|
|||||||
res.write('world\n');
|
res.write('world\n');
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
server.listen(common.PORT);
|
server.listen(port);
|
||||||
|
|
||||||
server.on('listening', function() {
|
server.on('listening', function() {
|
||||||
var c = net.createConnection(common.PORT);
|
var c = net.createConnection(port);
|
||||||
|
|
||||||
c.setEncoding('utf8');
|
c.setEncoding('utf8');
|
||||||
|
|
||||||
c.on('connect', function() {
|
c.on('connect', function() {
|
||||||
c.write('PATCH / HTTP/1.0\r\n\r\n');
|
c.write(method + ' / HTTP/1.0\r\n\r\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
c.on('data', function(chunk) {
|
c.on('data', function(chunk) {
|
||||||
@ -64,5 +67,6 @@ server.on('listening', function() {
|
|||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
var m = server_response.split('\r\n\r\n');
|
var m = server_response.split('\r\n\r\n');
|
||||||
assert.equal(m[1], 'hello world\n');
|
assert.equal(m[1], 'hello world\n');
|
||||||
assert.equal(received_method, 'PATCH');
|
assert.equal(received_method, method);
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user