Class: Seahorse::Client::H2::Handler Private

Inherits:
Seahorse::Client::Handler show all
Defined in:
lib/seahorse/client/h2/handler.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Handler

#handler

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Handler

#initialize, #inspect

Constructor Details

This class inherits a constructor from Seahorse::Client::Handler

Instance Method Details

#call(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/seahorse/client/h2/handler.rb', line 29

def call(context)
  stream = nil
  begin
    conn = context.client.connection
    stream = conn.new_stream

    stream_mutex = Mutex.new
    close_condition = ConditionVariable.new
    sync_queue = Queue.new

    conn.connect(context.http_request.endpoint)
    _register_callbacks(
      context.http_response,
      stream,
      stream_mutex,
      close_condition,
      sync_queue
    )

    conn.debug_output("sending initial request ...")
    if input_emitter = context[:input_event_emitter]
      _send_initial_headers(context.http_request, stream)

      # prepare for sending events later
      input_emitter.stream = stream
      # request sigv4 serves as the initial #prior_signature
      input_emitter.encoder.prior_signature =
        context.http_request.headers['authorization'].split('Signature=').last
      input_emitter.validate_event = context.config.validate_params
    else
      _send_initial_headers(context.http_request, stream)
      _send_initial_data(context.http_request, stream)
    end

    conn.start(stream)
  rescue *NETWORK_ERRORS => error
    error = NetworkingError.new(
      error, error_message(context.http_request, error))
    context.http_response.signal_error(error)
  rescue => error
    conn.debug_output(error.inspect)
    # not retryable
    context.http_response.signal_error(error)
  end

  AsyncResponse.new(
    context: context,
    stream: stream,
    stream_mutex: stream_mutex,
    close_condition: close_condition,
    sync_queue: sync_queue
  )
end