Class: HttpCapture::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/http_capture.rb

Overview

Represents a captured request.

Direct Known Subclasses

HTTPClientRequest

Instance Method Summary collapse

Constructor Details

#initialize(real_request) ⇒ Request

Returns a new instance of Request.



9
10
11
# File 'lib/http_capture.rb', line 9

def initialize(real_request)
  @real_request = real_request
end

Instance Method Details

#methodObject

The request method as an upper-case string.



14
15
16
17
18
19
20
# File 'lib/http_capture.rb', line 14

def method
  if @real_request.respond_to?(:request_method)
    @real_request.request_method.to_s.upcase
  else
    @real_request.method.to_s.upcase
  end
end

#pathObject

The request path.



23
24
25
# File 'lib/http_capture.rb', line 23

def path
  @real_request.path
end

#uriObject

The complete request URI.



28
29
30
31
32
33
34
35
36
# File 'lib/http_capture.rb', line 28

def uri
  uri = if @real_request.respond_to?(:uri)
          @real_request.uri
        else
          @real_request.url
        end
  uri = URI.parse(uri.to_s) unless uri.is_a?(URI)
  uri
end