Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ task 'test', ->
ssl_cert ->
test_cases = glob.sync 'test/js/**/*_test.js'
test_cases.sort() # Consistent test case order.
run 'node_modules/.bin/mocha --colors --slow 200 --timeout 1000 ' +
run 'node_modules/.bin/mocha --colors --slow 200 --timeout 1000 --exit ' +
"--require test/js/helpers/setup.js #{test_cases.join(' ')}"

task 'webtest', ->
Expand Down
5 changes: 2 additions & 3 deletions src/001-xml_http_request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ class XMLHttpRequest extends XMLHttpRequestEventTarget
trailer: true
'transfer-encoding': true
upgrade: true
'user-agent': true
via: true

# HTTP response headers that should not be exposed according to the XHR spec.
Expand All @@ -391,7 +390,7 @@ class XMLHttpRequest extends XMLHttpRequestEventTarget
'set-cookie': true
'set-cookie2': true

# The value of the User-Agent header.
# The default value of the User-Agent header.
_userAgent: "Mozilla/5.0 (#{os.type()} #{os.arch()}) " +
"node.js/#{process.versions.node} v8/#{process.versions.v8}"

Expand Down Expand Up @@ -483,7 +482,7 @@ class XMLHttpRequest extends XMLHttpRequestEventTarget
@_headers['Host'] = @_url.host
if @_anonymous
@_headers['Referer'] = 'about:blank'
@_headers['User-Agent'] = @_userAgent
@_headers['User-Agent'] ||= @_userAgent
@upload._finalizeHeaders @_headers, @_loweredHeaders
undefined

Expand Down
3 changes: 3 additions & 0 deletions test/src/headers_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe 'XMLHttpRequest', ->
describe 'with allowed headers', ->
beforeEach ->
@xhr.setRequestHeader 'Authorization', 'lol'
@xhr.setRequestHeader 'User-Agent', 'toaster'
@xhr.setRequestHeader 'X-Answer', '42'
@xhr.setRequestHeader 'X-Header-Name', 'value'

Expand All @@ -19,6 +20,8 @@ describe 'XMLHttpRequest', ->
headers = JSON.parse @xhr.responseText
expect(headers).to.have.property 'authorization'
expect(headers['authorization']).to.equal 'lol'
expect(headers).to.have.property 'user-agent'
expect(headers['user-agent']).to.equal 'toaster'
expect(headers).to.have.property 'x-answer'
expect(headers['x-answer']).to.equal '42'
expect(headers).to.have.property 'x-header-name'
Expand Down