国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

【搬運工】Say hello to HTTP/2 for Node.js Core

HelKyle / 1907人閱讀

來源:Say hello to HTTP/2 for Node.js Core – Node.js Collection – Medium

A few minutes ago I opened the initial pull-request that would provide an implementation of HTTP/2 for Node.js core. While it’s far from being production ready, this marks a key milestone.

Because this is just a pull-request, it’s possible to play around with, but there are a few additional steps.

First, you’ll need to make sure you’re set up for building Node.js locally by following the instructions here: https://github.com/nodejs/nod...

After that, check out the working branch:

$ git clone https://github.com/jasnell/node
$ git checkout initial-pr

Then build...

$ ./configure
$ make -j8

Warning, building Node.js from scratch takes quite a bit of time. So go grab a quick snack while things get going.

Once complete, you can create a functioning HTTP/2 server in a few lines of code:

const http2 = require("http2");
const server = http2.createServer();
server.on("stream", (stream, requestHeaders) => {
  stream.respond({ ":status": 200, "content-type": "text/plain" });
  stream.write("hello ");
  stream.end("world");
});
server.listen(8000);

Because the HTTP/2 support is still experimental, in order to run this server, the Node.js instance must be started using the --expose-http2 command line argument:

$ node --expose-http2 h2server.js

Note that the server above uses plain-text TCP connection so the server will not be accessible from Web Browsers, which require using TLS. We can, however, create a simple HTTP/2 client:

const http2 = require("http2");
const client = http2.connect("http://localhost:8000");
const req = client.request({ ":method": "GET", ":path": "/" });
req.on("response", (responseHeaders) => {
  // do something with the headers
});
req.on("data", (chunk) => {
  // do something with the data
});
req.on("end", () => client.destroy());

Setting up a TLS-enabled HTTP/2 server requires just a few more additional steps:

const http2 = require("http2");
const options = {
  key: getKeySomehow(),
  cert: getCertSomehow()
};
const server = http2.createSecureServer(options);
server.on("stream", (stream, requestHeaders) => {
  stream.respond();
  stream.end("secured hello world!");
});
server.listen(43);

Refer to the Node.js tls.createServer() documentation for more information regarding the required key and cert configuration options.

While there are many details that still need to worked through, and likely many issues that need to be fixed… this initial implementation provides enough functionality to get started, including:

Push Stream Support

respondWithFile() and respondWithFD() APIs that allow extremely efficient sending of raw file data that bypasses the Streams API.

TLS and Plain-text connections

Full support for stream multiplexing

HTTP/2 Prioritization and Flow Control

Support for HTTP/2 trailers

HPACK header compression support

A compatibility API layer that operates as close as possible to the existing HTTP/1 API

Development will be ongoing, as will security hardening, performance optimization, and API refinement. The more input we get on this, the better it will become.

Happy Multiplexing to All :-)

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/84192.html

相關文章

  • [譯]當 Node.js Core 遇到 HTTP/2

    摘要:幾分鐘前我打開了一個,它為提供了初始的實現。雖然還不堪用,但對來說是一個重要的里程碑。首先你需要跟著這個介紹來配置好的構建環境。我們付出的越多,就會變的越好。 原文:Say hello to HTTP/2 for Node.js Core 第一次嘗試翻譯文章,如果有翻譯的不好或者有錯誤的地方還望大佬們指點一二,謝謝。 幾分鐘前我打開了一個 pull-request,它為 Nodejs ...

    Yuanf 評論0 收藏0
  • 微服務框架 Spark Framework

    摘要:我是廣告本人的直播課程在月份就要開始了,希望小伙伴們支持一下,現在報名有優惠噢 源碼:http://git.oschina.net/sancha... Spark Framework beetl fastjson 結合 項目結構如下 showImg(https://segmentfault.com/img/bVP12A?w=315&h=512); pom.xml如下: 4...

    fasss 評論0 收藏0
  • Node.js原生開發入門完全教程

    摘要:原生開發入門完全教程微信公眾號開發企業級產品全棧開發速成周末班首期班號正式開班,歡迎搶座一關于本篇文章參考了入門并從零到壹操作了一遍,感謝原作者,同時也強烈推薦大家移步到原文給予原文作者一個贊賞支持。 Node.js原生開發入門完全教程 (Node+Vue+React+微信公眾號開發)企業級產品全棧開發速成周末班首期班(10.28號正式開班,歡迎搶座) 一、關于 本篇文章參考了Node...

    alphahans 評論0 收藏0
  • 初識 CoffeeScript

    摘要:而造成一些莫名其妙的錯誤。寫一個文件打印出編譯命令會在同級目錄下生成一個同名的文件。將包裹在了一個匿名函數當中,并用調用,這樣使得代碼隔離,不會和外部混淆。其中的表示的就是為了方便使用,可以使用雙冒號來替代。 很早就知道這CoffeeScript一門語言,但是一直沒有機會系統的學習下,那天趁在公司沒有什么要緊的項目做,就根據CoffeeScript首頁的例子學了一下。 引用Coffe...

    騫諱護 評論0 收藏0
  • node函數使用

    摘要:在中,一個函數可以作為另一個函數的參數。我們可以先定義一個函數,然后傳遞,也可以在傳遞參數的地方直接定義函數。中函數的使用與類似。以上代碼中,我們把函數作為函數的第一個變量進行了傳遞。 在JavaScript中,一個函數可以作為另一個函數的參數。我們可以先定義一個函數,然后傳遞,也可以在傳遞參數的地方直接定義函數。 Node.js中函數的使用與Javascript類似。 funct...

    番茄西紅柿 評論0 收藏0

發表評論

0條評論

HelKyle

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<