зеркало из https://github.com/mozilla/gecko-dev.git
bug 1130874 - h2 test server altsvc 06 r=hurley
This only updates node-http2 for mozilla's CI needs by supporting sending of the AltSvc frame (-06). It does not implement receiving or the node internal tests.
This commit is contained in:
Родитель
bfa57d2872
Коммит
c19611d6a0
|
@ -785,7 +785,7 @@ Deserializer.CONTINUATION = function readContinuation(buffer, frame) {
|
||||||
frame.data = buffer;
|
frame.data = buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
// [ALTSVC](http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-04#section-4)
|
// [ALTSVC](http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-06#section-4)
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// The ALTSVC frame (type=0xA) advertises the availability of an alternative service to the client.
|
// The ALTSVC frame (type=0xA) advertises the availability of an alternative service to the client.
|
||||||
|
@ -799,79 +799,40 @@ frameFlags.ALTSVC = [];
|
||||||
// 0 1 2 3
|
// 0 1 2 3
|
||||||
// 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
|
// 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
|
||||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
// | Max-Age (32) |
|
// | Origin-Len (16) | Origin? (*) ...
|
||||||
// +-------------------------------+----------------+--------------+
|
// +-------------------------------+-------------------------------+
|
||||||
// | Port (16) | Reserved (8) | PID_LEN (8) |
|
// | Alt-Svc-Field-Value (*) ...
|
||||||
// +-------------------------------+----------------+--------------+
|
|
||||||
// | Protocol-ID (*) |
|
|
||||||
// +---------------+-----------------------------------------------+
|
|
||||||
// | HOST_LEN (8) | Host (*) ...
|
|
||||||
// +---------------+-----------------------------------------------+
|
|
||||||
// | Origin? (*) ...
|
|
||||||
// +---------------------------------------------------------------+
|
// +---------------------------------------------------------------+
|
||||||
//
|
//
|
||||||
// The ALTSVC frame contains the following fields:
|
// The ALTSVC frame contains the following fields:
|
||||||
//
|
//
|
||||||
// Max-Age: An unsigned, 32-bit integer indicating the freshness
|
// Origin-Len: An unsinged 16 bit integer indicating the length of the origin
|
||||||
// lifetime of the alternative service association, as per [ALT-SVC](http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-01)
|
// field. Must be empty for non zero stream id
|
||||||
// section 2.2.
|
|
||||||
//
|
//
|
||||||
// Port: An unsigned, 16-bit integer indicating the port that the
|
// Origin: origin this directive applies to. If empty it applies to the
|
||||||
// alternative service is available upon.
|
// same origin as the stream with the same id
|
||||||
//
|
//
|
||||||
// Reserved: For future use. Senders MUST set these bits to '0', and
|
// Alt-Svc-Field-Value: an ascaii string corresponding to the HTTP response
|
||||||
// recipients MUST ignore them.
|
// header field value for Alt-Svc
|
||||||
//
|
|
||||||
// PID_LEN: An unsigned, 8-bit integer indicating the length, in
|
|
||||||
// octets, of the Protocol-ID field.
|
|
||||||
//
|
|
||||||
// Protocol-ID: A sequence of bytes (length determined by PID_LEN)
|
|
||||||
// containing the ALPN protocol identifier of the alternative
|
|
||||||
// service.
|
|
||||||
//
|
|
||||||
// HOST_LEN: An unsigned, 8-bit integer indicating the length, in
|
|
||||||
// octets, of the Host field.
|
|
||||||
//
|
|
||||||
// Host: A sequence of characters (length determined by HOST_LEN)
|
|
||||||
// containing an ASCII string indicating the host that the
|
|
||||||
// alternative service is available upon. An internationalized
|
|
||||||
// domain [IDNA] MUST be expressed using A-labels.
|
|
||||||
//
|
|
||||||
// Origin: An optional sequence of characters (length determined by
|
|
||||||
// subtracting the length of all lpreceding fields from the frame
|
|
||||||
// length) containing ASCII serialisation of an origin ([RFC6454](http://tools.ietf.org/html/rfc6454),
|
|
||||||
// Section 6.2) that the alternate service is applicable to.
|
|
||||||
|
|
||||||
typeSpecificAttributes.ALTSVC = ['maxAge', 'port', 'protocolID', 'host',
|
typeSpecificAttributes.ALTSVC = ['maxAge', 'port', 'protocolID', 'host',
|
||||||
'origin'];
|
'origin'];
|
||||||
|
|
||||||
Serializer.ALTSVC = function writeAltSvc(frame, buffers) {
|
Serializer.ALTSVC = function writeAltSvc(frame, buffers) {
|
||||||
var buffer = new Buffer(8);
|
var hdr = frame.protocolID + "=\"" + frame.host + ":" + frame.port + "\"";
|
||||||
buffer.writeUInt32BE(frame.maxAge, 0);
|
if (frame.maxAge) {
|
||||||
buffer.writeUInt16BE(frame.port, 4);
|
hdr += "; ma=" + frame.maxAge;
|
||||||
buffer.writeUInt8(0, 6);
|
}
|
||||||
buffer.writeUInt8(frame.protocolID.length, 7);
|
|
||||||
|
buffer = new Buffer(2);
|
||||||
|
buffer.writeUInt16BE(frame.origin.length, 0);
|
||||||
buffers.push(buffer);
|
buffers.push(buffer);
|
||||||
|
|
||||||
buffers.push(new Buffer(frame.protocolID, 'ascii'));
|
|
||||||
|
|
||||||
buffer = new Buffer(1);
|
|
||||||
buffer.writeUInt8(frame.host.length, 0);
|
|
||||||
buffers.push(buffer);
|
|
||||||
|
|
||||||
buffers.push(new Buffer(frame.host, 'ascii'));
|
|
||||||
|
|
||||||
buffers.push(new Buffer(frame.origin, 'ascii'));
|
buffers.push(new Buffer(frame.origin, 'ascii'));
|
||||||
|
buffers.push(new Buffer(hdr, 'ascii'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Deserializer.ALTSVC = function readAltSvc(buffer, frame) {
|
Deserializer.ALTSVC = function readAltSvc(buffer, frame) {
|
||||||
frame.maxAge = buffer.readUInt32BE(0);
|
// todo
|
||||||
frame.port = buffer.readUInt16BE(4);
|
|
||||||
var pidLength = buffer.readUInt8(7);
|
|
||||||
frame.protocolID = buffer.toString('ascii', 8, 8 + pidLength);
|
|
||||||
var hostLength = buffer.readUInt8(8 + pidLength);
|
|
||||||
frame.host = buffer.toString('ascii', 9 + pidLength, 9 + pidLength + hostLength);
|
|
||||||
frame.origin = buffer.toString('ascii', 9 + pidLength + hostLength);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// BLOCKED
|
// BLOCKED
|
||||||
|
|
|
@ -176,34 +176,37 @@ var test_frames = [{
|
||||||
},
|
},
|
||||||
// length + type + flags + stream + content
|
// length + type + flags + stream + content
|
||||||
buffer: new Buffer('000004' + '09' + '04' + '0000000A' + '12345678', 'hex')
|
buffer: new Buffer('000004' + '09' + '04' + '0000000A' + '12345678', 'hex')
|
||||||
}, {
|
},
|
||||||
frame: {
|
// need to be updated for -06
|
||||||
type: 'ALTSVC',
|
//{
|
||||||
flags: { },
|
// frame: {
|
||||||
stream: 0,
|
// type: 'ALTSVC',
|
||||||
|
// flags: { },
|
||||||
|
// stream: 0,
|
||||||
|
|
||||||
maxAge: 31536000,
|
// maxAge: 31536000,
|
||||||
port: 4443,
|
// port: 4443,
|
||||||
protocolID: "h2",
|
// protocolID: "h2",
|
||||||
host: "altsvc.example.com",
|
// host: "altsvc.example.com",
|
||||||
origin: ""
|
// origin: ""
|
||||||
},
|
// },
|
||||||
buffer: new Buffer('00001D' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D', 'hex')
|
// buffer: new Buffer('00001D' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D', 'hex')
|
||||||
}, {
|
//}, {
|
||||||
frame: {
|
// frame: {
|
||||||
type: 'ALTSVC',
|
// type: 'ALTSVC',
|
||||||
flags: { },
|
// flags: { },
|
||||||
stream: 0,
|
// stream: 0,
|
||||||
|
//
|
||||||
maxAge: 31536000,
|
// maxAge: 31536000,
|
||||||
port: 4443,
|
// port: 4443,
|
||||||
protocolID: "h2",
|
// protocolID: "h2",
|
||||||
host: "altsvc.example.com",
|
// host: "altsvc.example.com",
|
||||||
origin: "https://onlyme.example.com"
|
// origin: "https://onlyme.example.com"
|
||||||
},
|
// },
|
||||||
buffer: new Buffer('000037' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D' + '68747470733A2F2F6F6E6C796D652E6578616D706C652E636F6D', 'hex')
|
// buffer: new Buffer('000037' + '0A' + '00' + '00000000' + '01E13380' + '115B' + '00' + '02' + '6832' + '12' + '616C747376632E6578616D706C652E636F6D' + '68747470733A2F2F6F6E6C796D652E6578616D706C652E636F6D', 'hex')
|
||||||
|
//
|
||||||
}, {
|
//},
|
||||||
|
{
|
||||||
frame: {
|
frame: {
|
||||||
type: 'BLOCKED',
|
type: 'BLOCKED',
|
||||||
flags: { },
|
flags: { },
|
||||||
|
|
Загрузка…
Ссылка в новой задаче