resat 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/api_request.rb +11 -9
- data/lib/resat.rb +1 -1
- metadata +2 -2
data/lib/api_request.rb
CHANGED
@@ -7,7 +7,7 @@ require 'rexml/document'
|
|
7
7
|
require File.join(File.dirname(__FILE__), 'net_patch')
|
8
8
|
|
9
9
|
module Resat
|
10
|
-
|
10
|
+
|
11
11
|
class ApiRequest
|
12
12
|
include Kwalify::Util::HashLike
|
13
13
|
attr_reader :request, :response, :send_count, :failures
|
@@ -24,11 +24,13 @@ module Resat
|
|
24
24
|
@headers ||= []
|
25
25
|
@params ||= []
|
26
26
|
# Clone config values so we don't mess with them when expanding variables
|
27
|
-
config.headers.each do |h|
|
28
|
-
@headers
|
27
|
+
config.headers.each do |h|
|
28
|
+
value = @headers.detect { |header| header['name'] == h['name'] }
|
29
|
+
@headers << { 'name' => h['name'].dup, 'value' => h['value'].dup } unless value
|
29
30
|
end if config.headers
|
30
31
|
config.params.each do |p|
|
31
|
-
@params
|
32
|
+
value = @params.detect { |header| header['name'] == h['name'] }
|
33
|
+
@params << { 'name' => h['name'].dup, 'value' => h['value'].dup } unless value
|
32
34
|
end if config.params && request_class.REQUEST_HAS_BODY
|
33
35
|
variables.substitute!(@params)
|
34
36
|
variables.substitute!(@headers)
|
@@ -77,7 +79,7 @@ module Resat
|
|
77
79
|
variables.substitute!(username) if username
|
78
80
|
password = @password || config.password
|
79
81
|
variables.substitute!(password) if password
|
80
|
-
if username && password
|
82
|
+
if username && password
|
81
83
|
@request.basic_auth(username, password)
|
82
84
|
end
|
83
85
|
form_data = Hash.new
|
@@ -90,7 +92,7 @@ module Resat
|
|
90
92
|
@oks = @valid_codes.map { |r| r.to_s } if @valid_codes
|
91
93
|
@oks ||= %w{200 201 202 203 204 205 206}
|
92
94
|
end
|
93
|
-
|
95
|
+
|
94
96
|
# Actually send the request
|
95
97
|
def send
|
96
98
|
sleep(delay_seconds) # Delay request if needed
|
@@ -111,12 +113,12 @@ module Resat
|
|
111
113
|
end
|
112
114
|
end
|
113
115
|
end
|
114
|
-
|
115
|
-
# Does response include given header or body field?
|
116
|
+
|
117
|
+
# Does response include given header or body field?
|
116
118
|
def has_response_field?(field, target)
|
117
119
|
!!get_response_field(field, target)
|
118
120
|
end
|
119
|
-
|
121
|
+
|
120
122
|
# Get value of response header or body field
|
121
123
|
def get_response_field(field, target)
|
122
124
|
return unless @response
|
data/lib/resat.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Simon
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-06-
|
12
|
+
date: 2010-06-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|