Permalink
Browse files

Merge pull request #97 from ded/ugly-diff

big fat batch of changes
  • Loading branch information...
2 parents 9def4cb + 56a59de commit e40fcc6a88491cadeb0a1169fe3290aad9f6808b @rvagg rvagg committed Mar 4, 2013
Showing with 1,350 additions and 656 deletions.
  1. +61 −0 .jshintrc
  2. +2 −1 Makefile
  3. +70 −32 build.json
  4. +28 −8 make/tests.js
  5. +1 −0 package.json
  6. +111 −80 reqwest.js
  7. +1 −1 reqwest.min.js
  8. +111 −80 src/reqwest.js
  9. +1 −1 tests/fixtures/badfixtures.xml
  10. +964 −453 tests/tests.js
View
@@ -0,0 +1,61 @@
+{
+ "predef": [ "define", "ActiveXObject" ]
+ , "bitwise": true
+ , "camelcase": false
+ , "curly": false
+ , "eqeqeq": false
+ , "forin": false
+ , "immed": false
+ , "latedef": false
+ , "newcap": true
+ , "noarg": true
+ , "noempty": true
+ , "nonew": true
+ , "plusplus": false
+ , "quotmark": true
+ , "regexp": false
+ , "undef": true
+ , "unused": true
+ , "strict": false
+ , "trailing": true
+ , "maxlen": 120
+ , "asi": true
+ , "boss": true
+ , "debug": true
+ , "eqnull": true
+ , "es5": true
+ , "esnext": true
+ , "evil": true
+ , "expr": true
+ , "funcscope": false
+ , "globalstrict": false
+ , "iterator": false
+ , "lastsemic": true
+ , "laxbreak": true
+ , "laxcomma": true
+ , "loopfunc": true
+ , "multistr": false
+ , "onecase": false
+ , "proto": false
+ , "regexdash": false
+ , "scripturl": true
+ , "smarttabs": false
+ , "shadow": false
+ , "sub": true
+ , "supernew": false
+ , "validthis": true
+ , "browser": true
+ , "couch": false
+ , "devel": false
+ , "dojo": false
+ , "mootools": false
+ , "node": true
+ , "nonstandard": true
+ , "prototypejs": false
+ , "rhino": false
+ , "worker": true
+ , "wsh": false
+ , "nomen": false
+ , "onevar": true
+ , "passfail": false
+}
View
@@ -1,7 +1,8 @@
.PHONY: boosh test
boosh:
- node_modules/smoosh/bin/smoosh make build.json
+ @node -e "var json = require('./build');json.JSHINT_OPTS=JSON.parse(require('fs').readFileSync('./.jshintrc'));require('fs').writeFileSync('./build.json', JSON.stringify(json, null, 2))"
+ @node_modules/smoosh/bin/smoosh make build.json
test:
npm test
View
@@ -1,36 +1,74 @@
{
+ "YO": "This file is built by the Makefile, your edits may not be saved on build",
"JAVASCRIPT": {
- "DIST_DIR": "./"
- , "reqwest": [
- "src/copyright.js"
- , "src/reqwest.js"
+ "DIST_DIR": "./",
+ "reqwest": [
+ "src/copyright.js",
+ "src/reqwest.js"
]
+ },
+ "JSHINT_OPTS": {
+ "predef": [
+ "define",
+ "ActiveXObject"
+ ],
+ "bitwise": true,
+ "camelcase": false,
+ "curly": false,
+ "eqeqeq": false,
+ "forin": false,
+ "immed": false,
+ "latedef": false,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "plusplus": false,
+ "quotmark": true,
+ "regexp": false,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+ "trailing": true,
+ "maxlen": 120,
+ "asi": true,
+ "boss": true,
+ "debug": true,
+ "eqnull": true,
+ "es5": true,
+ "esnext": true,
+ "evil": true,
+ "expr": true,
+ "funcscope": false,
+ "globalstrict": false,
+ "iterator": false,
+ "lastsemic": true,
+ "laxbreak": true,
+ "laxcomma": true,
+ "loopfunc": true,
+ "multistr": false,
+ "onecase": false,
+ "proto": false,
+ "regexdash": false,
+ "scripturl": true,
+ "smarttabs": false,
+ "shadow": false,
+ "sub": true,
+ "supernew": false,
+ "validthis": true,
+ "browser": true,
+ "couch": false,
+ "devel": false,
+ "dojo": false,
+ "mootools": false,
+ "node": true,
+ "nonstandard": true,
+ "prototypejs": false,
+ "rhino": false,
+ "worker": true,
+ "wsh": false,
+ "nomen": false,
+ "onevar": true,
+ "passfail": false
}
-, "JSHINT_OPTS": {
- "predef": [ "define", "module", "ActiveXObject" ]
- , "boss": true
- , "bitwise": true
- , "shadow": true
- , "trailing": true
- , "latedef": true
- , "forin": false
- , "curly": false
- , "devel": false
- , "evil": true
- , "regexp": false
- , "undef": true
- , "sub": true
- , "white": false
- , "indent": 2
- , "trailing": true
- , "asi": true
- , "laxbreak": true
- , "eqnull": true
- , "browser": true
- , "laxcomma": true
- , "proto": true
- , "expr": true
- , "es5": true
- , "strict": false
- }
-}
+}
View
@@ -1,9 +1,10 @@
-var http = require('http')
- , exec = require('child_process').exec
+var exec = require('child_process').exec
, fs = require('fs')
, Connect = require('connect')
, dispatch = require('dispatch')
, mime = require('mime')
+ , DelayedStream = require('delayed-stream')
+
, getMime = function(ext) {
return mime.lookup(ext == 'jsonp' ? 'js' : ext)
}
@@ -13,6 +14,19 @@ var routes = {
res.write(fs.readFileSync('./tests/tests.html', 'utf8'))
res.end()
},
+ '/tests/timeout$': function (req, res) {
+ var delayed = DelayedStream.create(req)
+ setTimeout(function() {
+ res.writeHead(200, {
+ 'Expires': 0
+ , 'Cache-Control': 'max-age=0, no-cache, no-store'
+ })
+ req.query.callback && res.write(req.query.callback + '(')
+ res.write(JSON.stringify({ method: req.method, query: req.query, headers: req.headers }))
+ req.query.callback && res.write(');')
+ delayed.pipe(res)
+ }, 2000)
+ },
'(([\\w\\-\\/]+)\\.(css|js|json|jsonp|html|xml)$)': function (req, res, next, uri, file, ext) {
res.writeHead(200, {
'Expires': 0
@@ -35,26 +49,32 @@ Connect.createServer(Connect.query(), dispatch(routes)).listen(1234)
var otherOriginRoutes = {
'/get-value': function (req, res) {
res.writeHead(200, {
- 'Access-Control-Allow-Origin': 'http://localhost:1234',
+ 'Access-Control-Allow-Origin': req.headers.origin,
'Content-Type': 'text/plain'
})
res.end('hello')
},
'/set-cookie': function (req, res) {
res.writeHead(200, {
- 'Access-Control-Allow-Origin': 'http://localhost:1234',
+ 'Access-Control-Allow-Origin': req.headers.origin,
'Access-Control-Allow-Credentials': 'true',
'Content-Type': 'text/plain',
'Set-Cookie': 'cookie=hello'
})
res.end('Set a cookie!')
},
'/get-cookie-value': function (req, res) {
- var cookies = req.headers.cookie
- var value = ((cookies.indexOf('=') > -1) ? cookies.split('=')[1] : '')
+ var cookies = {}
+ , value
+ req.headers.cookie && req.headers.cookie.split(';').forEach(function( cookie ) {
+ var parts = cookie.split('=')
+ cookies[ parts[ 0 ].trim() ] = ( parts[ 1 ] || '' ).trim()
+ })
+ value = cookies.cookie
+
res.writeHead(200, {
- 'Access-Control-Allow-Origin': 'http://localhost:1234',
+ 'Access-Control-Allow-Origin': req.headers.origin,
'Access-Control-Allow-Credentials': 'true',
'Content-Type': 'text/plain'
})
@@ -66,4 +86,4 @@ Connect.createServer(Connect.query(), dispatch(otherOriginRoutes)).listen(5678)
exec('open http://localhost:1234', function () {
console.log('opening tests at http://localhost:1234')
-})
+})
View
@@ -18,6 +18,7 @@
, "dispatch": "0.x.x"
, "valentine": ">=1.4.7"
, "smoosh": "0.4.0"
+ , "delayed-stream" : "0.0.5"
}
, "scripts": {
"boosh": "smoosh make ./build.json"
Oops, something went wrong.

0 comments on commit e40fcc6

Please sign in to comment.