Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working multipart/form-data posts and now bundles whole module
- Loading branch information
1 parent
5b2704f
commit 17979de
Showing
7 changed files
with
123 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
node_modules/ | ||
bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.gitignore | ||
bundle.js | ||
test-get.js | ||
test-post.js | ||
test-promise.js | ||
.* | ||
test-*.js | ||
index.js | ||
_read.js | ||
_write.js | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var test = require('tape') | ||
var fs = require('fs') | ||
var tiny = require('.') | ||
var http = require('http') | ||
var server | ||
|
||
test('make a multipart post', t=> { | ||
t.plan(1) | ||
t.ok(tiny, 'got env') | ||
}) | ||
|
||
test('start a fake server', t=> { | ||
t.plan(1) | ||
// somebody thought this was intuitive | ||
server = http.createServer((req, res)=> { | ||
var body = [] | ||
req.on('data', function _data(data) { | ||
//console.log(data.toString()) | ||
body.push(data) | ||
}) | ||
req.on('end', function _end() { | ||
console.log('END', Buffer.concat(body).toString()) | ||
}) | ||
res.end('ugh') | ||
}).listen(3333, x=> { | ||
t.ok(true, 'opened server') | ||
}) | ||
}) | ||
|
||
test('can multipart/form-data post', t=> { | ||
t.plan(1) | ||
tiny.post({ | ||
url: 'http://localhost:3333', | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
}, | ||
data: { | ||
one: 1, | ||
anotherFile: fs.createReadStream(__dirname + '/readme.md') | ||
} | ||
}, | ||
function _post(err, data) { | ||
if (err) { | ||
t.fail(err, err) | ||
console.log(err) | ||
} | ||
else { | ||
t.ok(true, 'posted') | ||
console.log(data) | ||
} | ||
}) | ||
}) | ||
|
||
test('close fake server', t=> { | ||
t.plan(1) | ||
server.close() | ||
t.ok(true, 'server closed') | ||
}) |