-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest.js
More file actions
60 lines (51 loc) · 1.25 KB
/
test.js
File metadata and controls
60 lines (51 loc) · 1.25 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict'
var net = require('net')
var test = require('tape')
var rtsp = require('./')
test('server events', function (t) {
t.plan(3)
var server = rtsp.createServer()
server.on('listening', connect)
server.on('connection', function (c) {
t.ok(true)
c.unref()
})
server.on('request', function (req, res) {
t.ok(req instanceof rtsp.IncomingMessage)
t.ok(res instanceof rtsp.ServerResponse)
server.unref()
})
server.listen()
function connect () {
var port = server.address().port
var client = net.connect(port, function () {
client.write('OPTIONS * RTSP/1.0\r\n\r\n')
})
client.unref()
}
})
test('request events', function (t) {
t.plan(3)
var server = rtsp.createServer(function (req, res) {
req.on('readable', function () {
t.ok(true)
})
req.on('end', function () {
t.ok(true)
server.unref()
})
req.on('data', function (chunk) {
t.equal(chunk.toString(), 'foobar')
})
})
server.on('connection', function (c) {
c.unref()
})
server.listen(function () {
var port = server.address().port
var client = net.connect(port, function () {
client.write('OPTIONS * RTSP/1.0\r\nContent-Length: 6\r\n\r\nfoobar')
})
client.unref()
})
})