Comparing version 0.7.2 to 0.8.0
@@ -256,3 +256,6 @@ /* | ||
var req, response | ||
var req | ||
, response | ||
, options = url.options || url.headers | ||
, option | ||
, that = this | ||
@@ -294,2 +297,10 @@ | ||
if (options) { | ||
for (option in options) { | ||
if (options.hasOwnProperty(option)) { | ||
req.setOption(option, options[option]) | ||
} | ||
} | ||
} | ||
req.sender.on('error', req.emit.bind(req, 'error')) | ||
@@ -296,0 +307,0 @@ |
@@ -52,2 +52,3 @@ /* | ||
this.statusCode = '' | ||
this.code = '' | ||
} | ||
@@ -65,3 +66,3 @@ | ||
packet.code = toCode(this.statusCode) | ||
packet.code = toCode(this.code || this.statusCode) | ||
packet.payload = this | ||
@@ -68,0 +69,0 @@ |
{ | ||
"name": "coap", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "A CoAP library for node modelled after 'http'", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha --bail --reporter spec" | ||
"test": "./node_modules/.bin/mocha --bail --reporter spec 2>&1" | ||
}, | ||
@@ -30,13 +30,13 @@ "repository": { | ||
"devDependencies": { | ||
"pre-commit": "0.0.4", | ||
"chai": "~1.8.0", | ||
"mocha": "~1.13.0", | ||
"timekeeper": "0.0.3", | ||
"pre-commit": "0.0.9", | ||
"chai": "~1.9.1", | ||
"mocha": "~1.21.4", | ||
"timekeeper": "0.0.4", | ||
"sinon": "~1.7.3" | ||
}, | ||
"dependencies": { | ||
"bl": "~0.7.0", | ||
"coap-packet": "~0.1.8", | ||
"bl": "~0.9.0", | ||
"coap-packet": "~0.1.12", | ||
"lru-cache": "~2.5.0" | ||
} | ||
} |
@@ -145,4 +145,6 @@ node-coap | ||
e.g. 'a=b&c=d' | ||
- `observe`: send a CoAP observe message, allowing the streaming of | ||
updates from the server. | ||
- `options`: object that includes the CoAP options, for each key-value | ||
pair the [setOption()](#setOption) will be called. | ||
- `headers`: alias for `options`, but it works only if `options` is | ||
missing. | ||
- `agent`: Controls [`Agent`](#agent) behavior. Possible values: | ||
@@ -232,3 +234,3 @@ * `undefined` (default): use [`globalAgent`](#globalAgent), a single socket for all | ||
#### message.statusCode | ||
#### message.code | ||
@@ -238,2 +240,7 @@ The CoAP code ot the message. | ||
#### message.statusCode | ||
(same as message.code) | ||
<a name="setOption"></a> | ||
#### message.setOption(name, value) | ||
@@ -240,0 +247,0 @@ |
@@ -22,2 +22,6 @@ /* | ||
afterEach(function() { | ||
server.close() | ||
}) | ||
it('should server not use blockwise in response when payload fit in one packet', function(done) { | ||
@@ -24,0 +28,0 @@ var payload = new Buffer(100) // default max packet is 1280 |
@@ -11,3 +11,3 @@ /* | ||
var portCounter = 9042 | ||
var portCounter = 11043 | ||
global.nextPort = function() { | ||
@@ -14,0 +14,0 @@ return ++portCounter |
@@ -41,2 +41,32 @@ /* | ||
it('should return code using res.code attribute', function(done) { | ||
coap | ||
.request('coap://localhost:'+port) | ||
.on('response', function(res) { | ||
expect(res.code).to.eql('4.04') | ||
setImmediate(done) | ||
}) | ||
.end() | ||
server.on('request', function(req, res) { | ||
res.code = '4.04' | ||
res.end('hello') | ||
}) | ||
}) | ||
it('should return code using res.statusCode attribute', function(done) { | ||
coap | ||
.request('coap://localhost:'+port) | ||
.on('response', function(res) { | ||
expect(res.code).to.eql('4.04') | ||
setImmediate(done) | ||
}) | ||
.end() | ||
server.on('request', function(req, res) { | ||
res.statusCode = '4.04' | ||
res.end('hello') | ||
}) | ||
}) | ||
it('should support observing', function(done) { | ||
@@ -118,2 +148,35 @@ var req = coap.request({ | ||
it('should pass the \'' + option + ': ' + format + '\' option to the server if passed alongside the url', function(done) { | ||
var req = { | ||
port: port, | ||
options: {} | ||
}; | ||
req.options[option] = format | ||
coap.request(req).end() | ||
server.on('request', function(req) { | ||
expect(req.options[0].name).to.eql(option) | ||
expect(req.options[0].value).to.eql(format) | ||
done() | ||
}) | ||
}) | ||
it('should pass the \'' + option + ': ' + format + '\' headers to the server if passed alongside the url', function(done) { | ||
var req = { | ||
port: port, | ||
headers: {} | ||
}; | ||
req.headers[option] = format | ||
coap.request(req).end() | ||
server.on('request', function(req) { | ||
expect(req.headers[option]).to.eql(format) | ||
done() | ||
}) | ||
}) | ||
it('should pass the \'' + option + ': ' + format + '\' header to the server', function(done) { | ||
@@ -120,0 +183,0 @@ var req = coap.request('coap://localhost:'+port) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123615
32
3424
466
+ Addedbl@0.9.5(transitive)
- Removedbl@0.7.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstream-browserify@3.0.0(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedbl@~0.9.0
Updatedcoap-packet@~0.1.12