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

koa-spdy-push

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-spdy-push - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

26

index.js

@@ -15,3 +15,5 @@

return function push(context, options) {
return function push(context, options, done) {
done = done || noop
// koa properties

@@ -44,2 +46,3 @@ var res = context.res

// regular push stream handling
var stream = res.push(path, headers, priority)

@@ -51,2 +54,12 @@ stream.on('acknowledge', acknowledge)

// handle the deferred thunk
stream.on('finish', finish)
stream.on('error', finish)
stream.on('close', finish)
socket.on('close', finish)
return function (fn) {
done = fn
}
function acknowledge() {

@@ -111,2 +124,11 @@ cleanup()

}
function finish(err) {
done(filterError(err), stream)
stream.removeListener('finish', finish)
stream.removeListener('error', finish)
stream.removeListener('close', finish)
socket.removeListener('close', finish)
}
}

@@ -122,1 +144,3 @@ }

}
function noop() {}

2

package.json
{
"name": "koa-spdy-push",
"description": "SPDY Push helper for Koa",
"version": "0.1.6",
"version": "0.1.7",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

@@ -123,6 +123,2 @@

describe('Files without Content-Length', function () {
// stupid `res.socket = null` is being set on next tick
})
describe('RST_STREAM', function () {

@@ -191,2 +187,30 @@ it('should not leak file descriptors', co(function* () {

describe('yield push', function () {
it('should wait until the stream is finished writing', co(function* () {
yield listen(koa().use(function* () {
this.status = 204
var stream = yield push({
threshold: 1
})(this, {
path: '/',
headers: {
'content-encoding': 'gzip',
'content-type': 'text/plain'
},
body: yield zlib.gzip('lol')
})
stream.writable.should.be.false
}))
var res = yield pull
res.should.have.header('Content-Encoding', 'gzip')
res.should.have.header('Content-Type', 'text/plain')
var buffer = yield get(res)
buffer.toString('utf8').should.equal('lol')
}))
})
function listen(app) {

@@ -193,0 +217,0 @@ // app.outputErrors = true

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