httparty 0.14.0 → 0.20.0
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 +5 -5
- data/.editorconfig +18 -0
- data/.github/workflows/ci.yml +23 -0
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +1 -1
- data/{History → Changelog.md} +216 -63
- data/Gemfile +6 -1
- data/README.md +8 -8
- data/bin/httparty +3 -1
- data/docs/README.md +108 -37
- data/examples/README.md +34 -12
- data/examples/aaws.rb +7 -3
- data/examples/body_stream.rb +14 -0
- data/examples/crack.rb +1 -1
- data/examples/custom_parsers.rb +5 -1
- data/examples/delicious.rb +4 -4
- data/examples/headers_and_user_agents.rb +7 -3
- data/examples/idn.rb +10 -0
- data/examples/logging.rb +4 -4
- data/examples/microsoft_graph.rb +52 -0
- data/examples/multipart.rb +22 -0
- data/examples/peer_cert.rb +9 -0
- data/examples/stackexchange.rb +1 -1
- data/examples/stream_download.rb +26 -0
- data/examples/tripit_sign_in.rb +1 -1
- data/examples/twitter.rb +2 -2
- data/examples/whoismyrep.rb +1 -1
- data/httparty.gemspec +7 -4
- data/lib/httparty/connection_adapter.rb +73 -16
- data/lib/httparty/cookie_hash.rb +10 -8
- data/lib/httparty/decompressor.rb +92 -0
- data/lib/httparty/exceptions.rb +4 -1
- data/lib/httparty/hash_conversions.rb +30 -12
- data/lib/httparty/headers_processor.rb +32 -0
- data/lib/httparty/logger/apache_formatter.rb +31 -6
- data/lib/httparty/logger/curl_formatter.rb +9 -7
- data/lib/httparty/logger/logger.rb +5 -1
- data/lib/httparty/logger/logstash_formatter.rb +61 -0
- data/lib/httparty/module_inheritable_attributes.rb +6 -4
- data/lib/httparty/net_digest_auth.rb +19 -19
- data/lib/httparty/parser.rb +25 -14
- data/lib/httparty/request/body.rb +98 -0
- data/lib/httparty/request/multipart_boundary.rb +13 -0
- data/lib/httparty/request.rb +137 -110
- data/lib/httparty/response/headers.rb +23 -19
- data/lib/httparty/response.rb +81 -22
- data/lib/httparty/response_fragment.rb +21 -0
- data/lib/httparty/text_encoder.rb +72 -0
- data/lib/httparty/utils.rb +13 -0
- data/lib/httparty/version.rb +3 -1
- data/lib/httparty.rb +79 -30
- data/website/css/common.css +1 -1
- metadata +37 -103
- data/.travis.yml +0 -9
- 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/google.html +0 -3
- data/spec/fixtures/ssl/generate.sh +0 -29
- data/spec/fixtures/ssl/generated/1fe462c2.0 +0 -16
- data/spec/fixtures/ssl/generated/bogushost.crt +0 -13
- data/spec/fixtures/ssl/generated/ca.crt +0 -16
- data/spec/fixtures/ssl/generated/ca.key +0 -15
- data/spec/fixtures/ssl/generated/selfsigned.crt +0 -14
- data/spec/fixtures/ssl/generated/server.crt +0 -13
- data/spec/fixtures/ssl/generated/server.key +0 -15
- data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
- 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 -495
- 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 -49
- data/spec/httparty/logger/apache_formatter_spec.rb +0 -41
- data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
- data/spec/httparty/logger/logger_spec.rb +0 -38
- data/spec/httparty/net_digest_auth_spec.rb +0 -240
- data/spec/httparty/parser_spec.rb +0 -173
- data/spec/httparty/request_spec.rb +0 -1183
- data/spec/httparty/response_spec.rb +0 -291
- data/spec/httparty/ssl_spec.rb +0 -74
- data/spec/httparty_spec.rb +0 -872
- data/spec/spec_helper.rb +0 -59
- 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 -49
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.
|
4
|
+
version: 0.20.0
|
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:
|
12
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.5.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mime-types
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.0'
|
28
42
|
description: Makes http fun! Also, makes consuming restful web services dead easy.
|
29
43
|
email:
|
30
44
|
- nunemaker@gmail.com
|
@@ -33,15 +47,16 @@ executables:
|
|
33
47
|
extensions: []
|
34
48
|
extra_rdoc_files: []
|
35
49
|
files:
|
50
|
+
- ".editorconfig"
|
51
|
+
- ".github/workflows/ci.yml"
|
36
52
|
- ".gitignore"
|
37
53
|
- ".rubocop.yml"
|
38
54
|
- ".rubocop_todo.yml"
|
39
55
|
- ".simplecov"
|
40
|
-
- ".travis.yml"
|
41
56
|
- CONTRIBUTING.md
|
57
|
+
- Changelog.md
|
42
58
|
- Gemfile
|
43
59
|
- Guardfile
|
44
|
-
- History
|
45
60
|
- MIT-LICENSE
|
46
61
|
- README.md
|
47
62
|
- Rakefile
|
@@ -51,86 +66,53 @@ files:
|
|
51
66
|
- examples/README.md
|
52
67
|
- examples/aaws.rb
|
53
68
|
- examples/basic.rb
|
69
|
+
- examples/body_stream.rb
|
54
70
|
- examples/crack.rb
|
55
71
|
- examples/custom_parsers.rb
|
56
72
|
- examples/delicious.rb
|
57
73
|
- examples/google.rb
|
58
74
|
- examples/headers_and_user_agents.rb
|
75
|
+
- examples/idn.rb
|
59
76
|
- examples/logging.rb
|
77
|
+
- examples/microsoft_graph.rb
|
78
|
+
- examples/multipart.rb
|
60
79
|
- examples/nokogiri_html_parser.rb
|
80
|
+
- examples/peer_cert.rb
|
61
81
|
- examples/rescue_json.rb
|
62
82
|
- examples/rubyurl.rb
|
63
83
|
- examples/stackexchange.rb
|
84
|
+
- examples/stream_download.rb
|
64
85
|
- examples/tripit_sign_in.rb
|
65
86
|
- examples/twitter.rb
|
66
87
|
- examples/whoismyrep.rb
|
67
|
-
- features/basic_authentication.feature
|
68
|
-
- features/command_line.feature
|
69
|
-
- features/deals_with_http_error_codes.feature
|
70
|
-
- features/digest_authentication.feature
|
71
|
-
- features/handles_compressed_responses.feature
|
72
|
-
- features/handles_multiple_formats.feature
|
73
|
-
- features/steps/env.rb
|
74
|
-
- features/steps/httparty_response_steps.rb
|
75
|
-
- features/steps/httparty_steps.rb
|
76
|
-
- features/steps/mongrel_helper.rb
|
77
|
-
- features/steps/remote_service_steps.rb
|
78
|
-
- features/supports_read_timeout_option.feature
|
79
|
-
- features/supports_redirection.feature
|
80
|
-
- features/supports_timeout_option.feature
|
81
88
|
- httparty.gemspec
|
82
89
|
- lib/httparty.rb
|
83
90
|
- lib/httparty/connection_adapter.rb
|
84
91
|
- lib/httparty/cookie_hash.rb
|
92
|
+
- lib/httparty/decompressor.rb
|
85
93
|
- lib/httparty/exceptions.rb
|
86
94
|
- lib/httparty/hash_conversions.rb
|
95
|
+
- lib/httparty/headers_processor.rb
|
87
96
|
- lib/httparty/logger/apache_formatter.rb
|
88
97
|
- lib/httparty/logger/curl_formatter.rb
|
89
98
|
- lib/httparty/logger/logger.rb
|
99
|
+
- lib/httparty/logger/logstash_formatter.rb
|
90
100
|
- lib/httparty/module_inheritable_attributes.rb
|
91
101
|
- lib/httparty/net_digest_auth.rb
|
92
102
|
- lib/httparty/parser.rb
|
93
103
|
- lib/httparty/request.rb
|
104
|
+
- lib/httparty/request/body.rb
|
105
|
+
- lib/httparty/request/multipart_boundary.rb
|
94
106
|
- lib/httparty/response.rb
|
95
107
|
- lib/httparty/response/headers.rb
|
108
|
+
- lib/httparty/response_fragment.rb
|
109
|
+
- lib/httparty/text_encoder.rb
|
110
|
+
- lib/httparty/utils.rb
|
96
111
|
- lib/httparty/version.rb
|
97
112
|
- script/release
|
98
|
-
- spec/fixtures/delicious.xml
|
99
|
-
- spec/fixtures/empty.xml
|
100
|
-
- spec/fixtures/google.html
|
101
|
-
- spec/fixtures/ssl/generate.sh
|
102
|
-
- spec/fixtures/ssl/generated/1fe462c2.0
|
103
|
-
- spec/fixtures/ssl/generated/bogushost.crt
|
104
|
-
- spec/fixtures/ssl/generated/ca.crt
|
105
|
-
- spec/fixtures/ssl/generated/ca.key
|
106
|
-
- spec/fixtures/ssl/generated/selfsigned.crt
|
107
|
-
- spec/fixtures/ssl/generated/server.crt
|
108
|
-
- spec/fixtures/ssl/generated/server.key
|
109
|
-
- spec/fixtures/ssl/openssl-exts.cnf
|
110
|
-
- spec/fixtures/twitter.csv
|
111
|
-
- spec/fixtures/twitter.json
|
112
|
-
- spec/fixtures/twitter.xml
|
113
|
-
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
114
|
-
- spec/httparty/connection_adapter_spec.rb
|
115
|
-
- spec/httparty/cookie_hash_spec.rb
|
116
|
-
- spec/httparty/exception_spec.rb
|
117
|
-
- spec/httparty/hash_conversions_spec.rb
|
118
|
-
- spec/httparty/logger/apache_formatter_spec.rb
|
119
|
-
- spec/httparty/logger/curl_formatter_spec.rb
|
120
|
-
- spec/httparty/logger/logger_spec.rb
|
121
|
-
- spec/httparty/net_digest_auth_spec.rb
|
122
|
-
- spec/httparty/parser_spec.rb
|
123
|
-
- spec/httparty/request_spec.rb
|
124
|
-
- spec/httparty/response_spec.rb
|
125
|
-
- spec/httparty/ssl_spec.rb
|
126
|
-
- spec/httparty_spec.rb
|
127
|
-
- spec/spec_helper.rb
|
128
|
-
- spec/support/ssl_test_helper.rb
|
129
|
-
- spec/support/ssl_test_server.rb
|
130
|
-
- spec/support/stub_response.rb
|
131
113
|
- website/css/common.css
|
132
114
|
- website/index.html
|
133
|
-
homepage:
|
115
|
+
homepage: https://github.com/jnunemaker/httparty
|
134
116
|
licenses:
|
135
117
|
- MIT
|
136
118
|
metadata: {}
|
@@ -142,63 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
124
|
requirements:
|
143
125
|
- - ">="
|
144
126
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
127
|
+
version: 2.3.0
|
146
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
129
|
requirements:
|
148
130
|
- - ">="
|
149
131
|
- !ruby/object:Gem::Version
|
150
132
|
version: '0'
|
151
133
|
requirements: []
|
152
|
-
|
153
|
-
rubygems_version: 2.4.5.1
|
134
|
+
rubygems_version: 3.0.3
|
154
135
|
signing_key:
|
155
136
|
specification_version: 4
|
156
137
|
summary: Makes http fun! Also, makes consuming restful web services dead easy.
|
157
|
-
test_files:
|
158
|
-
- features/basic_authentication.feature
|
159
|
-
- features/command_line.feature
|
160
|
-
- features/deals_with_http_error_codes.feature
|
161
|
-
- features/digest_authentication.feature
|
162
|
-
- features/handles_compressed_responses.feature
|
163
|
-
- features/handles_multiple_formats.feature
|
164
|
-
- features/steps/env.rb
|
165
|
-
- features/steps/httparty_response_steps.rb
|
166
|
-
- features/steps/httparty_steps.rb
|
167
|
-
- features/steps/mongrel_helper.rb
|
168
|
-
- features/steps/remote_service_steps.rb
|
169
|
-
- features/supports_read_timeout_option.feature
|
170
|
-
- features/supports_redirection.feature
|
171
|
-
- features/supports_timeout_option.feature
|
172
|
-
- spec/fixtures/delicious.xml
|
173
|
-
- spec/fixtures/empty.xml
|
174
|
-
- spec/fixtures/google.html
|
175
|
-
- spec/fixtures/ssl/generate.sh
|
176
|
-
- spec/fixtures/ssl/generated/1fe462c2.0
|
177
|
-
- spec/fixtures/ssl/generated/bogushost.crt
|
178
|
-
- spec/fixtures/ssl/generated/ca.crt
|
179
|
-
- spec/fixtures/ssl/generated/ca.key
|
180
|
-
- spec/fixtures/ssl/generated/selfsigned.crt
|
181
|
-
- spec/fixtures/ssl/generated/server.crt
|
182
|
-
- spec/fixtures/ssl/generated/server.key
|
183
|
-
- spec/fixtures/ssl/openssl-exts.cnf
|
184
|
-
- spec/fixtures/twitter.csv
|
185
|
-
- spec/fixtures/twitter.json
|
186
|
-
- spec/fixtures/twitter.xml
|
187
|
-
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
188
|
-
- spec/httparty/connection_adapter_spec.rb
|
189
|
-
- spec/httparty/cookie_hash_spec.rb
|
190
|
-
- spec/httparty/exception_spec.rb
|
191
|
-
- spec/httparty/hash_conversions_spec.rb
|
192
|
-
- spec/httparty/logger/apache_formatter_spec.rb
|
193
|
-
- spec/httparty/logger/curl_formatter_spec.rb
|
194
|
-
- spec/httparty/logger/logger_spec.rb
|
195
|
-
- spec/httparty/net_digest_auth_spec.rb
|
196
|
-
- spec/httparty/parser_spec.rb
|
197
|
-
- spec/httparty/request_spec.rb
|
198
|
-
- spec/httparty/response_spec.rb
|
199
|
-
- spec/httparty/ssl_spec.rb
|
200
|
-
- spec/httparty_spec.rb
|
201
|
-
- spec/spec_helper.rb
|
202
|
-
- spec/support/ssl_test_helper.rb
|
203
|
-
- spec/support/ssl_test_server.rb
|
204
|
-
- spec/support/stub_response.rb
|
138
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -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'
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Feature: Digest Authentication
|
2
|
-
|
3
|
-
As a developer
|
4
|
-
I want to be able to use a service that requires Digest Authentication
|
5
|
-
Because that is not an uncommon requirement
|
6
|
-
|
7
|
-
Scenario: Passing no credentials to a page requiring Digest Authentication
|
8
|
-
Given a restricted page at '/digest_auth.html'
|
9
|
-
When I call HTTParty#get with '/digest_auth.html'
|
10
|
-
Then it should return a response with a 401 response code
|
11
|
-
|
12
|
-
Scenario: Passing proper credentials to a page requiring Digest Authentication
|
13
|
-
Given a remote service that returns 'Digest Authenticated Page'
|
14
|
-
And that service is accessed at the path '/digest_auth.html'
|
15
|
-
And that service is protected by Digest Authentication
|
16
|
-
And that service requires the username 'jcash' with the password 'maninblack'
|
17
|
-
When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash:
|
18
|
-
| username | password |
|
19
|
-
| jcash | maninblack |
|
20
|
-
Then the return value should match 'Digest Authenticated Page'
|
21
|
-
|
22
|
-
Scenario: Passing proper credentials to a page requiring Digest Authentication using md5-sess algorithm
|
23
|
-
Given a remote service that returns 'Digest Authenticated Page Using MD5-sess'
|
24
|
-
And that service is accessed at the path '/digest_auth.html'
|
25
|
-
And that service is protected by MD5-sess Digest Authentication
|
26
|
-
And that service requires the username 'jcash' with the password 'maninblack'
|
27
|
-
When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash:
|
28
|
-
| username | password |
|
29
|
-
| jcash | maninblack |
|
30
|
-
Then the return value should match 'Digest Authenticated Page Using MD5-sess'
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Feature: Handles Compressed Responses
|
2
|
-
|
3
|
-
In order to save bandwidth
|
4
|
-
As a developer
|
5
|
-
I want to uncompress compressed responses
|
6
|
-
|
7
|
-
Scenario: Supports deflate encoding
|
8
|
-
Given a remote deflate service
|
9
|
-
And the response from the service has a body of '<h1>Some HTML</h1>'
|
10
|
-
And that service is accessed at the path '/deflate_service.html'
|
11
|
-
When I call HTTParty#get with '/deflate_service.html'
|
12
|
-
Then the return value should match '<h1>Some HTML</h1>'
|
13
|
-
|
14
|
-
Scenario: Supports gzip encoding
|
15
|
-
Given a remote gzip service
|
16
|
-
And the response from the service has a body of '<h1>Some HTML</h1>'
|
17
|
-
And that service is accessed at the path '/gzip_service.html'
|
18
|
-
When I call HTTParty#get with '/gzip_service.html'
|
19
|
-
Then the return value should match '<h1>Some HTML</h1>'
|
20
|
-
|
21
|
-
Scenario: Supports HEAD request with gzip encoding
|
22
|
-
Given a remote gzip service
|
23
|
-
And that service is accessed at the path '/gzip_head.gz.js'
|
24
|
-
When I call HTTParty#head with '/gzip_head.gz.js'
|
25
|
-
Then it should return a response with a 200 response code
|
26
|
-
Then it should return a response with a gzip content-encoding
|
27
|
-
Then it should return a response with a blank body
|
@@ -1,57 +0,0 @@
|
|
1
|
-
Feature: Handles Multiple Formats
|
2
|
-
|
3
|
-
As a developer
|
4
|
-
I want to be able to consume remote services of many different formats
|
5
|
-
And I want those formats to be automatically detected and handled
|
6
|
-
Because web services take many forms
|
7
|
-
And I don't want to have to do any extra work
|
8
|
-
|
9
|
-
Scenario: An HTML service
|
10
|
-
Given a remote service that returns '<h1>Some HTML</h1>'
|
11
|
-
And that service is accessed at the path '/html_service.html'
|
12
|
-
And the response from the service has a Content-Type of 'text/html'
|
13
|
-
When I call HTTParty#get with '/html_service.html'
|
14
|
-
Then it should return a String
|
15
|
-
And the return value should match '<h1>Some HTML</h1>'
|
16
|
-
|
17
|
-
Scenario: A CSV service
|
18
|
-
Given a remote service that returns:
|
19
|
-
"""
|
20
|
-
"Last Name","Name"
|
21
|
-
"jennings","waylon"
|
22
|
-
"cash","johnny"
|
23
|
-
"""
|
24
|
-
And that service is accessed at the path '/service.csv'
|
25
|
-
And the response from the service has a Content-Type of 'application/csv'
|
26
|
-
When I call HTTParty#get with '/service.csv'
|
27
|
-
Then it should return an Array equaling:
|
28
|
-
| Last Name | Name |
|
29
|
-
| jennings | waylon |
|
30
|
-
| cash | johnny |
|
31
|
-
|
32
|
-
Scenario: A JSON service
|
33
|
-
Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
|
34
|
-
And that service is accessed at the path '/service.json'
|
35
|
-
And the response from the service has a Content-Type of 'application/json'
|
36
|
-
When I call HTTParty#get with '/service.json'
|
37
|
-
Then it should return a Hash equaling:
|
38
|
-
| key | value |
|
39
|
-
| jennings | waylon |
|
40
|
-
| cash | johnny |
|
41
|
-
|
42
|
-
Scenario: An XML Service
|
43
|
-
Given a remote service that returns '<singer>waylon jennings</singer>'
|
44
|
-
And that service is accessed at the path '/service.xml'
|
45
|
-
And the response from the service has a Content-Type of 'text/xml'
|
46
|
-
When I call HTTParty#get with '/service.xml'
|
47
|
-
Then it should return a Hash equaling:
|
48
|
-
| key | value |
|
49
|
-
| singer | waylon jennings |
|
50
|
-
|
51
|
-
Scenario: A Javascript remote file
|
52
|
-
Given a remote service that returns '$(function() { alert("hi"); });'
|
53
|
-
And that service is accessed at the path '/service.js'
|
54
|
-
And the response from the service has a Content-Type of 'application/javascript'
|
55
|
-
When I call HTTParty#get with '/service.js'
|
56
|
-
Then it should return a String
|
57
|
-
And the return value should match '$(function() { alert("hi"); });'
|
data/features/steps/env.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'mongrel'
|
2
|
-
require './lib/httparty'
|
3
|
-
require 'rspec/expectations'
|
4
|
-
require 'aruba/cucumber'
|
5
|
-
|
6
|
-
def run_server(port)
|
7
|
-
@host_and_port = "0.0.0.0:#{port}"
|
8
|
-
@server = Mongrel::HttpServer.new("0.0.0.0", port)
|
9
|
-
@server.run
|
10
|
-
@request_options = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_port
|
14
|
-
server = TCPServer.new('0.0.0.0', nil)
|
15
|
-
port = server.addr[1]
|
16
|
-
ensure
|
17
|
-
server.close
|
18
|
-
end
|
19
|
-
|
20
|
-
Before('~@command_line') do
|
21
|
-
port = ENV["HTTPARTY_PORT"] || new_port
|
22
|
-
run_server(port)
|
23
|
-
end
|
24
|
-
|
25
|
-
After do
|
26
|
-
@server.stop if @server
|
27
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Not needed anymore in ruby 2.0, but needed to resolve constants
|
2
|
-
# in nested namespaces. This is taken from rails :)
|
3
|
-
def constantize(camel_cased_word)
|
4
|
-
names = camel_cased_word.split('::')
|
5
|
-
names.shift if names.empty? || names.first.empty?
|
6
|
-
|
7
|
-
constant = Object
|
8
|
-
names.each do |name|
|
9
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
10
|
-
end
|
11
|
-
constant
|
12
|
-
end
|
13
|
-
|
14
|
-
Then /it should return an? ([\w\:]+)$/ do |class_string|
|
15
|
-
expect(@response_from_httparty.parsed_response).to be_a(Object.const_get(class_string))
|
16
|
-
end
|
17
|
-
|
18
|
-
Then /the return value should match '(.*)'/ do |expected_text|
|
19
|
-
expect(@response_from_httparty.parsed_response).to eq(expected_text)
|
20
|
-
end
|
21
|
-
|
22
|
-
Then /it should return a Hash equaling:/ do |hash_table|
|
23
|
-
expect(@response_from_httparty.parsed_response).to be_a(Hash)
|
24
|
-
expect(@response_from_httparty.keys.length).to eq(hash_table.rows.length)
|
25
|
-
hash_table.hashes.each do |pair|
|
26
|
-
key, value = pair["key"], pair["value"]
|
27
|
-
expect(@response_from_httparty.keys).to include(key)
|
28
|
-
expect(@response_from_httparty[key]).to eq(value)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Then /it should return an Array equaling:/ do |array|
|
33
|
-
expect(@response_from_httparty.parsed_response).to be_a(Array)
|
34
|
-
expect(@response_from_httparty.parsed_response).to eq(array.raw)
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /it should return a response with a (\d+) response code/ do |code|
|
38
|
-
expect(@response_from_httparty.code).to eq(code.to_i)
|
39
|
-
end
|
40
|
-
|
41
|
-
Then /it should return a response with a (.*) content\-encoding$/ do |content_type|
|
42
|
-
expect(@response_from_httparty.headers['content-encoding']).to eq('gzip')
|
43
|
-
end
|
44
|
-
|
45
|
-
Then /it should return a response with a blank body$/ do
|
46
|
-
expect(@response_from_httparty.body).to be_nil
|
47
|
-
end
|
48
|
-
|
49
|
-
Then /it should raise (?:an|a) ([\w:]+) exception/ do |exception|
|
50
|
-
expect(@exception_from_httparty).to_not be_nil
|
51
|
-
expect(@exception_from_httparty).to be_a constantize(exception)
|
52
|
-
end
|
53
|
-
|
54
|
-
Then /it should not raise (?:an|a) ([\w:]+) exception/ do |exception|
|
55
|
-
expect(@exception_from_httparty).to be_nil
|
56
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
When /^I set my HTTParty timeout option to (\d+)$/ do |timeout|
|
2
|
-
@request_options[:timeout] = timeout.to_i
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I set my HTTParty open_timeout option to (\d+)$/ do |timeout|
|
6
|
-
@request_options[:open_timeout] = timeout.to_i
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I set my HTTParty read_timeout option to (\d+)$/ do |timeout|
|
10
|
-
@request_options[:read_timeout] = timeout.to_i
|
11
|
-
end
|
12
|
-
|
13
|
-
When /I call HTTParty#get with '(.*)'$/ do |url|
|
14
|
-
begin
|
15
|
-
@response_from_httparty = HTTParty.get("http://#{@host_and_port}#{url}", @request_options)
|
16
|
-
rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
|
17
|
-
@exception_from_httparty = e
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^I call HTTParty#head with '(.*)'$/ do |url|
|
22
|
-
begin
|
23
|
-
@response_from_httparty = HTTParty.head("http://#{@host_and_port}#{url}", @request_options)
|
24
|
-
rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
|
25
|
-
@exception_from_httparty = e
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
When /I call HTTParty#get with '(.*)' and a basic_auth hash:/ do |url, auth_table|
|
30
|
-
h = auth_table.hashes.first
|
31
|
-
@response_from_httparty = HTTParty.get(
|
32
|
-
"http://#{@host_and_port}#{url}",
|
33
|
-
basic_auth: { username: h["username"], password: h["password"] }
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
When /I call HTTParty#get with '(.*)' and a digest_auth hash:/ do |url, auth_table|
|
38
|
-
h = auth_table.hashes.first
|
39
|
-
@response_from_httparty = HTTParty.get(
|
40
|
-
"http://#{@host_and_port}#{url}",
|
41
|
-
digest_auth: { username: h["username"], password: h["password"] }
|
42
|
-
)
|
43
|
-
end
|