Skip to content

Commit

Permalink
Merge branch 'master' into rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Jun 10, 2024
2 parents 1262eeb + dfe8629 commit 52f0df3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Style/Documentation:
- 'test/**/*'
- 'example/helper.rb'
- 'example/upgrade_server.rb'
- 'lib/tasks/generate_huffman_table.rb'
- 'tasks/generate_huffman_table.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'
require 'open3'
require_relative 'lib/tasks/generate_huffman_table'

require_relative 'tasks/generate_huffman_table'

RSpec::Core::RakeTask.new(:spec) do |t|
t.exclude_pattern = './spec/hpack_test_spec.rb'
Expand Down
9 changes: 6 additions & 3 deletions example/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@
stream = conn.new_stream
log = Logger.new(stream.id)

conn_mutex = Mutex.new # Synchronize writing to socket
conn.on(:frame) do |bytes|
# puts "Sending bytes: #{bytes.unpack("H*").first}"
sock.print bytes
sock.flush
conn_mutex.synchronize do # Make sure that only one frame is sent at a time
# puts "Sending bytes: #{bytes.unpack("H*").first}"
sock.print bytes
sock.flush
end
end
conn.on(:frame_sent) do |frame|
puts "Sent frame: #{frame.inspect}"
Expand Down
7 changes: 5 additions & 2 deletions example/upgrade_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ def request_header_hash
end
end

conn_mutex = Mutex.new # Synchronize writing to socket
conn.on(:frame) do |bytes|
sock.print bytes
sock.flush
conn_mutex.synchronize do # Make sure that only one frame is sent at a time
sock.print bytes
sock.flush
end
end
conn.on(:frame_sent) do |frame|
puts "Sent frame: #{frame.inspect}"
Expand Down
6 changes: 2 additions & 4 deletions lib/http/2/compressor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def size_check(cmd)
# Responsible for encoding header key-value pairs using HPACK algorithm.
class Compressor
# @param options [Hash] encoding options
# @see EncodingContext#initialize
def initialize(**options)
@cc = EncodingContext.new(**options)
end
Expand Down Expand Up @@ -467,12 +468,9 @@ def encode(headers)
# Responsible for decoding received headers and maintaining compression
# context of the opposing peer. Decompressor must be initialized with
# appropriate starting context based on local role: client or server.
#
# @example
# server_role = Decompressor.new(:request)
# client_role = Decompressor.new(:response)
class Decompressor
# @param options [Hash] decoding options. Only :table_size is effective.
# @see EncodingContext#initialize
def initialize(**options)
@cc = EncodingContext.new(**options)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

require_relative '../lib/http/2/huffman'

# TODO: Currently, regenerating this table will produce something different from
# the table shipped with this gem. It is however stable.
desc 'Generate Huffman precompiled table in huffman_statemachine.rb'
task :generate_table do
task :generate_huffman_table do
HuffmanTable::Node.generate_state_table
end

require_relative '../http/2/huffman'

# @private
module HuffmanTable
BITS_AT_ONCE = HTTP2::Header::Huffman::BITS_AT_ONCE
EOS = 256
Expand Down

0 comments on commit 52f0df3

Please sign in to comment.