httparty 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of httparty might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/Gemfile +1 -0
- data/httparty.gemspec +0 -1
- data/lib/httparty.rb +2 -18
- data/lib/httparty/connection_adapter.rb +10 -0
- data/lib/httparty/headers_processor.rb +30 -0
- data/lib/httparty/request.rb +4 -4
- data/lib/httparty/version.rb +1 -1
- metadata +4 -103
- data/features/basic_authentication.feature +0 -20
- data/features/command_line.feature +0 -95
- data/features/deals_with_http_error_codes.feature +0 -26
- data/features/digest_authentication.feature +0 -30
- data/features/handles_compressed_responses.feature +0 -27
- data/features/handles_multiple_formats.feature +0 -57
- data/features/steps/env.rb +0 -27
- data/features/steps/httparty_response_steps.rb +0 -56
- data/features/steps/httparty_steps.rb +0 -43
- data/features/steps/mongrel_helper.rb +0 -127
- data/features/steps/remote_service_steps.rb +0 -92
- data/features/supports_read_timeout_option.feature +0 -13
- data/features/supports_redirection.feature +0 -22
- data/features/supports_timeout_option.feature +0 -13
- data/spec/fixtures/delicious.xml +0 -23
- data/spec/fixtures/empty.xml +0 -0
- data/spec/fixtures/example.html +0 -10
- data/spec/fixtures/ssl/generate.sh +0 -29
- data/spec/fixtures/ssl/generated/bogushost.crt +0 -29
- data/spec/fixtures/ssl/generated/ca.crt +0 -31
- data/spec/fixtures/ssl/generated/ca.key +0 -52
- data/spec/fixtures/ssl/generated/selfsigned.crt +0 -29
- data/spec/fixtures/ssl/generated/server.crt +0 -30
- data/spec/fixtures/ssl/generated/server.key +0 -52
- data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
- data/spec/fixtures/tiny.gif +0 -0
- data/spec/fixtures/twitter.csv +0 -2
- data/spec/fixtures/twitter.json +0 -1
- data/spec/fixtures/twitter.xml +0 -403
- data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
- data/spec/httparty/connection_adapter_spec.rb +0 -628
- data/spec/httparty/cookie_hash_spec.rb +0 -100
- data/spec/httparty/exception_spec.rb +0 -45
- data/spec/httparty/hash_conversions_spec.rb +0 -58
- data/spec/httparty/logger/apache_formatter_spec.rb +0 -40
- data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
- data/spec/httparty/logger/logger_spec.rb +0 -43
- data/spec/httparty/logger/logstash_formatter_spec.rb +0 -44
- data/spec/httparty/net_digest_auth_spec.rb +0 -270
- data/spec/httparty/parser_spec.rb +0 -190
- data/spec/httparty/request/body_spec.rb +0 -165
- data/spec/httparty/request_spec.rb +0 -1389
- data/spec/httparty/response_fragment_spec.rb +0 -17
- data/spec/httparty/response_spec.rb +0 -374
- data/spec/httparty/ssl_spec.rb +0 -82
- data/spec/httparty_spec.rb +0 -943
- data/spec/spec_helper.rb +0 -57
- data/spec/support/ssl_test_helper.rb +0 -47
- data/spec/support/ssl_test_server.rb +0 -80
- data/spec/support/stub_response.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f061610c664e42b9d4d712d08fff7ca07f544f9a
|
4
|
+
data.tar.gz: 5e532cd3467fbb0e39bd8f87adc2364d505fbd5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99deed9c0f2786c0afb4944badd7dca54739c21a8e7f30308ce432397f552e0d7cc641be5603828d82eda8f3d7d5290875f01e8d35e89c522dd0222e4a428247
|
7
|
+
data.tar.gz: 691fc41871c19e7a2a3b220dbdb14165aa2aaa61439854822be74468d96caeaab96d874e6d6b41f0f95b226342250a2c7b45add712595d42640acd9bc0a4cd51
|
data/Changelog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.17.1
|
2
|
+
|
3
|
+
* [Pass options to dynamic block headers](https://github.com/jnunemaker/httparty/pull/661)
|
4
|
+
* [Normalize urls with URI adapter to allow International Domain Names support](https://github.com/jnunemaker/httparty/pull/668)
|
5
|
+
* [Add max_retries support](https://github.com/jnunemaker/httparty/pull/648)
|
6
|
+
* [Minize gem size by removing test files](https://github.com/jnunemaker/httparty/pull/658)
|
7
|
+
|
1
8
|
## 0.17.0
|
2
9
|
|
3
10
|
* [Fix encoding of streamed chunk](https://github.com/jnunemaker/httparty/pull/644)
|
data/Gemfile
CHANGED
data/httparty.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
26
|
|
27
27
|
s.files = all_files - test_files
|
28
|
-
s.test_files = test_files
|
29
28
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
30
29
|
s.require_paths = ["lib"]
|
31
30
|
end
|
data/lib/httparty.rb
CHANGED
@@ -17,6 +17,7 @@ require 'httparty/logger/logger'
|
|
17
17
|
require 'httparty/request/body'
|
18
18
|
require 'httparty/response_fragment'
|
19
19
|
require 'httparty/text_encoder'
|
20
|
+
require 'httparty/headers_processor'
|
20
21
|
|
21
22
|
# @see HTTParty::ClassMethods
|
22
23
|
module HTTParty
|
@@ -588,28 +589,11 @@ module HTTParty
|
|
588
589
|
|
589
590
|
def perform_request(http_method, path, options, &block) #:nodoc:
|
590
591
|
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
|
591
|
-
|
592
|
+
HeadersProcessor.new(headers, options).call
|
592
593
|
process_cookies(options)
|
593
594
|
Request.new(http_method, path, options).perform(&block)
|
594
595
|
end
|
595
596
|
|
596
|
-
def process_headers(options)
|
597
|
-
if options[:headers]
|
598
|
-
if headers.any?
|
599
|
-
options[:headers] = headers.merge(options[:headers])
|
600
|
-
end
|
601
|
-
|
602
|
-
options[:headers] = Utils.stringify_keys(process_dynamic_headers(options[:headers]))
|
603
|
-
end
|
604
|
-
end
|
605
|
-
|
606
|
-
def process_dynamic_headers(headers)
|
607
|
-
headers.each_with_object({}) do |header, processed_headers|
|
608
|
-
key, value = header
|
609
|
-
processed_headers[key] = value.respond_to?(:call) ? value.call : value
|
610
|
-
end
|
611
|
-
end
|
612
|
-
|
613
597
|
def process_cookies(options) #:nodoc:
|
614
598
|
return unless options[:cookies] || default_cookies.any?
|
615
599
|
options[:headers] ||= headers.dup
|
@@ -137,6 +137,12 @@ module HTTParty
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
if add_max_retries?(options[:max_retries])
|
141
|
+
from_ruby_version('2.5.0', option: :max_retries) do
|
142
|
+
http.max_retries = options[:max_retries]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
140
146
|
if options[:debug_output]
|
141
147
|
http.set_debug_output(options[:debug_output])
|
142
148
|
end
|
@@ -177,6 +183,10 @@ module HTTParty
|
|
177
183
|
timeout && (timeout.is_a?(Integer) || timeout.is_a?(Float))
|
178
184
|
end
|
179
185
|
|
186
|
+
def add_max_retries?(max_retries)
|
187
|
+
max_retries && max_retries.is_a?(Integer) && max_retries >= 0
|
188
|
+
end
|
189
|
+
|
180
190
|
def clean_host(host)
|
181
191
|
strip_ipv6_brackets(host)
|
182
192
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module HTTParty
|
2
|
+
class HeadersProcessor
|
3
|
+
attr_reader :headers, :options
|
4
|
+
|
5
|
+
def initialize(headers, options)
|
6
|
+
@headers = headers
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
return unless options[:headers]
|
12
|
+
|
13
|
+
options[:headers] = headers.merge(options[:headers]) if headers.any?
|
14
|
+
options[:headers] = Utils.stringify_keys(process_dynamic_headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def process_dynamic_headers
|
20
|
+
options[:headers].each_with_object({}) do |header, processed_headers|
|
21
|
+
key, value = header
|
22
|
+
processed_headers[key] = if value.respond_to?(:call)
|
23
|
+
value.arity == 0 ? value.call : value.call(options)
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/httparty/request.rb
CHANGED
@@ -71,7 +71,7 @@ module HTTParty
|
|
71
71
|
@path = if uri.is_a?(uri_adapter)
|
72
72
|
uri
|
73
73
|
elsif String.try_convert(uri)
|
74
|
-
uri_adapter.parse
|
74
|
+
uri_adapter.parse(uri).normalize
|
75
75
|
else
|
76
76
|
raise ArgumentError,
|
77
77
|
"bad argument (expected #{uri_adapter} object or URI string)"
|
@@ -95,9 +95,9 @@ module HTTParty
|
|
95
95
|
end
|
96
96
|
|
97
97
|
if path.relative? && path.host
|
98
|
-
new_uri = options[:uri_adapter].parse("#{@last_uri.scheme}:#{path}")
|
98
|
+
new_uri = options[:uri_adapter].parse("#{@last_uri.scheme}:#{path}").normalize
|
99
99
|
elsif path.relative?
|
100
|
-
new_uri = options[:uri_adapter].parse("#{base_uri}#{path}")
|
100
|
+
new_uri = options[:uri_adapter].parse("#{base_uri}#{path}").normalize
|
101
101
|
else
|
102
102
|
new_uri = path.clone
|
103
103
|
end
|
@@ -305,7 +305,7 @@ module HTTParty
|
|
305
305
|
|
306
306
|
def handle_host_redirection
|
307
307
|
check_duplicate_location_header
|
308
|
-
redirect_path = options[:uri_adapter].parse
|
308
|
+
redirect_path = options[:uri_adapter].parse(last_response['location']).normalize
|
309
309
|
return if redirect_path.relative? || path.host == redirect_path.host
|
310
310
|
@changed_hosts = true
|
311
311
|
end
|
data/lib/httparty/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|
@@ -84,26 +84,13 @@ files:
|
|
84
84
|
- examples/tripit_sign_in.rb
|
85
85
|
- examples/twitter.rb
|
86
86
|
- examples/whoismyrep.rb
|
87
|
-
- features/basic_authentication.feature
|
88
|
-
- features/command_line.feature
|
89
|
-
- features/deals_with_http_error_codes.feature
|
90
|
-
- features/digest_authentication.feature
|
91
|
-
- features/handles_compressed_responses.feature
|
92
|
-
- features/handles_multiple_formats.feature
|
93
|
-
- features/steps/env.rb
|
94
|
-
- features/steps/httparty_response_steps.rb
|
95
|
-
- features/steps/httparty_steps.rb
|
96
|
-
- features/steps/mongrel_helper.rb
|
97
|
-
- features/steps/remote_service_steps.rb
|
98
|
-
- features/supports_read_timeout_option.feature
|
99
|
-
- features/supports_redirection.feature
|
100
|
-
- features/supports_timeout_option.feature
|
101
87
|
- httparty.gemspec
|
102
88
|
- lib/httparty.rb
|
103
89
|
- lib/httparty/connection_adapter.rb
|
104
90
|
- lib/httparty/cookie_hash.rb
|
105
91
|
- lib/httparty/exceptions.rb
|
106
92
|
- lib/httparty/hash_conversions.rb
|
93
|
+
- lib/httparty/headers_processor.rb
|
107
94
|
- lib/httparty/logger/apache_formatter.rb
|
108
95
|
- lib/httparty/logger/curl_formatter.rb
|
109
96
|
- lib/httparty/logger/logger.rb
|
@@ -121,42 +108,6 @@ files:
|
|
121
108
|
- lib/httparty/utils.rb
|
122
109
|
- lib/httparty/version.rb
|
123
110
|
- script/release
|
124
|
-
- spec/fixtures/delicious.xml
|
125
|
-
- spec/fixtures/empty.xml
|
126
|
-
- spec/fixtures/example.html
|
127
|
-
- spec/fixtures/ssl/generate.sh
|
128
|
-
- spec/fixtures/ssl/generated/bogushost.crt
|
129
|
-
- spec/fixtures/ssl/generated/ca.crt
|
130
|
-
- spec/fixtures/ssl/generated/ca.key
|
131
|
-
- spec/fixtures/ssl/generated/selfsigned.crt
|
132
|
-
- spec/fixtures/ssl/generated/server.crt
|
133
|
-
- spec/fixtures/ssl/generated/server.key
|
134
|
-
- spec/fixtures/ssl/openssl-exts.cnf
|
135
|
-
- spec/fixtures/tiny.gif
|
136
|
-
- spec/fixtures/twitter.csv
|
137
|
-
- spec/fixtures/twitter.json
|
138
|
-
- spec/fixtures/twitter.xml
|
139
|
-
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
140
|
-
- spec/httparty/connection_adapter_spec.rb
|
141
|
-
- spec/httparty/cookie_hash_spec.rb
|
142
|
-
- spec/httparty/exception_spec.rb
|
143
|
-
- spec/httparty/hash_conversions_spec.rb
|
144
|
-
- spec/httparty/logger/apache_formatter_spec.rb
|
145
|
-
- spec/httparty/logger/curl_formatter_spec.rb
|
146
|
-
- spec/httparty/logger/logger_spec.rb
|
147
|
-
- spec/httparty/logger/logstash_formatter_spec.rb
|
148
|
-
- spec/httparty/net_digest_auth_spec.rb
|
149
|
-
- spec/httparty/parser_spec.rb
|
150
|
-
- spec/httparty/request/body_spec.rb
|
151
|
-
- spec/httparty/request_spec.rb
|
152
|
-
- spec/httparty/response_fragment_spec.rb
|
153
|
-
- spec/httparty/response_spec.rb
|
154
|
-
- spec/httparty/ssl_spec.rb
|
155
|
-
- spec/httparty_spec.rb
|
156
|
-
- spec/spec_helper.rb
|
157
|
-
- spec/support/ssl_test_helper.rb
|
158
|
-
- spec/support/ssl_test_server.rb
|
159
|
-
- spec/support/stub_response.rb
|
160
111
|
- website/css/common.css
|
161
112
|
- website/index.html
|
162
113
|
homepage: https://github.com/jnunemaker/httparty
|
@@ -183,54 +134,4 @@ rubygems_version: 2.6.14
|
|
183
134
|
signing_key:
|
184
135
|
specification_version: 4
|
185
136
|
summary: Makes http fun! Also, makes consuming restful web services dead easy.
|
186
|
-
test_files:
|
187
|
-
- features/basic_authentication.feature
|
188
|
-
- features/command_line.feature
|
189
|
-
- features/deals_with_http_error_codes.feature
|
190
|
-
- features/digest_authentication.feature
|
191
|
-
- features/handles_compressed_responses.feature
|
192
|
-
- features/handles_multiple_formats.feature
|
193
|
-
- features/steps/env.rb
|
194
|
-
- features/steps/httparty_response_steps.rb
|
195
|
-
- features/steps/httparty_steps.rb
|
196
|
-
- features/steps/mongrel_helper.rb
|
197
|
-
- features/steps/remote_service_steps.rb
|
198
|
-
- features/supports_read_timeout_option.feature
|
199
|
-
- features/supports_redirection.feature
|
200
|
-
- features/supports_timeout_option.feature
|
201
|
-
- spec/fixtures/delicious.xml
|
202
|
-
- spec/fixtures/empty.xml
|
203
|
-
- spec/fixtures/example.html
|
204
|
-
- spec/fixtures/ssl/generate.sh
|
205
|
-
- spec/fixtures/ssl/generated/bogushost.crt
|
206
|
-
- spec/fixtures/ssl/generated/ca.crt
|
207
|
-
- spec/fixtures/ssl/generated/ca.key
|
208
|
-
- spec/fixtures/ssl/generated/selfsigned.crt
|
209
|
-
- spec/fixtures/ssl/generated/server.crt
|
210
|
-
- spec/fixtures/ssl/generated/server.key
|
211
|
-
- spec/fixtures/ssl/openssl-exts.cnf
|
212
|
-
- spec/fixtures/tiny.gif
|
213
|
-
- spec/fixtures/twitter.csv
|
214
|
-
- spec/fixtures/twitter.json
|
215
|
-
- spec/fixtures/twitter.xml
|
216
|
-
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
217
|
-
- spec/httparty/connection_adapter_spec.rb
|
218
|
-
- spec/httparty/cookie_hash_spec.rb
|
219
|
-
- spec/httparty/exception_spec.rb
|
220
|
-
- spec/httparty/hash_conversions_spec.rb
|
221
|
-
- spec/httparty/logger/apache_formatter_spec.rb
|
222
|
-
- spec/httparty/logger/curl_formatter_spec.rb
|
223
|
-
- spec/httparty/logger/logger_spec.rb
|
224
|
-
- spec/httparty/logger/logstash_formatter_spec.rb
|
225
|
-
- spec/httparty/net_digest_auth_spec.rb
|
226
|
-
- spec/httparty/parser_spec.rb
|
227
|
-
- spec/httparty/request/body_spec.rb
|
228
|
-
- spec/httparty/request_spec.rb
|
229
|
-
- spec/httparty/response_fragment_spec.rb
|
230
|
-
- spec/httparty/response_spec.rb
|
231
|
-
- spec/httparty/ssl_spec.rb
|
232
|
-
- spec/httparty_spec.rb
|
233
|
-
- spec/spec_helper.rb
|
234
|
-
- spec/support/ssl_test_helper.rb
|
235
|
-
- spec/support/ssl_test_server.rb
|
236
|
-
- spec/support/stub_response.rb
|
137
|
+
test_files: []
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Feature: Basic Authentication
|
2
|
-
|
3
|
-
As a developer
|
4
|
-
I want to be able to use a service that requires Basic Authentication
|
5
|
-
Because that is not an uncommon requirement
|
6
|
-
|
7
|
-
Scenario: Passing no credentials to a page requiring Basic Authentication
|
8
|
-
Given a restricted page at '/basic_auth.html'
|
9
|
-
When I call HTTParty#get with '/basic_auth.html'
|
10
|
-
Then it should return a response with a 401 response code
|
11
|
-
|
12
|
-
Scenario: Passing proper credentials to a page requiring Basic Authentication
|
13
|
-
Given a remote service that returns 'Authenticated Page'
|
14
|
-
And that service is accessed at the path '/basic_auth.html'
|
15
|
-
And that service is protected by Basic Authentication
|
16
|
-
And that service requires the username 'jcash' with the password 'maninblack'
|
17
|
-
When I call HTTParty#get with '/basic_auth.html' and a basic_auth hash:
|
18
|
-
| username | password |
|
19
|
-
| jcash | maninblack |
|
20
|
-
Then the return value should match 'Authenticated Page'
|
@@ -1,95 +0,0 @@
|
|
1
|
-
@command_line
|
2
|
-
Feature: Command Line
|
3
|
-
|
4
|
-
As a developer
|
5
|
-
I want to be able to harness the power of HTTParty from the command line
|
6
|
-
Because that would make quick testing and debugging easy
|
7
|
-
|
8
|
-
Scenario: Show help information
|
9
|
-
When I run `httparty --help`
|
10
|
-
Then the output should contain "-f, --format [FORMAT]"
|
11
|
-
|
12
|
-
Scenario: Show current version
|
13
|
-
When I run `httparty --version`
|
14
|
-
Then the output should contain "Version:"
|
15
|
-
And the output should not contain "You need to provide a URL"
|
16
|
-
|
17
|
-
Scenario: Make a get request
|
18
|
-
Given a remote deflate service on port '4001'
|
19
|
-
And the response from the service has a body of 'GET request'
|
20
|
-
And that service is accessed at the path '/fun'
|
21
|
-
When I run `httparty http://0.0.0.0:4001/fun`
|
22
|
-
Then the output should contain "GET request"
|
23
|
-
|
24
|
-
Scenario: Make a post request
|
25
|
-
Given a remote deflate service on port '4002'
|
26
|
-
And the response from the service has a body of 'POST request'
|
27
|
-
And that service is accessed at the path '/fun'
|
28
|
-
When I run `httparty http://0.0.0.0:4002/fun --action post --data "a=1&b=2"`
|
29
|
-
Then the output should contain "POST request"
|
30
|
-
|
31
|
-
Scenario: Make a put request
|
32
|
-
Given a remote deflate service on port '4003'
|
33
|
-
And the response from the service has a body of 'PUT request'
|
34
|
-
And that service is accessed at the path '/fun'
|
35
|
-
When I run `httparty http://0.0.0.0:4003/fun --action put --data "a=1&b=2"`
|
36
|
-
Then the output should contain "PUT request"
|
37
|
-
|
38
|
-
Scenario: Make a delete request
|
39
|
-
Given a remote deflate service on port '4004'
|
40
|
-
And the response from the service has a body of 'DELETE request'
|
41
|
-
And that service is accessed at the path '/fun'
|
42
|
-
When I run `httparty http://0.0.0.0:4004/fun --action delete`
|
43
|
-
Then the output should contain "DELETE request"
|
44
|
-
|
45
|
-
Scenario: Set a verbose mode
|
46
|
-
Given a remote deflate service on port '4005'
|
47
|
-
And the response from the service has a body of 'Some request'
|
48
|
-
And that service is accessed at the path '/fun'
|
49
|
-
When I run `httparty http://0.0.0.0:4005/fun --verbose`
|
50
|
-
Then the output should contain "content-length"
|
51
|
-
|
52
|
-
Scenario: Use service with basic authentication
|
53
|
-
Given a remote deflate service on port '4006'
|
54
|
-
And the response from the service has a body of 'Successfull authentication'
|
55
|
-
And that service is accessed at the path '/fun'
|
56
|
-
And that service is protected by Basic Authentication
|
57
|
-
And that service requires the username 'user' with the password 'pass'
|
58
|
-
When I run `httparty http://0.0.0.0:4006/fun --user 'user:pass'`
|
59
|
-
Then the output should contain "Successfull authentication"
|
60
|
-
|
61
|
-
Scenario: Get response in plain format
|
62
|
-
Given a remote deflate service on port '4007'
|
63
|
-
And the response from the service has a body of 'Some request'
|
64
|
-
And that service is accessed at the path '/fun'
|
65
|
-
When I run `httparty http://0.0.0.0:4007/fun --format plain`
|
66
|
-
Then the output should contain "Some request"
|
67
|
-
|
68
|
-
Scenario: Get response in json format
|
69
|
-
Given a remote deflate service on port '4008'
|
70
|
-
Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
|
71
|
-
And that service is accessed at the path '/service.json'
|
72
|
-
And the response from the service has a Content-Type of 'application/json'
|
73
|
-
When I run `httparty http://0.0.0.0:4008/service.json --format json`
|
74
|
-
Then the output should contain '"jennings": "waylon"'
|
75
|
-
|
76
|
-
Scenario: Get response in xml format
|
77
|
-
Given a remote deflate service on port '4009'
|
78
|
-
Given a remote service that returns '<singer>waylon jennings</singer>'
|
79
|
-
And that service is accessed at the path '/service.xml'
|
80
|
-
And the response from the service has a Content-Type of 'text/xml'
|
81
|
-
When I run `httparty http://0.0.0.0:4009/service.xml --format xml`
|
82
|
-
Then the output should contain "<singer>"
|
83
|
-
|
84
|
-
Scenario: Get response in csv format
|
85
|
-
Given a remote deflate service on port '4010'
|
86
|
-
Given a remote service that returns:
|
87
|
-
"""
|
88
|
-
"Last Name","Name"
|
89
|
-
"jennings","waylon"
|
90
|
-
"cash","johnny"
|
91
|
-
"""
|
92
|
-
And that service is accessed at the path '/service.csv'
|
93
|
-
And the response from the service has a Content-Type of 'application/csv'
|
94
|
-
When I run `httparty http://0.0.0.0:4010/service.csv --format csv`
|
95
|
-
Then the output should contain '["Last Name", "Name"]'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Feature: Deals with HTTP error codes
|
2
|
-
|
3
|
-
As a developer
|
4
|
-
I want to be informed of non-successful responses
|
5
|
-
Because sometimes thing explode
|
6
|
-
And I should probably know what happened
|
7
|
-
|
8
|
-
Scenario: A response of '404 - Not Found'
|
9
|
-
Given a remote service that returns a 404 status code
|
10
|
-
And that service is accessed at the path '/404_service.html'
|
11
|
-
When I call HTTParty#get with '/404_service.html'
|
12
|
-
Then it should return a response with a 404 response code
|
13
|
-
|
14
|
-
Scenario: A response of '500 - Internal Server Error'
|
15
|
-
Given a remote service that returns a 500 status code
|
16
|
-
And that service is accessed at the path '/500_service.html'
|
17
|
-
When I call HTTParty#get with '/500_service.html'
|
18
|
-
Then it should return a response with a 500 response code
|
19
|
-
|
20
|
-
Scenario: A non-successful response where I need the body
|
21
|
-
Given a remote service that returns a 400 status code
|
22
|
-
And the response from the service has a body of 'Bad response'
|
23
|
-
And that service is accessed at the path '/400_service.html'
|
24
|
-
When I call HTTParty#get with '/400_service.html'
|
25
|
-
Then it should return a response with a 400 response code
|
26
|
-
And the return value should match 'Bad response'
|