Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coap

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coap - npm Package Compare versions

Comparing version 0.7.2 to 0.8.0

examples/json.js

13

lib/agent.js

@@ -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 @@

3

lib/outgoing_message.js

@@ -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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc