http2-浏览器支持的情况

毕竟http2是新事物,尽管它的协议文本已经正式发布,但是相应的服务器和客户端代码依然在演进中。

我本人也特别关注浏览器部分。因为研究了颇有一段时间的node-http2,希望它可以和浏览器互操作,而不是自己的client,自己的server在那里左右互搏。

其中的firefox,最近的一片报道提到:Firefox 36 已经支持了最终版的h2。

Firefox 36, currently in beta, will support the official final “h2″ protocol for negotiation next week. ... Firefox 36 will also support draft IDs -14 and -15, and will use -15 to negotiate with Twitter as well as Google.

Mozilla outlines Firefox roadmap for HTTP/2 | VentureBeat | Business | by Emil Protalinski - http://venturebeat.com/2015/02/18/mozilla-outlines-firefox-roadmap-for-http2/

而chrome的最近报道兴趣盎然的提到了将会在2016年内删除spdy,却对我最关心的http2支持语焉不详。

We plan to gradually roll out support for HTTP/2 in Chrome 40 in the upcoming weeks.

所以,为了验证实际情况,我写了一小块服务器代码,当浏览器访问https://localhost:8001时,如果此浏览器支持http2的话,就会在服务器段打印h2:

var https = require('https');
var fs = require('fs');

var options = {
  key: fs.readFileSync('example/localhost.key'),
  cert: fs.readFileSync('example/localhost.crt')
};
var supportedProtocols = ["h2", "h2-14",'http/1.1', 'http/1.0'];
options.NPNProtocols = supportedProtocols;
var _server = https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8001);

_server.on('secureConnection', function(socket) {
      console.log('Protocol:'+socket.npnProtocol);      
});

实测效果是, firefox 36 支持http2了。用它访问 URL ,可以看到服务器打印了h2字样。
chrome 42啊打印h2-14。

所为的 in the upcoming weeks,还真是长啊,改成drozens of weeks 或者更妥。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值