Skip to content

Commit a24ab93

Browse files
committed
fix: iron-request now expects headers to be lower case
1 parent 1a5f744 commit a24ab93

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

grapp-rest-resource.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,16 @@
197197
_prepareHeaders: function() {
198198
var h, key, ref, val;
199199
h = {
200-
'Accept': 'application/json',
201-
'Content-Type': 'application/json'
200+
'accept': 'application/json',
201+
'content-type': 'application/json'
202202
};
203203
ref = this.headers;
204204
for (key in ref) {
205205
val = ref[key];
206206
h[key] = val;
207207
}
208208
if (this.token) {
209-
h['Authorization'] = this.token;
209+
h['authorization'] = this.token;
210210
}
211211
return h;
212212
},

src/grapp-rest-resource.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ Polymer
9292
url
9393

9494
_prepareHeaders: ->
95-
h = {'Accept': 'application/json', 'Content-Type': 'application/json'}
95+
h = {'accept': 'application/json', 'content-type': 'application/json'}
9696
for key, val of @headers
9797
h[key] = val
98-
h['Authorization'] = @token if @token
98+
h['authorization'] = @token if @token
9999
h
100100

101101
_sendRequest: (method, path, query, id = null, data = null, action = null) ->

test/headers.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
@server = sinon.fakeServer.create()
4040
@server.respondWith 'GET', '/data', (request) ->
4141
if request.requestHeaders['foo'] == 123
42-
request.respond 200, {'Content-Type': 'application/json'}, '"request-with-headers"'
43-
else if request.requestHeaders['Authorization'] == 'JWT'
44-
request.respond 200, {'Content-Type': 'application/json'}, '"request-with-token"'
45-
else if request.requestHeaders['Accept'] == 'application/json' && request.requestHeaders['Content-Type'] == 'application/json'
46-
request.respond 200, {'Content-Type': 'application/json'}, '"simple-request"'
42+
request.respond 200, {'content-type': 'application/json'}, '"request-with-headers"'
43+
else if request.requestHeaders['authorization'] == 'JWT'
44+
request.respond 200, {'content-type': 'application/json'}, '"request-with-token"'
45+
else if request.requestHeaders['accept'] == 'application/json' && request.requestHeaders['content-type'] == 'application/json'
46+
request.respond 200, {'content-type': 'application/json'}, '"simple-request"'
4747

4848
describe 'default hedaers', ->
4949

0 commit comments

Comments
 (0)