Skip to content

Commit

Permalink
ded#160 Fix problem where no specificed content-type throws exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Walser committed Apr 14, 2015
1 parent b4171a0 commit 1d62762
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions make/tests.js
Expand Up @@ -27,6 +27,10 @@ var routes = {
delayed.pipe(res)
}, 2000)
},
'/tests/204': function(req, res) {
res.writeHead(204);
res.end();
},
'(([\\w\\-\\/\\.]+)\\.(css|js|json|jsonp|html|xml)$)': function (req, res, next, uri, file, ext) {
res.writeHead(200, {
'Expires': 0
Expand Down
1 change: 1 addition & 0 deletions reqwest.js
Expand Up @@ -237,6 +237,7 @@

function setType(header) {
// json, javascript, text/plain, text/html, xml
if (header === null) return undefined; //In case of no content-type.
if (header.match('json')) return 'json'
if (header.match('javascript')) return 'js'
if (header.match('text')) return 'html'
Expand Down
2 changes: 1 addition & 1 deletion reqwest.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/reqwest.js
Expand Up @@ -231,6 +231,7 @@

function setType(header) {
// json, javascript, text/plain, text/html, xml
if (header === null) return undefined; //In case of no content-type.
if (header.match('json')) return 'json'
if (header.match('javascript')) return 'js'
if (header.match('text')) return 'html'
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.js
Expand Up @@ -801,6 +801,15 @@
})
})

test('standard mode on no content-type', function (complete) {
ajax({
url: '/tests/204'
, success: function (resp) {
ok(true, 'Nothing blew up.')
}
})
})

test('compat mode "dataType=json" headers', function (complete) {
ajax.compat({
url: '/tests/none.json?echo'
Expand Down

0 comments on commit 1d62762

Please sign in to comment.