File: post-binary.js

package info (click to toggle)
node-stream-http 3.2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 260 kB
  • sloc: javascript: 1,310; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 598 bytes parent folder | download | duplicates (2)
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
26
27
28
29
var Buffer = require('buffer').Buffer
var fs = require('fs')
var test = require('tape')
var UAParser = require('ua-parser-js')

var http = require('../..')

var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png')

test('post binary', function (t) {
	var req = http.request({
		path: '/echo',
		method: 'POST'
	}, function (res) {
		var buffers = []

		res.on('end', function () {
			t.ok(reference.equals(Buffer.concat(buffers)), 'echoed contents match')
			t.end()
		})

		res.on('data', function (data) {
			buffers.push(data)
		})
	})

	req.write(reference)
	req.end()
})