Uppercase the HTTP method name

This fixes PUT/DELETE for IE 9 and PATCH for Node.js.
This commit is contained in:
Mislav Marohnić 2014-10-30 13:31:30 +01:00
Родитель 430d871ca3
Коммит c71f1dd9bb
2 изменённых файлов: 42 добавлений и 1 удалений

Просмотреть файл

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

Просмотреть файл

@ -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()
})
})