index.js (4700B)
1 // This is an implementation of the [HTTP/2][http2] 2 // framing layer for [node.js][node]. 3 // 4 // The main building blocks are [node.js streams][node-stream] that are connected through pipes. 5 // 6 // The main components are: 7 // 8 // * [Endpoint](endpoint.html): represents an HTTP/2 endpoint (client or server). It's 9 // responsible for the the first part of the handshake process (sending/receiving the 10 // [connection header][http2-connheader]) and manages other components (framer, compressor, 11 // connection, streams) that make up a client or server. 12 // 13 // * [Connection](connection.html): multiplexes the active HTTP/2 streams, manages connection 14 // lifecycle and settings, and responsible for enforcing the connection level limits (flow 15 // control, initiated stream limit) 16 // 17 // * [Stream](stream.html): implementation of the [HTTP/2 stream concept][http2-stream]. 18 // Implements the [stream state machine][http2-streamstate] defined by the standard, provides 19 // management methods and events for using the stream (sending/receiving headers, data, etc.), 20 // and enforces stream level constraints (flow control, sending only legal frames). 21 // 22 // * [Flow](flow.html): implements flow control for Connection and Stream as parent class. 23 // 24 // * [Compressor and Decompressor](compressor.html): compression and decompression of HEADER and 25 // PUSH_PROMISE frames 26 // 27 // * [Serializer and Deserializer](framer.html): the lowest layer in the stack that transforms 28 // between the binary and the JavaScript object representation of HTTP/2 frames 29 // 30 // [http2]: https://tools.ietf.org/html/rfc7540 31 // [http2-connheader]: https://tools.ietf.org/html/rfc7540#section-3.5 32 // [http2-stream]: https://tools.ietf.org/html/rfc7540#section-5 33 // [http2-streamstate]: https://tools.ietf.org/html/rfc7540#section-5.1 34 // [node]: https://nodejs.org/ 35 // [node-stream]: https://nodejs.org/api/stream.html 36 // [node-https]: https://nodejs.org/api/https.html 37 // [node-http]: https://nodejs.org/api/http.html 38 39 exports.VERSION = 'h2'; 40 41 exports.Endpoint = require('./endpoint').Endpoint; 42 43 /* Bunyan serializers exported by submodules that are worth adding when creating a logger. */ 44 exports.serializers = {}; 45 var modules = ['./framer', './compressor', './flow', './connection', './stream', './endpoint']; 46 modules.map(require).forEach(function(module) { 47 for (var name in module.serializers) { 48 exports.serializers[name] = module.serializers[name]; 49 } 50 }); 51 52 /* 53 Stream API Endpoint API 54 Stream data 55 56 | ^ | ^ 57 | | | | 58 | | | | 59 +-----------|------------|---------------------------------------+ 60 | | | Endpoint | 61 | | | | 62 | +-------|------------|-----------------------------------+ | 63 | | | | Connection | | 64 | | v | | | 65 | | +-----------------------+ +-------------------- | | 66 | | | Stream | | Stream ... | | 67 | | +-----------------------+ +-------------------- | | 68 | | | ^ | ^ | | 69 | | v | v | | | 70 | | +------------+--+--------+--+------------+- ... | | 71 | | | ^ | | 72 | | | | | | 73 | +-----------------------|--------|-----------------------+ | 74 | | | | 75 | v | | 76 | +--------------------------+ +--------------------------+ | 77 | | Compressor | | Decompressor | | 78 | +--------------------------+ +--------------------------+ | 79 | | ^ | 80 | v | | 81 | +--------------------------+ +--------------------------+ | 82 | | Serializer | | Deserializer | | 83 | +--------------------------+ +--------------------------+ | 84 | | ^ | 85 +---------------------------|--------|---------------------------+ 86 | | 87 v | 88 89 Raw data 90 91 */