forked from isaacs/http-duplex-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
25 lines (23 loc) · 679 Bytes
/
test.js
File metadata and controls
25 lines (23 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// vim: set softtabstop=3 shiftwidth=3:
var HttpDuplex = require ('./client.js')
var fs = require ('fs')
var input = fs . createReadStream (__filename)
var http = require ('http')
var assert = require ('assert')
var server = http . createServer (function (req, res) {
req . pipe (res)
server . close ()
})
server . listen (1337, function () {
var req = HttpDuplex ({ port: 1337, method: 'POST' })
input . pipe (req)
var result = ''
req . setEncoding ('utf8')
req . on ('data', function (c) {
result += c
})
req . on ('end', function () {
assert . equal (result, fs . readFileSync (__filename, 'utf8'))
console . log ('ok')
})
})