Skip to content
Open
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
9 changes: 6 additions & 3 deletions lib/http-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var http = require('http'),
events = require('events'),
queryString = require('querystring'),
readline = require('readline'),
sys = require('util');
sys = require('util'),
methods = require('methods');

require('./ext');

Expand All @@ -17,6 +18,8 @@ try {

var consoles = [];

var reMethods = new RegExp('^(' + methods.join('|') + ')', 'i')

this.Console = function (host, port, options) {
this.host = host;
this.port = parseInt(port);
Expand Down Expand Up @@ -181,7 +184,7 @@ this.Console.prototype = new(function () {
} else {
delete(this.headers[match[1]]);
}
} else if (/^(GET|POST|PUT|HEAD|DELETE|OPTIONS)/i.test(command)) {
} else if (reMethods.test(command)) {
command = command.split(/\s+/);
method = command.shift().toUpperCase();
path = this.path.slice(0);
Expand All @@ -190,7 +193,7 @@ this.Console.prototype = new(function () {

path = ('/' + path.join('/')).replace(/\/+/g, '/');

if (method === 'PUT' || method === 'POST') {
if (method !== 'GET' && method !== 'HEAD') {
this.pending = { method: method, path: path };
this.dataPrompt();
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords" : ["http", "console", "repl"],
"author" : "Alexis Sellier <[email protected]>",
"contributors" : [],
"dependencies" : { "eyes": ">=0.1.4" },
"dependencies" : { "eyes": ">=0.1.4", "methods": "~0.1.0" },
"version" : "0.6.2",
"main" : "./lib/http-console",
"directories" : { "lib": "./lib", "test": "./test" },
Expand Down