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