Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't automatically send push response headers if disabled #50

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/spdy-transport/protocol/http2/framer.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ Framer.prototype.pushFrame = function pushFrame (frame, callback) {

compress(frame.headers, pairs.promise, function (promiseChunks) {
sendPromise(promiseChunks)
if (frame.response === false) {
return callback(null)
}
compress(frame.response, pairs.response, function (responseChunks) {
sendResponse(responseChunks, callback)
})
Expand Down
37 changes: 37 additions & 0 deletions test/both/transport/push-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,43 @@ describe('Transport/Push', function () {
})

if (version >= 4) {
it('should not send HEADERS on PUSH_PROMISE if disabled', function (done) {
client.request({
path: '/parent'
}, function (err, stream) {
assert(!err)

stream.on('pushPromise', function (push) {
push.on('response', function (status, headers) {
assert.equal(status, 201)
})
push.on('headers', function (headers) {
assert(false)
})
push.on('close', function (err) {
assert(!err)
done()
})
push.resume()
})
})

server.on('stream', function (stream) {
assert.equal(stream.path, '/parent')

stream.respond(200, {})
stream.pushPromise({
path: '/push',
response: false
}, function (err, stream) {
assert(!err)

stream.respond(201)
stream.end()
})
})
})

it('should send PUSH_PROMISE+HEADERS and HEADERS concurrently',
function (done) {
var seq = []
Expand Down