httparty 0.15.4 → 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/Changelog.md +105 -0
- data/Gemfile +6 -1
- data/README.md +6 -6
- data/docs/README.md +100 -38
- data/examples/README.md +28 -11
- data/examples/aaws.rb +6 -2
- data/examples/body_stream.rb +14 -0
- data/examples/custom_parsers.rb +4 -0
- data/examples/headers_and_user_agents.rb +7 -3
- data/examples/idn.rb +10 -0
- data/examples/logging.rb +3 -3
- data/examples/microsoft_graph.rb +52 -0
- data/examples/multipart.rb +22 -0
- data/examples/peer_cert.rb +9 -0
- data/examples/stream_download.rb +8 -2
- data/httparty.gemspec +3 -3
- data/lib/httparty/connection_adapter.rb +59 -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 +28 -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 +15 -15
- data/lib/httparty/parser.rb +22 -16
- data/lib/httparty/request/body.rb +98 -0
- data/lib/httparty/request/multipart_boundary.rb +13 -0
- data/lib/httparty/request.rb +82 -95
- data/lib/httparty/response/headers.rb +4 -2
- data/lib/httparty/response.rb +59 -8
- 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 +70 -24
- data/website/css/common.css +1 -1
- metadata +35 -100
- data/.travis.yml +0 -8
- 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/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 -268
- data/spec/httparty/parser_spec.rb +0 -185
- data/spec/httparty/request_spec.rb +0 -1251
- data/spec/httparty/response_spec.rb +0 -347
- data/spec/httparty/ssl_spec.rb +0 -74
- data/spec/httparty_spec.rb +0 -877
- 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
data/lib/httparty/response.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module HTTParty
|
2
4
|
class Response < Object
|
3
5
|
def self.underscore(string)
|
4
6
|
string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2').downcase
|
5
7
|
end
|
6
8
|
|
9
|
+
def self._load(data)
|
10
|
+
req, resp, parsed_resp, resp_body = Marshal.load(data)
|
11
|
+
|
12
|
+
new(req, resp, -> { parsed_resp }, body: resp_body)
|
13
|
+
end
|
14
|
+
|
7
15
|
attr_reader :request, :response, :body, :headers
|
8
16
|
|
9
17
|
def initialize(request, response, parsed_block, options = {})
|
@@ -14,7 +22,11 @@ module HTTParty
|
|
14
22
|
@headers = Headers.new(response.to_hash)
|
15
23
|
|
16
24
|
if request.options[:logger]
|
17
|
-
logger = ::HTTParty::Logger.build(
|
25
|
+
logger = ::HTTParty::Logger.build(
|
26
|
+
request.options[:logger],
|
27
|
+
request.options[:log_level],
|
28
|
+
request.options[:log_format]
|
29
|
+
)
|
18
30
|
logger.format(request, self)
|
19
31
|
end
|
20
32
|
|
@@ -29,20 +41,24 @@ module HTTParty
|
|
29
41
|
response.code.to_i
|
30
42
|
end
|
31
43
|
|
44
|
+
def http_version
|
45
|
+
response.http_version
|
46
|
+
end
|
47
|
+
|
32
48
|
def tap
|
33
49
|
yield self
|
34
50
|
self
|
35
51
|
end
|
36
52
|
|
37
53
|
def inspect
|
38
|
-
inspect_id = ::Kernel::format
|
54
|
+
inspect_id = ::Kernel::format '%x', (object_id * 2)
|
39
55
|
%(#<#{self.class}:0x#{inspect_id} parsed_response=#{parsed_response.inspect}, @response=#{response.inspect}, @headers=#{headers.inspect}>)
|
40
56
|
end
|
41
57
|
|
42
58
|
CODES_TO_OBJ = ::Net::HTTPResponse::CODE_CLASS_TO_OBJ.merge ::Net::HTTPResponse::CODE_TO_OBJ
|
43
59
|
|
44
60
|
CODES_TO_OBJ.each do |response_code, klass|
|
45
|
-
name = klass.name.sub(
|
61
|
+
name = klass.name.sub('Net::HTTP', '')
|
46
62
|
name = "#{underscore(name)}?".to_sym
|
47
63
|
|
48
64
|
define_method(name) do
|
@@ -51,28 +67,46 @@ module HTTParty
|
|
51
67
|
end
|
52
68
|
|
53
69
|
# Support old multiple_choice? method from pre 2.0.0 era.
|
54
|
-
if ::RUBY_VERSION >=
|
70
|
+
if ::RUBY_VERSION >= '2.0.0' && ::RUBY_PLATFORM != 'java'
|
55
71
|
alias_method :multiple_choice?, :multiple_choices?
|
56
72
|
end
|
57
73
|
|
74
|
+
# Support old status codes method from pre 2.6.0 era.
|
75
|
+
if ::RUBY_VERSION >= '2.6.0' && ::RUBY_PLATFORM != 'java'
|
76
|
+
alias_method :gateway_time_out?, :gateway_timeout?
|
77
|
+
alias_method :request_entity_too_large?, :payload_too_large?
|
78
|
+
alias_method :request_time_out?, :request_timeout?
|
79
|
+
alias_method :request_uri_too_long?, :uri_too_long?
|
80
|
+
alias_method :requested_range_not_satisfiable?, :range_not_satisfiable?
|
81
|
+
end
|
82
|
+
|
58
83
|
def nil?
|
84
|
+
warn_about_nil_deprecation
|
59
85
|
response.nil? || response.body.nil? || response.body.empty?
|
60
86
|
end
|
61
87
|
|
62
|
-
def to_s
|
88
|
+
def to_s
|
63
89
|
if !response.nil? && !response.body.nil? && response.body.respond_to?(:to_s)
|
64
90
|
response.body.to_s
|
65
|
-
else
|
91
|
+
else
|
66
92
|
inspect
|
67
93
|
end
|
68
94
|
end
|
69
95
|
|
96
|
+
def pretty_print(pp)
|
97
|
+
if !parsed_response.nil? && parsed_response.respond_to?(:pretty_print)
|
98
|
+
parsed_response.pretty_print(pp)
|
99
|
+
else
|
100
|
+
super
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
70
104
|
def display(port=$>)
|
71
105
|
if !parsed_response.nil? && parsed_response.respond_to?(:display)
|
72
106
|
parsed_response.display(port)
|
73
107
|
elsif !response.nil? && !response.body.nil? && response.body.respond_to?(:display)
|
74
108
|
response.body.display(port)
|
75
|
-
else
|
109
|
+
else
|
76
110
|
port.write(inspect)
|
77
111
|
end
|
78
112
|
end
|
@@ -81,7 +115,11 @@ module HTTParty
|
|
81
115
|
return true if super
|
82
116
|
parsed_response.respond_to?(name) || response.respond_to?(name)
|
83
117
|
end
|
84
|
-
|
118
|
+
|
119
|
+
def _dump(_level)
|
120
|
+
Marshal.dump([request, response, parsed_response, body])
|
121
|
+
end
|
122
|
+
|
85
123
|
protected
|
86
124
|
|
87
125
|
def method_missing(name, *args, &block)
|
@@ -99,6 +137,19 @@ module HTTParty
|
|
99
137
|
::Kernel.raise ::HTTParty::ResponseError.new(@response), "Code #{code} - #{body}"
|
100
138
|
end
|
101
139
|
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
def warn_about_nil_deprecation
|
144
|
+
trace_line = caller.reject { |line| line.include?('httparty') }.first
|
145
|
+
warning = "[DEPRECATION] HTTParty will no longer override `response#nil?`. " \
|
146
|
+
"This functionality will be removed in future versions. " \
|
147
|
+
"Please, add explicit check `response.body.nil? || response.body.empty?`. " \
|
148
|
+
"For more info refer to: https://github.com/jnunemaker/httparty/issues/568\n" \
|
149
|
+
"#{trace_line}"
|
150
|
+
|
151
|
+
warn(warning)
|
152
|
+
end
|
102
153
|
end
|
103
154
|
end
|
104
155
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'delegate'
|
4
|
+
|
5
|
+
module HTTParty
|
6
|
+
# Allow access to http_response and code by delegation on fragment
|
7
|
+
class ResponseFragment < SimpleDelegator
|
8
|
+
attr_reader :http_response, :connection
|
9
|
+
|
10
|
+
def code
|
11
|
+
@http_response.code.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(fragment, http_response, connection)
|
15
|
+
@fragment = fragment
|
16
|
+
@http_response = http_response
|
17
|
+
@connection = connection
|
18
|
+
super fragment
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HTTParty
|
4
|
+
class TextEncoder
|
5
|
+
attr_reader :text, :content_type, :assume_utf16_is_big_endian
|
6
|
+
|
7
|
+
def initialize(text, assume_utf16_is_big_endian: true, content_type: nil)
|
8
|
+
@text = text.dup
|
9
|
+
@content_type = content_type
|
10
|
+
@assume_utf16_is_big_endian = assume_utf16_is_big_endian
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
if can_encode?
|
15
|
+
encoded_text
|
16
|
+
else
|
17
|
+
text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def can_encode?
|
24
|
+
''.respond_to?(:encoding) && charset
|
25
|
+
end
|
26
|
+
|
27
|
+
def encoded_text
|
28
|
+
if 'utf-16'.casecmp(charset) == 0
|
29
|
+
encode_utf_16
|
30
|
+
else
|
31
|
+
encode_with_ruby_encoding
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def encode_utf_16
|
36
|
+
if text.bytesize >= 2
|
37
|
+
if text.getbyte(0) == 0xFF && text.getbyte(1) == 0xFE
|
38
|
+
return text.force_encoding('UTF-16LE')
|
39
|
+
elsif text.getbyte(0) == 0xFE && text.getbyte(1) == 0xFF
|
40
|
+
return text.force_encoding('UTF-16BE')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if assume_utf16_is_big_endian # option
|
45
|
+
text.force_encoding('UTF-16BE')
|
46
|
+
else
|
47
|
+
text.force_encoding('UTF-16LE')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def encode_with_ruby_encoding
|
52
|
+
# NOTE: This will raise an argument error if the
|
53
|
+
# charset does not exist
|
54
|
+
encoding = Encoding.find(charset)
|
55
|
+
text.force_encoding(encoding.to_s)
|
56
|
+
rescue ArgumentError
|
57
|
+
text
|
58
|
+
end
|
59
|
+
|
60
|
+
def charset
|
61
|
+
return nil if content_type.nil?
|
62
|
+
|
63
|
+
if (matchdata = content_type.match(/;\s*charset\s*=\s*([^=,;"\s]+)/i))
|
64
|
+
return matchdata.captures.first
|
65
|
+
end
|
66
|
+
|
67
|
+
if (matchdata = content_type.match(/;\s*charset\s*=\s*"((\\.|[^\\"])+)"/i))
|
68
|
+
return matchdata.captures.first.gsub(/\\(.)/, '\1')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HTTParty
|
4
|
+
module Utils
|
5
|
+
def self.stringify_keys(hash)
|
6
|
+
return hash.transform_keys(&:to_s) if hash.respond_to?(:transform_keys)
|
7
|
+
|
8
|
+
hash.each_with_object({}) do |(key, value), new_hash|
|
9
|
+
new_hash[key.to_s] = value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/httparty/version.rb
CHANGED
data/lib/httparty.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'net/http'
|
3
5
|
require 'net/https'
|
4
6
|
require 'uri'
|
5
7
|
require 'zlib'
|
6
8
|
require 'multi_xml'
|
9
|
+
require 'mime/types'
|
7
10
|
require 'json'
|
8
11
|
require 'csv'
|
9
12
|
|
@@ -13,6 +16,11 @@ require 'httparty/net_digest_auth'
|
|
13
16
|
require 'httparty/version'
|
14
17
|
require 'httparty/connection_adapter'
|
15
18
|
require 'httparty/logger/logger'
|
19
|
+
require 'httparty/request/body'
|
20
|
+
require 'httparty/response_fragment'
|
21
|
+
require 'httparty/decompressor'
|
22
|
+
require 'httparty/text_encoder'
|
23
|
+
require 'httparty/headers_processor'
|
16
24
|
|
17
25
|
# @see HTTParty::ClassMethods
|
18
26
|
module HTTParty
|
@@ -21,8 +29,8 @@ module HTTParty
|
|
21
29
|
base.send :include, ModuleInheritableAttributes
|
22
30
|
base.send(:mattr_inheritable, :default_options)
|
23
31
|
base.send(:mattr_inheritable, :default_cookies)
|
24
|
-
base.instance_variable_set(
|
25
|
-
base.instance_variable_set(
|
32
|
+
base.instance_variable_set(:@default_options, {})
|
33
|
+
base.instance_variable_set(:@default_cookies, CookieHash.new)
|
26
34
|
end
|
27
35
|
|
28
36
|
# == Common Request Options
|
@@ -36,10 +44,11 @@ module HTTParty
|
|
36
44
|
# [:+limit+:] Maximum number of redirects to follow. Takes precedences over :+no_follow+.
|
37
45
|
# [:+query+:] Query string, or an object that responds to #to_hash representing it. Normalized according to the same rules as :+body+. If you specify this on a POST, you must use an object which responds to #to_hash. See also HTTParty::ClassMethods.default_params.
|
38
46
|
# [:+timeout+:] Timeout for opening connection and reading data.
|
39
|
-
# [:+local_host
|
40
|
-
# [:+local_port
|
41
|
-
# [:+body_stream
|
42
|
-
# [:+stream_body
|
47
|
+
# [:+local_host+:] Local address to bind to before connecting.
|
48
|
+
# [:+local_port+:] Local port to bind to before connecting.
|
49
|
+
# [:+body_stream+:] Allow streaming to a REST server to specify a body_stream.
|
50
|
+
# [:+stream_body+:] Allow for streaming large files without loading them into memory.
|
51
|
+
# [:+multipart+:] Force content-type to be multipart
|
43
52
|
#
|
44
53
|
# There are also another set of options with names corresponding to various class methods. The methods in question are those that let you set a class-wide default, and the options override the defaults on a request-by-request basis. Those options are:
|
45
54
|
# * :+base_uri+: see HTTParty::ClassMethods.base_uri.
|
@@ -168,9 +177,9 @@ module HTTParty
|
|
168
177
|
# include HTTParty
|
169
178
|
# default_timeout 10
|
170
179
|
# end
|
171
|
-
def default_timeout(
|
172
|
-
|
173
|
-
default_options[:timeout] =
|
180
|
+
def default_timeout(value)
|
181
|
+
validate_timeout_argument(__method__, value)
|
182
|
+
default_options[:timeout] = value
|
174
183
|
end
|
175
184
|
|
176
185
|
# Allows setting a default open_timeout for all HTTP calls in seconds
|
@@ -179,9 +188,9 @@ module HTTParty
|
|
179
188
|
# include HTTParty
|
180
189
|
# open_timeout 10
|
181
190
|
# end
|
182
|
-
def open_timeout(
|
183
|
-
|
184
|
-
default_options[:open_timeout] =
|
191
|
+
def open_timeout(value)
|
192
|
+
validate_timeout_argument(__method__, value)
|
193
|
+
default_options[:open_timeout] = value
|
185
194
|
end
|
186
195
|
|
187
196
|
# Allows setting a default read_timeout for all HTTP calls in seconds
|
@@ -190,11 +199,24 @@ module HTTParty
|
|
190
199
|
# include HTTParty
|
191
200
|
# read_timeout 10
|
192
201
|
# end
|
193
|
-
def read_timeout(
|
194
|
-
|
195
|
-
default_options[:read_timeout] =
|
202
|
+
def read_timeout(value)
|
203
|
+
validate_timeout_argument(__method__, value)
|
204
|
+
default_options[:read_timeout] = value
|
205
|
+
end
|
206
|
+
|
207
|
+
# Allows setting a default write_timeout for all HTTP calls in seconds
|
208
|
+
# Supported by Ruby > 2.6.0
|
209
|
+
#
|
210
|
+
# class Foo
|
211
|
+
# include HTTParty
|
212
|
+
# write_timeout 10
|
213
|
+
# end
|
214
|
+
def write_timeout(value)
|
215
|
+
validate_timeout_argument(__method__, value)
|
216
|
+
default_options[:write_timeout] = value
|
196
217
|
end
|
197
218
|
|
219
|
+
|
198
220
|
# Set an output stream for debugging, defaults to $stderr.
|
199
221
|
# The output stream is passed on to Net::HTTP#set_debug_output.
|
200
222
|
#
|
@@ -380,6 +402,22 @@ module HTTParty
|
|
380
402
|
default_options[:ssl_version] = version
|
381
403
|
end
|
382
404
|
|
405
|
+
# Deactivate automatic decompression of the response body.
|
406
|
+
# This will require you to explicitly handle body decompression
|
407
|
+
# by inspecting the Content-Encoding response header.
|
408
|
+
#
|
409
|
+
# Refer to docs/README.md "HTTP Compression" section for
|
410
|
+
# further details.
|
411
|
+
#
|
412
|
+
# @example
|
413
|
+
# class Foo
|
414
|
+
# include HTTParty
|
415
|
+
# skip_decompression
|
416
|
+
# end
|
417
|
+
def skip_decompression(value = true)
|
418
|
+
default_options[:skip_decompression] = !!value
|
419
|
+
end
|
420
|
+
|
383
421
|
# Allows setting of SSL ciphers to use. This only works in Ruby 1.9+.
|
384
422
|
# You can get a list of valid specific ciphers from OpenSSL::Cipher.ciphers.
|
385
423
|
# You also can specify a cipher suite here, listed here at openssl.org:
|
@@ -546,10 +584,22 @@ module HTTParty
|
|
546
584
|
perform_request Net::HTTP::Mkcol, path, options, &block
|
547
585
|
end
|
548
586
|
|
587
|
+
def lock(path, options = {}, &block)
|
588
|
+
perform_request Net::HTTP::Lock, path, options, &block
|
589
|
+
end
|
590
|
+
|
591
|
+
def unlock(path, options = {}, &block)
|
592
|
+
perform_request Net::HTTP::Unlock, path, options, &block
|
593
|
+
end
|
594
|
+
|
549
595
|
attr_reader :default_options
|
550
596
|
|
551
597
|
private
|
552
598
|
|
599
|
+
def validate_timeout_argument(timeout_type, value)
|
600
|
+
raise ArgumentError, "#{ timeout_type } must be an integer or float" unless value && (value.is_a?(Integer) || value.is_a?(Float))
|
601
|
+
end
|
602
|
+
|
553
603
|
def ensure_method_maintained_across_redirects(options)
|
554
604
|
unless options.key?(:maintain_method_across_redirects)
|
555
605
|
options[:maintain_method_across_redirects] = true
|
@@ -558,26 +608,21 @@ module HTTParty
|
|
558
608
|
|
559
609
|
def perform_request(http_method, path, options, &block) #:nodoc:
|
560
610
|
options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
|
561
|
-
|
611
|
+
HeadersProcessor.new(headers, options).call
|
562
612
|
process_cookies(options)
|
563
613
|
Request.new(http_method, path, options).perform(&block)
|
564
614
|
end
|
565
615
|
|
566
|
-
def process_headers(options)
|
567
|
-
if options[:headers] && headers.any?
|
568
|
-
options[:headers] = headers.merge(options[:headers])
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
616
|
def process_cookies(options) #:nodoc:
|
573
617
|
return unless options[:cookies] || default_cookies.any?
|
574
618
|
options[:headers] ||= headers.dup
|
575
|
-
options[:headers][
|
619
|
+
options[:headers]['cookie'] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
|
576
620
|
end
|
577
621
|
|
578
622
|
def validate_format
|
579
623
|
if format && parser.respond_to?(:supports_format?) && !parser.supports_format?(format)
|
580
|
-
|
624
|
+
supported_format_names = parser.supported_formats.map(&:to_s).sort.join(', ')
|
625
|
+
raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{supported_format_names}"
|
581
626
|
end
|
582
627
|
end
|
583
628
|
end
|
@@ -635,6 +680,7 @@ module HTTParty
|
|
635
680
|
end
|
636
681
|
|
637
682
|
require 'httparty/hash_conversions'
|
683
|
+
require 'httparty/utils'
|
638
684
|
require 'httparty/exceptions'
|
639
685
|
require 'httparty/parser'
|
640
686
|
require 'httparty/request'
|
data/website/css/common.css
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
|
9
9
|
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
|
10
10
|
/* end of yahoo reset and fonts */
|
11
|
-
|
11
|
+
|
12
12
|
body {color:#333; background:#4b1a1a; line-height:1.3;}
|
13
13
|
p {margin:0 0 20px;}
|
14
14
|
a {color:#4b1a1a;}
|
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,11 +47,12 @@ 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
|
42
57
|
- Changelog.md
|
43
58
|
- Gemfile
|
@@ -51,13 +66,18 @@ 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
|
@@ -65,72 +85,34 @@ files:
|
|
65
85
|
- examples/tripit_sign_in.rb
|
66
86
|
- examples/twitter.rb
|
67
87
|
- examples/whoismyrep.rb
|
68
|
-
- features/basic_authentication.feature
|
69
|
-
- features/command_line.feature
|
70
|
-
- features/deals_with_http_error_codes.feature
|
71
|
-
- features/digest_authentication.feature
|
72
|
-
- features/handles_compressed_responses.feature
|
73
|
-
- features/handles_multiple_formats.feature
|
74
|
-
- features/steps/env.rb
|
75
|
-
- features/steps/httparty_response_steps.rb
|
76
|
-
- features/steps/httparty_steps.rb
|
77
|
-
- features/steps/mongrel_helper.rb
|
78
|
-
- features/steps/remote_service_steps.rb
|
79
|
-
- features/supports_read_timeout_option.feature
|
80
|
-
- features/supports_redirection.feature
|
81
|
-
- features/supports_timeout_option.feature
|
82
88
|
- httparty.gemspec
|
83
89
|
- lib/httparty.rb
|
84
90
|
- lib/httparty/connection_adapter.rb
|
85
91
|
- lib/httparty/cookie_hash.rb
|
92
|
+
- lib/httparty/decompressor.rb
|
86
93
|
- lib/httparty/exceptions.rb
|
87
94
|
- lib/httparty/hash_conversions.rb
|
95
|
+
- lib/httparty/headers_processor.rb
|
88
96
|
- lib/httparty/logger/apache_formatter.rb
|
89
97
|
- lib/httparty/logger/curl_formatter.rb
|
90
98
|
- lib/httparty/logger/logger.rb
|
99
|
+
- lib/httparty/logger/logstash_formatter.rb
|
91
100
|
- lib/httparty/module_inheritable_attributes.rb
|
92
101
|
- lib/httparty/net_digest_auth.rb
|
93
102
|
- lib/httparty/parser.rb
|
94
103
|
- lib/httparty/request.rb
|
104
|
+
- lib/httparty/request/body.rb
|
105
|
+
- lib/httparty/request/multipart_boundary.rb
|
95
106
|
- lib/httparty/response.rb
|
96
107
|
- lib/httparty/response/headers.rb
|
108
|
+
- lib/httparty/response_fragment.rb
|
109
|
+
- lib/httparty/text_encoder.rb
|
110
|
+
- lib/httparty/utils.rb
|
97
111
|
- lib/httparty/version.rb
|
98
112
|
- script/release
|
99
|
-
- spec/fixtures/delicious.xml
|
100
|
-
- spec/fixtures/empty.xml
|
101
|
-
- spec/fixtures/google.html
|
102
|
-
- spec/fixtures/ssl/generate.sh
|
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,62 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
124
|
requirements:
|
143
125
|
- - ">="
|
144
126
|
- !ruby/object:Gem::Version
|
145
|
-
version: 2.
|
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.5.2
|
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/bogushost.crt
|
177
|
-
- spec/fixtures/ssl/generated/ca.crt
|
178
|
-
- spec/fixtures/ssl/generated/ca.key
|
179
|
-
- spec/fixtures/ssl/generated/selfsigned.crt
|
180
|
-
- spec/fixtures/ssl/generated/server.crt
|
181
|
-
- spec/fixtures/ssl/generated/server.key
|
182
|
-
- spec/fixtures/ssl/openssl-exts.cnf
|
183
|
-
- spec/fixtures/twitter.csv
|
184
|
-
- spec/fixtures/twitter.json
|
185
|
-
- spec/fixtures/twitter.xml
|
186
|
-
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
187
|
-
- spec/httparty/connection_adapter_spec.rb
|
188
|
-
- spec/httparty/cookie_hash_spec.rb
|
189
|
-
- spec/httparty/exception_spec.rb
|
190
|
-
- spec/httparty/hash_conversions_spec.rb
|
191
|
-
- spec/httparty/logger/apache_formatter_spec.rb
|
192
|
-
- spec/httparty/logger/curl_formatter_spec.rb
|
193
|
-
- spec/httparty/logger/logger_spec.rb
|
194
|
-
- spec/httparty/net_digest_auth_spec.rb
|
195
|
-
- spec/httparty/parser_spec.rb
|
196
|
-
- spec/httparty/request_spec.rb
|
197
|
-
- spec/httparty/response_spec.rb
|
198
|
-
- spec/httparty/ssl_spec.rb
|
199
|
-
- spec/httparty_spec.rb
|
200
|
-
- spec/spec_helper.rb
|
201
|
-
- spec/support/ssl_test_helper.rb
|
202
|
-
- spec/support/ssl_test_server.rb
|
203
|
-
- spec/support/stub_response.rb
|
138
|
+
test_files: []
|