Class: HttpMimic::Request
- Inherits:
-
Object
- Object
- HttpMimic::Request
- Defined in:
- lib/http_mimic/request.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(method, url, options = {}, config = nil) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(method, url, options = {}, config = nil) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 |
# File 'lib/http_mimic/request.rb', line 9 def initialize(method, url, = {}, config = nil) @method = method @url = url @options = .dup @config = config || HttpMimic.configuration end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/http_mimic/request.rb', line 7 def config @config end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/http_mimic/request.rb', line 7 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/http_mimic/request.rb', line 7 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/http_mimic/request.rb', line 7 def url @url end |
Instance Method Details
#perform ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/http_mimic/request.rb', line 16 def perform builder = CommandBuilder.new(method, url, , config) binary, args, stdin_data, final_url = builder.build full_command = [binary] + args log_debug("Executing HttpMimic command: #{full_command.join(' ')}") log_debug("Stdin data: #{stdin_data}") if stdin_data stdout, stderr, status = execute_open3(full_command, stdin_data) log_debug("Curl exit status: #{status.exitstatus}") log_debug("Curl stderr: #{stderr}") unless stderr.empty? response = ResponseParser.new( stdout, exit_status: status, stderr: stderr, command: full_command, request_url: final_url ).parse handle_errors(status, stderr, full_command, response) response end |