http-protocol 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module HTTP
22
+ module Protocol
23
+ module HTTP2
24
+ class Window
25
+ def initialize(capacity)
26
+ @used = 0
27
+ @capacity = capacity
28
+
29
+ fail unless capacity
30
+ end
31
+
32
+ def dup
33
+ return self.class.new(@capacity)
34
+ end
35
+
36
+ # The window is completely full?
37
+ def full?
38
+ @used == @capacity
39
+ end
40
+
41
+ attr_accessor :used
42
+ attr_accessor :capacity
43
+
44
+ def consume(amount)
45
+ @used += amount
46
+ end
47
+
48
+ def available
49
+ @capacity - @used
50
+ end
51
+
52
+ def available?
53
+ available > 0
54
+ end
55
+
56
+ def expand(amount)
57
+ @used -= amount
58
+ end
59
+
60
+ def limited?
61
+ @used > (@capacity / 2)
62
+ end
63
+ end
64
+
65
+ # The WINDOW_UPDATE frame is used to implement flow control.
66
+ #
67
+ # +-+-------------------------------------------------------------+
68
+ # |R| Window Size Increment (31) |
69
+ # +-+-------------------------------------------------------------+
70
+ #
71
+ class WindowUpdateFrame < Frame
72
+ TYPE = 0x8
73
+ FORMAT = "N"
74
+
75
+ def pack(window_size_increment)
76
+ super [window_size_increment].pack(FORMAT)
77
+ end
78
+
79
+ def unpack
80
+ super.unpack(FORMAT).first
81
+ end
82
+
83
+ def apply(connection)
84
+ connection.receive_window_update(self)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module HTTP
22
+ module Protocol
23
+ VERSION = "0.1.0"
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: http-protocol
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http-hpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - samuel.williams@oriontransfer.co.nz
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - http-protocol.gemspec
83
+ - lib/http/protocol.rb
84
+ - lib/http/protocol/error.rb
85
+ - lib/http/protocol/headers.rb
86
+ - lib/http/protocol/http2/client.rb
87
+ - lib/http/protocol/http2/connection.rb
88
+ - lib/http/protocol/http2/continuation_frame.rb
89
+ - lib/http/protocol/http2/data_frame.rb
90
+ - lib/http/protocol/http2/flow_control.rb
91
+ - lib/http/protocol/http2/frame.rb
92
+ - lib/http/protocol/http2/framer.rb
93
+ - lib/http/protocol/http2/goaway_frame.rb
94
+ - lib/http/protocol/http2/headers_frame.rb
95
+ - lib/http/protocol/http2/padded.rb
96
+ - lib/http/protocol/http2/ping_frame.rb
97
+ - lib/http/protocol/http2/priority_frame.rb
98
+ - lib/http/protocol/http2/push_promise_frame.rb
99
+ - lib/http/protocol/http2/reset_stream_frame.rb
100
+ - lib/http/protocol/http2/server.rb
101
+ - lib/http/protocol/http2/settings_frame.rb
102
+ - lib/http/protocol/http2/stream.rb
103
+ - lib/http/protocol/http2/window_update_frame.rb
104
+ - lib/http/protocol/version.rb
105
+ homepage: https://github.com/socketry/http-protocol
106
+ licenses: []
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.7.6
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Provides abstractions to handle HTTP1 and HTTP2 protocols.
128
+ test_files: []