You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

4 years ago
  1. # spdy-transport
  2. [![Build Status](https://travis-ci.org/spdy-http2/spdy-transport.svg?branch=master)](http://travis-ci.org/spdy-http2/spdy-transport)
  3. [![NPM version](https://badge.fury.io/js/spdy-transport.svg)](http://badge.fury.io/js/spdy-transport)
  4. [![dependencies Status](https://david-dm.org/spdy-http2/spdy-transport/status.svg?style=flat-square)](https://david-dm.org/spdy-http2/spdy-transport)
  5. [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)
  6. [![Waffle](https://img.shields.io/badge/track-waffle-blue.svg?style=flat-square)](https://waffle.io/spdy-http2/node-spdy)
  7. > SPDY/HTTP2 generic transport implementation.
  8. ## Usage
  9. ```javascript
  10. var transport = require('spdy-transport');
  11. // NOTE: socket is some stream or net.Socket instance, may be an argument
  12. // of `net.createServer`'s connection handler.
  13. var server = transport.connection.create(socket, {
  14. protocol: 'http2',
  15. isServer: true
  16. });
  17. server.on('stream', function(stream) {
  18. console.log(stream.method, stream.path, stream.headers);
  19. stream.respond(200, {
  20. header: 'value'
  21. });
  22. stream.on('readable', function() {
  23. var chunk = stream.read();
  24. if (!chunk)
  25. return;
  26. console.log(chunk);
  27. });
  28. stream.on('end', function() {
  29. console.log('end');
  30. });
  31. // And other node.js Stream APIs
  32. // ...
  33. });
  34. ```
  35. ## LICENSE
  36. This software is licensed under the MIT License.
  37. Copyright Fedor Indutny, 2015.
  38. Permission is hereby granted, free of charge, to any person obtaining a
  39. copy of this software and associated documentation files (the
  40. "Software"), to deal in the Software without restriction, including
  41. without limitation the rights to use, copy, modify, merge, publish,
  42. distribute, sublicense, and/or sell copies of the Software, and to permit
  43. persons to whom the Software is furnished to do so, subject to the
  44. following conditions:
  45. The above copyright notice and this permission notice shall be included
  46. in all copies or substantial portions of the Software.
  47. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  48. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  49. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  50. NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  51. DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  52. OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  53. USE OR OTHER DEALINGS IN THE SOFTWARE.
  54. [0]: http://json.org/
  55. [1]: http://github.com/indutny/bud-backend
  56. [2]: https://github.com/nodejs/io.js
  57. [3]: https://github.com/libuv/libuv
  58. [4]: http://openssl.org/