Class: Bidi2pdf::Bidi::AddHeadersInterceptor

Inherits:
Object
  • Object
show all
Includes:
Interceptor
Defined in:
lib/bidi2pdf/bidi/add_headers_interceptor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Interceptor

#client, #handle_event, included, #interceptor_id, #register_with_client, #unregister_with_client, #validate_phases!

Constructor Details

#initialize(headers:, url_patterns:, context:) ⇒ AddHeadersInterceptor

Returns a new instance of AddHeadersInterceptor.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 18

def initialize(headers:, url_patterns:, context:)
  @headers = headers.map do |header|
    {
      name: header[:name],
      value: {
        type: "string",
        value: header[:value]
      }
    }
  end

  @url_patterns = url_patterns
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



16
17
18
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 16

def context
  @context
end

#headersObject (readonly)

Returns the value of attribute headers.



16
17
18
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 16

def headers
  @headers
end

#url_patternsObject (readonly)

Returns the value of attribute url_patterns.



16
17
18
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 16

def url_patterns
  @url_patterns
end

Class Method Details

.eventsObject



13
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 13

def events = ["network.beforeRequestSent"]

.phasesObject



11
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 11

def phases = [Bidi2pdf::Bidi::Commands::AddIntercept::BEFORE_REQUEST]

Instance Method Details

#process_interception(_event_response, _navigation_id, network_id, _url) ⇒ Object



33
34
35
36
# File 'lib/bidi2pdf/bidi/add_headers_interceptor.rb', line 33

def process_interception(_event_response, _navigation_id, network_id, _url)
  cmd = Bidi2pdf::Bidi::Commands::NetworkContinue.new request: network_id, headers: headers
  client.send_cmd cmd
end