зеркало из https://github.com/github/fetch.git
Uppercase the HTTP method name
This fixes PUT/DELETE for IE 9 and PATCH for Node.js.
This commit is contained in:
Родитель
430d871ca3
Коммит
c71f1dd9bb
2
fetch.js
2
fetch.js
|
@ -115,7 +115,7 @@
|
|||
this.body = options.body
|
||||
this.credentials = options.credentials || null
|
||||
this.headers = new Headers(options.headers)
|
||||
this.method = options.method || 'GET'
|
||||
this.method = (options.method || 'GET').toUpperCase()
|
||||
this.mode = options.mode || null
|
||||
this.referrer = null
|
||||
}
|
||||
|
|
41
test/test.js
41
test/test.js
|
@ -165,3 +165,44 @@ asyncTest('rejects text promise after body is consumed', 2, function() {
|
|||
start()
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('supports HTTP PUT', 2, function() {
|
||||
fetch('/request', {
|
||||
method: 'put',
|
||||
body: {
|
||||
name: 'Hubot',
|
||||
title: 'Hubot Robawt',
|
||||
}
|
||||
}).then(function(response) {
|
||||
var request = JSON.parse(response.body);
|
||||
equal(request.method, 'PUT')
|
||||
equal(request.data, 'name=Hubot&title=Hubot+Robawt')
|
||||
start()
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('supports HTTP PATCH', 2, function() {
|
||||
fetch('/request', {
|
||||
method: 'patch',
|
||||
body: {
|
||||
name: 'Hubot',
|
||||
title: 'Hubot Robawt',
|
||||
}
|
||||
}).then(function(response) {
|
||||
var request = JSON.parse(response.body);
|
||||
equal(request.method, 'PATCH')
|
||||
equal(request.data, 'name=Hubot&title=Hubot+Robawt')
|
||||
start()
|
||||
})
|
||||
})
|
||||
|
||||
asyncTest('supports HTTP DELETE', 2, function() {
|
||||
fetch('/request', {
|
||||
method: 'delete',
|
||||
}).then(function(response) {
|
||||
var request = JSON.parse(response.body);
|
||||
equal(request.method, 'DELETE')
|
||||
equal(request.data, '')
|
||||
start()
|
||||
})
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче