spec/helper.rb in http-2-0.6.3 vs spec/helper.rb in http-2-0.7.0
- old
+ new
@@ -1,11 +1,27 @@
-require 'http/2'
+begin
+ if RSpec::Core::Version::STRING.to_i >= 3
+ # Disable deprecation warnings for newer RSpec
+ RSpec.configure do |config|
+ config.expect_with :rspec do |c|
+ c.syntax = [:should, :expect]
+ end
+ config.mock_with :rspec do |c|
+ c.syntax = [:should, :expect]
+ end
+ end
+ end
+rescue Exception
+end
+
require 'json'
require 'coveralls'
Coveralls.wear! if ENV["CI"]
+require 'http/2'
+
include HTTP2
include HTTP2::Header
include HTTP2::Error
DATA = {
@@ -17,24 +33,26 @@
HEADERS = {
type: :headers,
flags: [:end_headers],
stream: 1,
- payload: 'header-block'
+ payload: Compressor.new.encode([['a','b']])
}
HEADERS_END_STREAM = {
type: :headers,
flags: [:end_headers, :end_stream],
stream: 1,
- payload: 'header-block'
+ payload: Compressor.new.encode([['a','b']])
}
PRIORITY = {
type: :priority,
stream: 1,
- priority: 15
+ exclusive: false,
+ stream_dependency: 0,
+ weight: 20,
}
RST_STREAM = {
type: :rst_stream,
stream: 1,
@@ -42,22 +60,22 @@
}
SETTINGS = {
type: :settings,
stream: 0,
- payload: {
- settings_max_concurrent_streams: 10,
- settings_flow_control_options: 1
- }
+ payload: [
+ [:settings_max_concurrent_streams, 10],
+ [:settings_initial_window_size, 0x7fffffff],
+ ]
}
PUSH_PROMISE = {
type: :push_promise,
- flags: [:end_push_promise],
+ flags: [:end_headers],
stream: 1,
promise_stream: 2,
- payload: 'headers'
+ payload: Compressor.new.encode([['a','b']])
}
PING = {
stream: 0,
type: :ping,
@@ -65,11 +83,11 @@
}
PONG = {
stream: 0,
type: :ping,
- flags: [:pong],
+ flags: [:ack],
payload: '12345678'
}
GOAWAY = {
type: :goaway,
@@ -87,16 +105,25 @@
type: :continuation,
flags: [:end_headers],
payload: '-second-block'
}
+ALTSVC = {
+ type: :altsvc,
+ max_age: 1402290402, # 4
+ port: 8080, # 2 reserved 1
+ proto: 'h2-12', # 1 + 5
+ host: 'www.example.com', # 1 + 15
+ origin: 'www.example.com', # 15
+}
+
FRAME_TYPES = [
DATA, HEADERS, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE,
- PING, GOAWAY, WINDOW_UPDATE, CONTINUATION
+ PING, GOAWAY, WINDOW_UPDATE, CONTINUATION, ALTSVC
]
def set_stream_id(bytes, id)
- head = bytes.slice!(0,8).unpack('nCCN')
- head[3] = id
+ head = bytes.slice!(0,9).unpack('CnCCN')
+ head[4] = id
- head.pack('nCCN') + bytes
+ head.pack('CnCCN') + bytes
end