Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mikeal/request
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Bredensteiner committed Jul 6, 2012
2 parents 7ff5dae + 3a664fd commit 3daebaf
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
14 changes: 9 additions & 5 deletions tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ exports.createPostValidator = function (text) {
var r = '';
req.on('data', function (chunk) {r += chunk})
req.on('end', function () {
if (r !== text) console.log(r, text);
assert.equal(r, text)
resp.writeHead(200, {'content-type':'text/plain'})
resp.write('OK')
resp.end()
if (req.headers['content-type'] && req.headers['content-type'].indexOf('boundary=') >= 0) {
var boundary = req.headers['content-type'].split('boundary=')[1];
text = text.replace(/__BOUNDARY__/g, boundary);
}
if (r !== text) console.log(r, text);
assert.equal(r, text)
resp.writeHead(200, {'content-type':'text/plain'})
resp.write('OK')
resp.end()
})
}
return l;
Expand Down
33 changes: 16 additions & 17 deletions tests/test-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,22 @@ var tests =
, method: "PUT"
, json: {foo: 'bar'}
}
// , testPutMultipart :
// { resp: server.createPostValidator(
// '--frontier\r\n' +
// '--15F6786B-D0A8-4AB8-B0A5-DDF721BC6192\\r\\n'
// 'content-type: text/html\r\n' +
// '\r\n' +
// '<html><body>Oh hi.</body></html>' +
// '\r\n--frontier\r\n\r\n' +
// 'Oh hi.' +
// '\r\n--frontier--'
// )
// , method: "PUT"
// , multipart:
// [ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
// , {'body': 'Oh hi.'}
// ]
// }
, testPutMultipart :
{ resp: server.createPostValidator(
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
[ {'content-type': 'text/html', 'body': '<html><body>Oh hi.</body></html>'}
, {'body': 'Oh hi.'}
]
}
}

s.listen(s.port, function () {
Expand Down
6 changes: 3 additions & 3 deletions tests/test-https-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--frontier\r\n' +
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--frontier--'
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
Expand Down
6 changes: 3 additions & 3 deletions tests/test-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--frontier\r\n' +
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--frontier--'
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
Expand Down
6 changes: 3 additions & 3 deletions tests/test-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ var tests =
}
, testPutMultipart :
{ resp: server.createPostValidator(
'--frontier\r\n' +
'--__BOUNDARY__\r\n' +
'content-type: text/html\r\n' +
'\r\n' +
'<html><body>Oh hi.</body></html>' +
'\r\n--frontier\r\n\r\n' +
'\r\n--__BOUNDARY__\r\n\r\n' +
'Oh hi.' +
'\r\n--frontier--'
'\r\n--__BOUNDARY__--'
)
, method: "PUT"
, multipart:
Expand Down
3 changes: 2 additions & 1 deletion tests/test-tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ squid.stdout.on('data', function (c) {
})

squid.on('exit', function (c) {
console.error('exit '+c)
console.error('squid: exit '+c)
if (c && !ready) {
console.error('squid must be installed to run this test.')
console.error('skipping this test. please install squid and run again if you need to test tunneling.')
c = null
hadError = null
process.exit(0)
Expand Down

0 comments on commit 3daebaf

Please sign in to comment.