method-override
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,6 @@ | ||
2.0.2 / 2014-06-05 | ||
================== | ||
* use vary module for better `Vary` behavior | ||
2.0.1 / 2014-06-02 | ||
@@ -2,0 +7,0 @@ ================== |
31
index.js
/*! | ||
* Connect - methodOverride | ||
* method-override | ||
* Copyright(c) 2010 Sencha Inc. | ||
* Copyright(c) 2011 TJ Holowaychuk | ||
* Copyright(c) 2014 Jonathan Ong | ||
* Copyright(c) 2014 Douglas Christopher Wilson | ||
* MIT Licensed | ||
@@ -15,2 +17,3 @@ */ | ||
var querystring = require('querystring'); | ||
var vary = require('vary'); | ||
@@ -127,27 +130,1 @@ /** | ||
} | ||
/** | ||
* Add val to Vary header | ||
*/ | ||
function vary(res, val) { | ||
var header = res.getHeader('Vary') || '' | ||
var headers = Array.isArray(header) | ||
? header.join(', ') | ||
: header | ||
// enumerate current values | ||
var vals = headers.toLowerCase().split(/ *, */) | ||
if (vals.indexOf(val.toLowerCase()) !== -1) { | ||
// already set | ||
return | ||
} | ||
// append value (in existing format) | ||
header = headers | ||
? headers + ', ' + val | ||
: val | ||
res.setHeader('Vary', header) | ||
} |
{ | ||
"name": "method-override", | ||
"description": "Override HTTP verbs", | ||
"version": "2.0.1", | ||
"author": { | ||
"name": "Jonathan Ong", | ||
"email": "me@jongleberry.com", | ||
"url": "http://jongleberry.com", | ||
"twitter": "https://twitter.com/jongleberry" | ||
}, | ||
"version": "2.0.2", | ||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)", | ||
"contributors": [ | ||
{ | ||
"name": "Douglas Christopher Wilson", | ||
"email": "doug@somethingdoug.com" | ||
} | ||
"Douglas Christopher Wilson <doug@somethingdoug.com>" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/expressjs/method-override.git" | ||
}, | ||
"bugs": { | ||
"mail": "me@jongleberry.com", | ||
"url": "https://github.com/expressjs/method-override/issues" | ||
}, | ||
"repository": "expressjs/method-override", | ||
"dependencies": { | ||
"methods": "1.0.1", | ||
"parseurl": "1.0.1" | ||
"parseurl": "1.0.1", | ||
"vary": "0.1.0" | ||
}, | ||
@@ -30,0 +16,0 @@ "devDependencies": { |
@@ -57,2 +57,7 @@ # method-override | ||
To use a header to override the method, specify the header name | ||
as a string argument to the `methodOverride` function. To then make | ||
the call, send a `POST` request to a URL with the overridden method | ||
as the value of that header. | ||
```js | ||
@@ -66,4 +71,20 @@ var connect = require('connect') | ||
Example call with header override using `curl`: | ||
``` | ||
curl -XPOST -H'X-HTTP-Method-Override: DELETE' --verbose http://localhost:3000/resource | ||
> POST /resource HTTP/1.1 | ||
> Host: localhost:3000 | ||
> X-HTTP-Method-Override: DELETE | ||
> | ||
Cannot DELETE /resource | ||
``` | ||
### override using a query value | ||
To use a query string value to override the method, specify the query | ||
string key as a string argument to the `methodOverride` function. To | ||
then make the call, send a `POST` request to a URL with the overridden | ||
method as the value of that query string key. | ||
```js | ||
@@ -77,2 +98,12 @@ var connect = require('connect') | ||
Example call with query override using `curl`: | ||
``` | ||
curl -XPOST --verbose http://localhost:3000/resource?_method=DELETE | ||
> POST /resource?_method=DELETE HTTP/1.1 | ||
> Host: localhost:3000 | ||
> | ||
Cannot DELETE /resource?_method=DELETE | ||
``` | ||
### multiple format support | ||
@@ -79,0 +110,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10571
162
3
105
2
1
+ Addedvary@0.1.0
+ Addedvary@0.1.0(transitive)