Skip to content

Commit

Permalink
Use correct HOST header.
Browse files Browse the repository at this point in the history
  • Loading branch information
diversario committed Jun 18, 2014
1 parent bd7544f commit 1ee8907
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ client.on('notify', function () {
//console.log('Got a notification.')
})

client.on('response', function inResponse(code, headers, rinfo) {
client.on('response', function inResponse(headers, code, rinfo) {
console.log('Got a response to an m-search:\n%d\n%s\n%s', code, JSON.stringify(headers, null, ' '), JSON.stringify(rinfo, null, ' '))
})

Expand Down
7 changes: 4 additions & 3 deletions test/lib/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require('../helper')
var moduleVersion = require('../../package.json').version

var assert = require('assert')

Expand All @@ -16,7 +17,7 @@ describe('Client', function () {
'LOCATION: http://0.0.0.0:10000/upnp/desc.html',
'CACHE-CONTROL: max-age=1800',
'DATE: Fri, 30 May 2014 15:07:26 GMT',
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/1.0.1',
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/' + moduleVersion,
'EXT: ' // note the space
]

Expand All @@ -29,7 +30,7 @@ describe('Client', function () {
'LOCATION': 'http://0.0.0.0:10000/upnp/desc.html',
'CACHE-CONTROL': 'max-age=1800',
//'DATE': 'Fri, 30 May 2014 15:07:26 GMT',
'SERVER': 'node.js/0.10.28 UPnP/1.1 node-ssdp/1.0.1',
'SERVER': 'node.js/0.10.28 UPnP/1.1 node-ssdp/' + moduleVersion,
'EXT': ''
}

Expand All @@ -48,4 +49,4 @@ describe('Client', function () {
client.sock.emit('message', Buffer(response.join('\r\n')))
})
})
})
})
13 changes: 7 additions & 6 deletions test/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require('../helper')

var assert = require('chai').assert

var moduleVersion = require('../../package.json').version
var Server = require('../../').Server

describe('Server', function () {
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('Server', function () {
assert(method1, 'NOTIFY')

var headers1 = server._getHeaders(args1[0].toString())
assert.equal(headers1.HOST, 'unicast:1900')
assert.equal(headers1.HOST, 'ip:1900')
assert.equal(headers1.NT, 'tv/video')
assert.equal(headers1.NTS, 'ssdp:alive')
assert.equal(headers1.USN, 'device name::tv/video')
Expand All @@ -160,7 +161,7 @@ describe('Server', function () {
assert(method2, 'NOTIFY')

var headers2 = server._getHeaders(args2[0].toString())
assert.equal(headers2.HOST, 'unicast:1900')
assert.equal(headers2.HOST, 'ip:1900')
assert.equal(headers2.NT, 'device name')
assert.equal(headers2.NTS, 'ssdp:alive')
assert.equal(headers2.USN, 'device name')
Expand Down Expand Up @@ -210,7 +211,7 @@ describe('Server', function () {
assert(method1, 'NOTIFY')

var headers1 = server._getHeaders(args1[0].toString())
assert.equal(headers1.HOST, 'unicast:1900')
assert.equal(headers1.HOST, 'ip:1900')
assert.equal(headers1.NT, 'tv/video')
assert.equal(headers1.NTS, 'ssdp:byebye')
assert.equal(headers1.USN, 'device name::tv/video')
Expand All @@ -237,7 +238,7 @@ describe('Server', function () {
'USN: uuid:f40c2981-7329-40b7-8b04-27f187aecfb5::upnp:rootdevice',
'LOCATION: http://192.168.1.1:10293/upnp/desc.html',
'CACHE-CONTROL: max-age=1800',
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/1.0.1'
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/' + moduleVersion
].join('\r\n')

it('server emits nothing but logs it', function (done) {
Expand Down Expand Up @@ -272,7 +273,7 @@ describe('Server', function () {
'USN: uuid:f40c2981-7329-40b7-8b04-27f187aecfb5::upnp:rootdevice',
'LOCATION: http://192.168.1.1:10293/upnp/desc.html',
'CACHE-CONTROL: max-age=1800',
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/1.0.1'
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/' + moduleVersion
].join('\r\n')

var NOTIFY_BYE = [
Expand Down Expand Up @@ -409,7 +410,7 @@ describe('Server', function () {
'LOCATION: http://' + require('ip').address() + ':10293/upnp/desc.html',
'CACHE-CONTROL: max-age=1800',
//'DATE: Fri, 30 May 2014 15:07:26 GMT', we'll test for this separately
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/2.0.0',
'SERVER: node.js/0.10.28 UPnP/1.1 node-ssdp/' + moduleVersion,
'EXT: ' // note the space
]

Expand Down

0 comments on commit 1ee8907

Please sign in to comment.