Socket
Socket
Sign inDemoInstall

method-override

Package Overview
Dependencies
Maintainers
6
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

method-override - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

5

History.md

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc