Skip to content

Commit

Permalink
Merge pull request #22 from lepidum/draft-14-settings-sync
Browse files Browse the repository at this point in the history
Fix remote and local confusions.
  • Loading branch information
igrigorik committed Nov 1, 2014
2 parents abd7d1e + dc542ca commit b6f1275
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 118 deletions.
21 changes: 14 additions & 7 deletions lib/http/2/client.rb
Expand Up @@ -22,7 +22,10 @@ class Client < Connection
# Initialize new HTTP 2.0 client object.
def initialize(**settings)
@stream_id = 1
@state = :connection_header
@state = :waiting_connection_preface

@local_role = :client
@remote_role = :server

super
end
Expand All @@ -31,19 +34,23 @@ def initialize(**settings)
# by Connection class.
#
# @see Connection
# @note Client will emit the connection header as the first 24 bytes
# @param frame [Hash]
def send(frame)
if @state == :connection_header
send_connection_preface
super(frame)
end

# Emit the connection preface if not yet
def send_connection_preface
if @state == :waiting_connection_preface
@state = :connected
emit(:frame, CONNECTION_HEADER)
emit(:frame, CONNECTION_PREFACE_MAGIC)

payload = @settings.select {|k,v| v != SPEC_DEFAULT_CONNECTION_SETTINGS[k]}
payload = @local_settings.select {|k,v| v != SPEC_DEFAULT_CONNECTION_SETTINGS[k]}
settings(payload)
end

super(frame)
end

end

end

0 comments on commit b6f1275

Please sign in to comment.