mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1136361 - update node-http2 on ci. rs=mcmanus
This commit is contained in:
parent
db126411e5
commit
6eb4be429d
@ -581,7 +581,7 @@ function altsvcHttp1Server(metadata, response) {
|
||||
response.setStatusLine(metadata.httpVersion, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setHeader("Connection", "close", false);
|
||||
response.setHeader("Alt-Svc", 'h2-16=":' + serverPort + '"', false);
|
||||
response.setHeader("Alt-Svc", 'h2=":' + serverPort + '"', false);
|
||||
var body = "this is where a cool kid would write something neat.\n";
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
@ -859,6 +859,7 @@ var prefs;
|
||||
var spdypref;
|
||||
var spdy3pref;
|
||||
var spdypush;
|
||||
var http2draftpref;
|
||||
var http2pref;
|
||||
var tlspref;
|
||||
var altsvcpref1;
|
||||
@ -870,7 +871,8 @@ function resetPrefs() {
|
||||
prefs.setBoolPref("network.http.spdy.enabled", spdypref);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.v3-1", spdy3pref);
|
||||
prefs.setBoolPref("network.http.spdy.allow-push", spdypush);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2draft", http2pref);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2draft", http2draftpref);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2", http2pref);
|
||||
prefs.setBoolPref("network.http.spdy.enforce-tls-profile", tlspref);
|
||||
prefs.setBoolPref("network.http.altsvc.enabled", altsvcpref1);
|
||||
prefs.setBoolPref("network.http.altsvc.oe", altsvcpref2);
|
||||
@ -899,7 +901,8 @@ function run_test() {
|
||||
spdypref = prefs.getBoolPref("network.http.spdy.enabled");
|
||||
spdy3pref = prefs.getBoolPref("network.http.spdy.enabled.v3-1");
|
||||
spdypush = prefs.getBoolPref("network.http.spdy.allow-push");
|
||||
http2pref = prefs.getBoolPref("network.http.spdy.enabled.http2draft");
|
||||
http2draftpref = prefs.getBoolPref("network.http.spdy.enabled.http2draft");
|
||||
http2pref = prefs.getBoolPref("network.http.spdy.enabled.http2");
|
||||
tlspref = prefs.getBoolPref("network.http.spdy.enforce-tls-profile");
|
||||
altsvcpref1 = prefs.getBoolPref("network.http.altsvc.enabled");
|
||||
altsvcpref2 = prefs.getBoolPref("network.http.altsvc.oe", true);
|
||||
@ -908,6 +911,7 @@ function run_test() {
|
||||
prefs.setBoolPref("network.http.spdy.enabled.v3-1", true);
|
||||
prefs.setBoolPref("network.http.spdy.allow-push", true);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2draft", true);
|
||||
prefs.setBoolPref("network.http.spdy.enabled.http2", true);
|
||||
prefs.setBoolPref("network.http.spdy.enforce-tls-profile", false);
|
||||
prefs.setBoolPref("network.http.altsvc.enabled", true);
|
||||
prefs.setBoolPref("network.http.altsvc.oe", true);
|
||||
|
@ -382,7 +382,7 @@ function handleRequest(req, res) {
|
||||
return;
|
||||
}
|
||||
// test the alt svc frame for use with altsvc2
|
||||
res.altsvc("localhost", serverPort, "h2-16", 3600, req.headers['x-redirect-origin']);
|
||||
res.altsvc("localhost", serverPort, "h2", 3600, req.headers['x-redirect-origin']);
|
||||
}
|
||||
|
||||
else if (u.pathname === "/altsvc2") {
|
||||
|
@ -1,6 +1,17 @@
|
||||
Version history
|
||||
===============
|
||||
|
||||
### 3.2.0 (2015-02-19) ###
|
||||
|
||||
* Update ALPN token to final RFC version (h2).
|
||||
* Update altsvc implementation to draft 06: [draft-ietf-httpbis-alt-svc-06]
|
||||
|
||||
[draft-ietf-httpbis-altsvc-06]: http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-06
|
||||
|
||||
### 3.1.2 (2015-02-17) ###
|
||||
|
||||
* Update the example server to have a safe push example.
|
||||
|
||||
### 3.1.1 (2015-01-29) ###
|
||||
|
||||
* Bugfix release.
|
||||
|
@ -12,6 +12,13 @@ function onRequest(request, response) {
|
||||
|
||||
// Serving server.js from cache. Useful for microbenchmarks.
|
||||
if (request.url === cachedUrl) {
|
||||
if (response.push) {
|
||||
// Also push down the client js, since it's possible if the requester wants
|
||||
// one, they want both.
|
||||
var push = response.push('/client.js');
|
||||
push.writeHead(200);
|
||||
fs.createReadStream(path.join(__dirname, '/client.js')).pipe(push);
|
||||
}
|
||||
response.end(cachedFile);
|
||||
}
|
||||
|
||||
@ -19,13 +26,6 @@ function onRequest(request, response) {
|
||||
else if ((filename.indexOf(__dirname) === 0) && fs.existsSync(filename) && fs.statSync(filename).isFile()) {
|
||||
response.writeHead('200');
|
||||
|
||||
// If they download the certificate, push the private key too, they might need it.
|
||||
if (response.push && request.url === '/localhost.crt') {
|
||||
var push = response.push('/localhost.key');
|
||||
push.writeHead(200);
|
||||
fs.createReadStream(path.join(__dirname, '/localhost.key')).pipe(push);
|
||||
}
|
||||
|
||||
fs.createReadStream(filename).pipe(response);
|
||||
}
|
||||
|
||||
|
@ -800,39 +800,218 @@ frameFlags.ALTSVC = [];
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Origin-Len (16) | Origin? (*) ...
|
||||
// +-------------------------------+-------------------------------+
|
||||
// +-------------------------------+----------------+--------------+
|
||||
// | Alt-Svc-Field-Value (*) ...
|
||||
// +---------------------------------------------------------------+
|
||||
//
|
||||
// The ALTSVC frame contains the following fields:
|
||||
//
|
||||
// Origin-Len: An unsinged 16 bit integer indicating the length of the origin
|
||||
// field. Must be empty for non zero stream id
|
||||
// Origin-Len: An unsigned, 16-bit integer indicating the length, in
|
||||
// octets, of the Origin field.
|
||||
//
|
||||
// Origin: origin this directive applies to. If empty it applies to the
|
||||
// same origin as the stream with the same id
|
||||
// Origin: An OPTIONAL sequence of characters containing ASCII
|
||||
// serialisation of an origin ([RFC6454](http://tools.ietf.org/html/rfc6454),
|
||||
// Section 6.2) that the alternate service is applicable to.
|
||||
//
|
||||
// Alt-Svc-Field-Value: an ascaii string corresponding to the HTTP response
|
||||
// header field value for Alt-Svc
|
||||
// Alt-Svc-Field-Value: A sequence of octets (length determined by
|
||||
// subtracting the length of all preceding fields from the frame
|
||||
// length) containing a value identical to the Alt-Svc field value
|
||||
// defined in (Section 3)[http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-06#section-3]
|
||||
// (ABNF production "Alt-Svc").
|
||||
|
||||
typeSpecificAttributes.ALTSVC = ['maxAge', 'port', 'protocolID', 'host',
|
||||
'origin'];
|
||||
|
||||
Serializer.ALTSVC = function writeAltSvc(frame, buffers) {
|
||||
var hdr = frame.protocolID + "=\"" + frame.host + ":" + frame.port + "\"";
|
||||
if (frame.maxAge) {
|
||||
hdr += "; ma=" + frame.maxAge;
|
||||
function istchar(c) {
|
||||
return ('!#$&\'*+-.^_`|~1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.indexOf(c) > -1);
|
||||
}
|
||||
|
||||
function hexencode(s) {
|
||||
var t = '';
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
if (!istchar(s[i])) {
|
||||
t += '%';
|
||||
t += new Buffer(s[i]).toString('hex');
|
||||
} else {
|
||||
t += s[i];
|
||||
}
|
||||
}
|
||||
|
||||
buffer = new Buffer(2);
|
||||
return t;
|
||||
}
|
||||
|
||||
Serializer.ALTSVC = function writeAltSvc(frame, buffers) {
|
||||
var buffer = new Buffer(2);
|
||||
buffer.writeUInt16BE(frame.origin.length, 0);
|
||||
buffers.push(buffer);
|
||||
buffers.push(new Buffer(frame.origin, 'ascii'));
|
||||
buffers.push(new Buffer(hdr, 'ascii'));
|
||||
|
||||
var fieldValue = hexencode(frame.protocolID) + '="' + frame.host + ':' + frame.port + '"';
|
||||
if (frame.maxAge !== 86400) { // 86400 is the default
|
||||
fieldValue += "; ma=" + frame.maxAge;
|
||||
}
|
||||
|
||||
buffers.push(new Buffer(fieldValue, 'ascii'));
|
||||
};
|
||||
|
||||
function stripquotes(s) {
|
||||
var start = 0;
|
||||
var end = s.length;
|
||||
while ((start < end) && (s[start] === '"')) {
|
||||
start++;
|
||||
}
|
||||
while ((end > start) && (s[end - 1] === '"')) {
|
||||
end--;
|
||||
}
|
||||
if (start >= end) {
|
||||
return "";
|
||||
}
|
||||
return s.substring(start, end);
|
||||
}
|
||||
|
||||
function splitNameValue(nvpair) {
|
||||
var eq = -1;
|
||||
var inQuotes = false;
|
||||
|
||||
for (var i = 0; i < nvpair.length; i++) {
|
||||
if (nvpair[i] === '"') {
|
||||
inQuotes = !inQuotes;
|
||||
continue;
|
||||
}
|
||||
if (inQuotes) {
|
||||
continue;
|
||||
}
|
||||
if (nvpair[i] === '=') {
|
||||
eq = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (eq === -1) {
|
||||
return {'name': nvpair, 'value': null};
|
||||
}
|
||||
|
||||
var name = stripquotes(nvpair.substring(0, eq).trim());
|
||||
var value = stripquotes(nvpair.substring(eq + 1).trim());
|
||||
return {'name': name, 'value': value};
|
||||
}
|
||||
|
||||
function splitHeaderParameters(hv) {
|
||||
return parseHeaderValue(hv, ';', splitNameValue);
|
||||
}
|
||||
|
||||
function parseHeaderValue(hv, separator, callback) {
|
||||
var start = 0;
|
||||
var inQuotes = false;
|
||||
var values = [];
|
||||
|
||||
for (var i = 0; i < hv.length; i++) {
|
||||
if (hv[i] === '"') {
|
||||
inQuotes = !inQuotes;
|
||||
continue;
|
||||
}
|
||||
if (inQuotes) {
|
||||
// Just skip this
|
||||
continue;
|
||||
}
|
||||
if (hv[i] === separator) {
|
||||
var newValue = hv.substring(start, i).trim();
|
||||
if (newValue.length > 0) {
|
||||
newValue = callback(newValue);
|
||||
values.push(newValue);
|
||||
}
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newValue = hv.substring(start).trim();
|
||||
if (newValue.length > 0) {
|
||||
newValue = callback(newValue);
|
||||
values.push(newValue);
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
function rsplit(s, delim, count) {
|
||||
var nsplits = 0;
|
||||
var end = s.length;
|
||||
var rval = [];
|
||||
for (var i = s.length - 1; i >= 0; i--) {
|
||||
if (s[i] === delim) {
|
||||
var t = s.substring(i + 1, end);
|
||||
end = i;
|
||||
rval.unshift(t);
|
||||
nsplits++;
|
||||
if (nsplits === count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (end !== 0) {
|
||||
rval.unshift(s.substring(0, end));
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
function ishex(c) {
|
||||
return ('0123456789ABCDEFabcdef'.indexOf(c) > -1);
|
||||
}
|
||||
|
||||
function unescape(s) {
|
||||
var i = 0;
|
||||
var t = '';
|
||||
while (i < s.length) {
|
||||
if (s[i] != '%' || !ishex(s[i + 1]) || !ishex(s[i + 2])) {
|
||||
t += s[i];
|
||||
} else {
|
||||
++i;
|
||||
var hexvalue = '';
|
||||
if (i < s.length) {
|
||||
hexvalue += s[i];
|
||||
++i;
|
||||
}
|
||||
if (i < s.length) {
|
||||
hexvalue += s[i];
|
||||
}
|
||||
if (hexvalue.length > 0) {
|
||||
t += new Buffer(hexvalue, 'hex').toString();
|
||||
} else {
|
||||
t += '%';
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
Deserializer.ALTSVC = function readAltSvc(buffer, frame) {
|
||||
// todo
|
||||
var originLength = buffer.readUInt16BE(0);
|
||||
frame.origin = buffer.toString('ascii', 2, 2 + originLength);
|
||||
var fieldValue = buffer.toString('ascii', 2 + originLength);
|
||||
var values = parseHeaderValue(fieldValue, ',', splitHeaderParameters);
|
||||
if (values.length > 1) {
|
||||
// TODO - warn that we only use one here
|
||||
}
|
||||
if (values.length === 0) {
|
||||
// Well that's a malformed frame. Just ignore it.
|
||||
return;
|
||||
}
|
||||
|
||||
var chosenAltSvc = values[0];
|
||||
frame.maxAge = 86400; // Default
|
||||
for (var i = 0; i < chosenAltSvc.length; i++) {
|
||||
if (i === 0) {
|
||||
// This corresponds to the protocolID="<host>:<port>" item
|
||||
frame.protocolID = unescape(chosenAltSvc[i].name);
|
||||
var hostport = rsplit(chosenAltSvc[i].value, ':', 1);
|
||||
frame.host = hostport[0];
|
||||
frame.port = parseInt(hostport[1], 10);
|
||||
} else if (chosenAltSvc[i].name == 'ma') {
|
||||
frame.maxAge = parseInt(chosenAltSvc[i].value, 10);
|
||||
}
|
||||
// Otherwise, we just ignore this
|
||||
}
|
||||
};
|
||||
|
||||
// BLOCKED
|
||||
|
@ -37,7 +37,7 @@
|
||||
// [node-https]: http://nodejs.org/api/https.html
|
||||
// [node-http]: http://nodejs.org/api/http.html
|
||||
|
||||
exports.VERSION = 'h2-16';
|
||||
exports.VERSION = 'h2';
|
||||
|
||||
exports.Endpoint = require('./endpoint').Endpoint;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "http2",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.0",
|
||||
"description": "An HTTP/2 client and server implementation",
|
||||
"main": "lib/index.js",
|
||||
"engines" : {
|
||||
|
@ -15,7 +15,8 @@ var frame_types = {
|
||||
PING: ['data'],
|
||||
GOAWAY: ['last_stream', 'error'],
|
||||
WINDOW_UPDATE: ['window_size'],
|
||||
CONTINUATION: ['data']
|
||||
CONTINUATION: ['data'],
|
||||
ALTSVC: ['protocolID', 'host', 'port', 'origin', 'maxAge']
|
||||
};
|
||||
|
||||
var test_frames = [{
|
||||
@ -176,37 +177,34 @@ var test_frames = [{
|
||||
},
|
||||
// length + type + flags + stream + content
|
||||
buffer: new Buffer('000004' + '09' + '04' + '0000000A' + '12345678', 'hex')
|
||||
},
|
||||
// need to be updated for -06
|
||||
//{
|
||||
// frame: {
|
||||
// type: 'ALTSVC',
|
||||
// flags: { },
|
||||
// stream: 0,
|
||||
}, {
|
||||
frame: {
|
||||
type: 'ALTSVC',
|
||||
flags: { },
|
||||
stream: 0,
|
||||
|
||||
// maxAge: 31536000,
|
||||
// port: 4443,
|
||||
// protocolID: "h2",
|
||||
// host: "altsvc.example.com",
|
||||
// origin: ""
|
||||
// },
|
||||
// buffer: new Buffer('00001D' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D', 'hex')
|
||||
//}, {
|
||||
// frame: {
|
||||
// type: 'ALTSVC',
|
||||
// flags: { },
|
||||
// stream: 0,
|
||||
//
|
||||
// maxAge: 31536000,
|
||||
// port: 4443,
|
||||
// protocolID: "h2",
|
||||
// host: "altsvc.example.com",
|
||||
// origin: "https://onlyme.example.com"
|
||||
// },
|
||||
// buffer: new Buffer('000037' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D' + '68747470733A2F2F6F6E6C796D652E6578616D706C652E636F6D', 'hex')
|
||||
//
|
||||
//},
|
||||
{
|
||||
maxAge: 31536000,
|
||||
port: 4443,
|
||||
protocolID: "h2",
|
||||
host: "altsvc.example.com",
|
||||
origin: ""
|
||||
},
|
||||
buffer: new Buffer(new Buffer('00002B' + '0A' + '00' + '00000000' + '0000', 'hex') + new Buffer('h2="altsvc.example.com:4443"; ma=31536000', 'ascii'))
|
||||
}, {
|
||||
frame: {
|
||||
type: 'ALTSVC',
|
||||
flags: { },
|
||||
stream: 0,
|
||||
|
||||
maxAge: 31536000,
|
||||
port: 4443,
|
||||
protocolID: "h2",
|
||||
host: "altsvc.example.com",
|
||||
origin: "https://onlyme.example.com"
|
||||
},
|
||||
buffer: new Buffer(new Buffer('000045' + '0A' + '00' + '00000000' + '001A', 'hex') + new Buffer('https://onlyme.example.comh2="altsvc.example.com:4443"; ma=31536000', 'ascii'))
|
||||
|
||||
}, {
|
||||
frame: {
|
||||
type: 'BLOCKED',
|
||||
flags: { },
|
||||
|
Loading…
Reference in New Issue
Block a user