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.10.5 to 0.11.0

12

lib/agent.js

@@ -217,5 +217,11 @@ /*

if (req.response) {
// it is an observe request
// and we are already streaming
return req.response.append(packet)
if (req.response.append) {
// it is an observe request
// and we are already streaming
return req.response.append(packet)
} else {
// TODO There is a previous response but is not an ObserveStream !
return
}
}

@@ -222,0 +228,0 @@ else if (block2) {

@@ -17,2 +17,3 @@ /*

}
, capitalize = require('capitalize')

@@ -31,3 +32,4 @@ module.exports.genAck = function(request) {

var optionAliases = {
'Content-Type': 'Content-Format'
'Content-Type': 'Content-Format',
'Etag': 'ETag'
}

@@ -38,2 +40,5 @@

name = capitalize.words(name)
name = optionAliases[name] || name
this._packet.options = this._packet.options.filter(function(option) {

@@ -48,3 +53,3 @@ return option.name !== name

this._packet.options.push({
name: optionAliases[name] || name
name: name
, value: toBinary(name, values[i])

@@ -51,0 +56,0 @@ })

@@ -80,4 +80,4 @@ /*

var contentFormatToBinary = function(result) {
result = formatsString[result]
var contentFormatToBinary = function(value) {
var result = formatsString[value.split(';')[0]]
if (!result)

@@ -84,0 +84,0 @@ throw new Error('Unknown Content-Format: ' + value)

@@ -102,2 +102,13 @@ /*

OutgoingMessage.prototype.writeHead = function(code, headers) {
var packet = this._packet
var header
packet.code = String(code).replace(/(^\d[^.])/, '$1.')
for (header in headers) {
if (headers.hasOwnProperty(header)) {
this.setOption(header, headers[header])
}
}
}
module.exports = OutgoingMessage
{
"name": "coap",
"version": "0.10.5",
"version": "0.11.0",
"description": "A CoAP library for node modelled after 'http'",

@@ -38,2 +38,3 @@ "main": "index.js",

"bl": "~0.9.0",
"capitalize": "^1.0.0",
"coap-packet": "~0.1.12",

@@ -40,0 +41,0 @@ "fastseries": "^1.1.0",

@@ -310,2 +310,5 @@ node-coap

reset flag set to `true` to the caller. This action ends the interaction with the caller.
#### message.writeHead(code, headers)
Functions somewhat like `http`'s `writeHead()` function. If `code` is does not match the CoAP code mask of `#.##`, it is coerced into this mask. `headers` is an object with keys being the header names, and values being the header values.
-------------------------------------------------------

@@ -312,0 +315,0 @@ <a name="incoming"></a>

@@ -211,2 +211,30 @@ /*

it('should allow encoding with \'Content-Format\'', function(done) {
var req = coap.request('coap://localhost:' + port)
req.setOption('Content-Format', 'application/json; charset=utf8')
req.end()
server.on('request', function(req) {
expect(req.options[0].name).to.equal('Content-Format')
expect(req.options[0].value).to.equal('application/json')
done()
})
})
it('should provide a writeHead() method', function(done) {
var req = coap.request('coap://localhost:' + port)
req.end();
req.on('response', function(res) {
expect(res.headers['Content-Format']).to.equal('application/json')
done()
})
server.on('request', function(req, res) {
res.writeHead(200, {'Content-Format': 'application/json'})
res.write(JSON.stringify({}))
res.end()
})
})
it('should set and parse \'Location-Path\'', function(done) {

@@ -213,0 +241,0 @@ var req = coap.request({

@@ -359,2 +359,18 @@ /*

it('should attempt to normalize option case', function (done) {
var req = request({
port: port
})
, buf = new Buffer(3)
req.setOption('content-type', buf)
req.end()
server.on('message', function (msg) {
expect(parse(msg).options[0].name).to.eql('Content-Format')
expect(parse(msg).options[0].value).to.eql(buf)
done()
})
})
it('should overwrite the option', function (done) {

@@ -423,2 +439,39 @@ var req = request({

it('should not crash with two CON responses with the same messageId & token', function (done) {
var req = request({
port: port
, confirmable: true
})
server.once('message', function (msg, rsinfo) {
var packet = parse(msg)
, toSend = generate({
token: packet.token
, messageId: packet.messageId
, payload: new Buffer('42')
, confirmable: true
, code: '2.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
toSend = generate({
token: packet.token
, messageId: packet.messageId
, payload: new Buffer('42')
, confirmable: true
, code: '2.00'
})
server.send(toSend, 0, toSend.length, rsinfo.port, rsinfo.address)
})
req.on('response', function (res) {
res.pipe(bl(function (err, data) {
expect(data).to.eql(new Buffer('42'))
done()
}))
})
req.end()
})
var formatsString = {

@@ -425,0 +478,0 @@ 'text/plain': new Buffer([0])

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