Permalink
Browse files

#160 Fix problem where no specificed content-type throws exceptions.

  • Loading branch information...
1 parent b4171a0 commit 84e00137985b4b7d0f305805ff0ec621bb586b19 @wwalser wwalser committed Apr 14, 2015
Showing with 14 additions and 0 deletions.
  1. +4 −0 make/tests.js
  2. +1 −0 src/reqwest.js
  3. +9 −0 tests/tests.js
View
@@ -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
View
@@ -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'
View
@@ -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'

0 comments on commit 84e0013

Please sign in to comment.