httparty 0.14.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.editorconfig +18 -0
  3. data/.github/workflows/ci.yml +26 -0
  4. data/.gitignore +3 -0
  5. data/.rubocop_todo.yml +1 -1
  6. data/{History → Changelog.md} +222 -63
  7. data/Gemfile +8 -1
  8. data/Guardfile +3 -2
  9. data/README.md +8 -8
  10. data/bin/httparty +3 -1
  11. data/docs/README.md +128 -37
  12. data/examples/README.md +34 -12
  13. data/examples/aaws.rb +7 -3
  14. data/examples/body_stream.rb +14 -0
  15. data/examples/crack.rb +1 -1
  16. data/examples/custom_parsers.rb +5 -1
  17. data/examples/delicious.rb +4 -4
  18. data/examples/headers_and_user_agents.rb +7 -3
  19. data/examples/idn.rb +10 -0
  20. data/examples/logging.rb +4 -4
  21. data/examples/microsoft_graph.rb +52 -0
  22. data/examples/multipart.rb +22 -0
  23. data/examples/peer_cert.rb +9 -0
  24. data/examples/stackexchange.rb +1 -1
  25. data/examples/stream_download.rb +26 -0
  26. data/examples/tripit_sign_in.rb +1 -1
  27. data/examples/twitter.rb +2 -2
  28. data/examples/whoismyrep.rb +1 -1
  29. data/httparty.gemspec +7 -4
  30. data/lib/httparty/connection_adapter.rb +73 -16
  31. data/lib/httparty/cookie_hash.rb +10 -8
  32. data/lib/httparty/decompressor.rb +102 -0
  33. data/lib/httparty/exceptions.rb +4 -1
  34. data/lib/httparty/hash_conversions.rb +30 -12
  35. data/lib/httparty/headers_processor.rb +32 -0
  36. data/lib/httparty/logger/apache_formatter.rb +31 -6
  37. data/lib/httparty/logger/curl_formatter.rb +9 -7
  38. data/lib/httparty/logger/logger.rb +5 -1
  39. data/lib/httparty/logger/logstash_formatter.rb +61 -0
  40. data/lib/httparty/module_inheritable_attributes.rb +6 -4
  41. data/lib/httparty/net_digest_auth.rb +19 -19
  42. data/lib/httparty/parser.rb +25 -14
  43. data/lib/httparty/request/body.rb +105 -0
  44. data/lib/httparty/request/multipart_boundary.rb +13 -0
  45. data/lib/httparty/request.rb +141 -110
  46. data/lib/httparty/response/headers.rb +23 -19
  47. data/lib/httparty/response.rb +81 -22
  48. data/lib/httparty/response_fragment.rb +21 -0
  49. data/lib/httparty/text_encoder.rb +72 -0
  50. data/lib/httparty/utils.rb +13 -0
  51. data/lib/httparty/version.rb +3 -1
  52. data/lib/httparty.rb +79 -31
  53. data/website/css/common.css +1 -1
  54. metadata +39 -106
  55. data/.simplecov +0 -1
  56. data/.travis.yml +0 -9
  57. data/features/basic_authentication.feature +0 -20
  58. data/features/command_line.feature +0 -95
  59. data/features/deals_with_http_error_codes.feature +0 -26
  60. data/features/digest_authentication.feature +0 -30
  61. data/features/handles_compressed_responses.feature +0 -27
  62. data/features/handles_multiple_formats.feature +0 -57
  63. data/features/steps/env.rb +0 -27
  64. data/features/steps/httparty_response_steps.rb +0 -56
  65. data/features/steps/httparty_steps.rb +0 -43
  66. data/features/steps/mongrel_helper.rb +0 -127
  67. data/features/steps/remote_service_steps.rb +0 -92
  68. data/features/supports_read_timeout_option.feature +0 -13
  69. data/features/supports_redirection.feature +0 -22
  70. data/features/supports_timeout_option.feature +0 -13
  71. data/spec/fixtures/delicious.xml +0 -23
  72. data/spec/fixtures/empty.xml +0 -0
  73. data/spec/fixtures/google.html +0 -3
  74. data/spec/fixtures/ssl/generate.sh +0 -29
  75. data/spec/fixtures/ssl/generated/1fe462c2.0 +0 -16
  76. data/spec/fixtures/ssl/generated/bogushost.crt +0 -13
  77. data/spec/fixtures/ssl/generated/ca.crt +0 -16
  78. data/spec/fixtures/ssl/generated/ca.key +0 -15
  79. data/spec/fixtures/ssl/generated/selfsigned.crt +0 -14
  80. data/spec/fixtures/ssl/generated/server.crt +0 -13
  81. data/spec/fixtures/ssl/generated/server.key +0 -15
  82. data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
  83. data/spec/fixtures/twitter.csv +0 -2
  84. data/spec/fixtures/twitter.json +0 -1
  85. data/spec/fixtures/twitter.xml +0 -403
  86. data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
  87. data/spec/httparty/connection_adapter_spec.rb +0 -495
  88. data/spec/httparty/cookie_hash_spec.rb +0 -100
  89. data/spec/httparty/exception_spec.rb +0 -45
  90. data/spec/httparty/hash_conversions_spec.rb +0 -49
  91. data/spec/httparty/logger/apache_formatter_spec.rb +0 -41
  92. data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
  93. data/spec/httparty/logger/logger_spec.rb +0 -38
  94. data/spec/httparty/net_digest_auth_spec.rb +0 -240
  95. data/spec/httparty/parser_spec.rb +0 -173
  96. data/spec/httparty/request_spec.rb +0 -1183
  97. data/spec/httparty/response_spec.rb +0 -291
  98. data/spec/httparty/ssl_spec.rb +0 -74
  99. data/spec/httparty_spec.rb +0 -872
  100. data/spec/spec_helper.rb +0 -59
  101. data/spec/support/ssl_test_helper.rb +0 -47
  102. data/spec/support/ssl_test_server.rb +0 -80
  103. data/spec/support/stub_response.rb +0 -49
@@ -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
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HTTParty
2
- VERSION = "0.14.0"
4
+ VERSION = '0.21.0'
3
5
  end
data/lib/httparty.rb CHANGED
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'net/http'
3
- require 'net/https'
4
5
  require 'uri'
5
6
  require 'zlib'
6
7
  require 'multi_xml'
8
+ require 'mini_mime'
7
9
  require 'json'
8
10
  require 'csv'
9
- require 'erb'
10
11
 
11
12
  require 'httparty/module_inheritable_attributes'
12
13
  require 'httparty/cookie_hash'
@@ -14,6 +15,11 @@ require 'httparty/net_digest_auth'
14
15
  require 'httparty/version'
15
16
  require 'httparty/connection_adapter'
16
17
  require 'httparty/logger/logger'
18
+ require 'httparty/request/body'
19
+ require 'httparty/response_fragment'
20
+ require 'httparty/decompressor'
21
+ require 'httparty/text_encoder'
22
+ require 'httparty/headers_processor'
17
23
 
18
24
  # @see HTTParty::ClassMethods
19
25
  module HTTParty
@@ -22,8 +28,8 @@ module HTTParty
22
28
  base.send :include, ModuleInheritableAttributes
23
29
  base.send(:mattr_inheritable, :default_options)
24
30
  base.send(:mattr_inheritable, :default_cookies)
25
- base.instance_variable_set("@default_options", {})
26
- base.instance_variable_set("@default_cookies", CookieHash.new)
31
+ base.instance_variable_set(:@default_options, {})
32
+ base.instance_variable_set(:@default_cookies, CookieHash.new)
27
33
  end
28
34
 
29
35
  # == Common Request Options
@@ -37,10 +43,11 @@ module HTTParty
37
43
  # [:+limit+:] Maximum number of redirects to follow. Takes precedences over :+no_follow+.
38
44
  # [:+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.
39
45
  # [:+timeout+:] Timeout for opening connection and reading data.
40
- # [:+local_host:] Local address to bind to before connecting.
41
- # [:+local_port:] Local port to bind to before connecting.
42
- # [:+body_steam:] Allow streaming to a REST server to specify a body_stream.
43
- # [:+stream_body:] Allow for streaming large files without loading them into memory.
46
+ # [:+local_host+:] Local address to bind to before connecting.
47
+ # [:+local_port+:] Local port to bind to before connecting.
48
+ # [:+body_stream+:] Allow streaming to a REST server to specify a body_stream.
49
+ # [:+stream_body+:] Allow for streaming large files without loading them into memory.
50
+ # [:+multipart+:] Force content-type to be multipart
44
51
  #
45
52
  # 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:
46
53
  # * :+base_uri+: see HTTParty::ClassMethods.base_uri.
@@ -128,7 +135,7 @@ module HTTParty
128
135
  end
129
136
 
130
137
  # Do not send rails style query strings.
131
- # Specically, don't use bracket notation when sending an array
138
+ # Specifically, don't use bracket notation when sending an array
132
139
  #
133
140
  # For a query:
134
141
  # get '/', query: {selected_ids: [1,2,3]}
@@ -169,9 +176,9 @@ module HTTParty
169
176
  # include HTTParty
170
177
  # default_timeout 10
171
178
  # end
172
- def default_timeout(t)
173
- raise ArgumentError, 'Timeout must be an integer or float' unless t && (t.is_a?(Integer) || t.is_a?(Float))
174
- default_options[:timeout] = t
179
+ def default_timeout(value)
180
+ validate_timeout_argument(__method__, value)
181
+ default_options[:timeout] = value
175
182
  end
176
183
 
177
184
  # Allows setting a default open_timeout for all HTTP calls in seconds
@@ -180,9 +187,9 @@ module HTTParty
180
187
  # include HTTParty
181
188
  # open_timeout 10
182
189
  # end
183
- def open_timeout(t)
184
- raise ArgumentError, 'open_timeout must be an integer or float' unless t && (t.is_a?(Integer) || t.is_a?(Float))
185
- default_options[:open_timeout] = t
190
+ def open_timeout(value)
191
+ validate_timeout_argument(__method__, value)
192
+ default_options[:open_timeout] = value
186
193
  end
187
194
 
188
195
  # Allows setting a default read_timeout for all HTTP calls in seconds
@@ -191,11 +198,24 @@ module HTTParty
191
198
  # include HTTParty
192
199
  # read_timeout 10
193
200
  # end
194
- def read_timeout(t)
195
- raise ArgumentError, 'read_timeout must be an integer or float' unless t && (t.is_a?(Integer) || t.is_a?(Float))
196
- default_options[:read_timeout] = t
201
+ def read_timeout(value)
202
+ validate_timeout_argument(__method__, value)
203
+ default_options[:read_timeout] = value
204
+ end
205
+
206
+ # Allows setting a default write_timeout for all HTTP calls in seconds
207
+ # Supported by Ruby > 2.6.0
208
+ #
209
+ # class Foo
210
+ # include HTTParty
211
+ # write_timeout 10
212
+ # end
213
+ def write_timeout(value)
214
+ validate_timeout_argument(__method__, value)
215
+ default_options[:write_timeout] = value
197
216
  end
198
217
 
218
+
199
219
  # Set an output stream for debugging, defaults to $stderr.
200
220
  # The output stream is passed on to Net::HTTP#set_debug_output.
201
221
  #
@@ -213,10 +233,14 @@ module HTTParty
213
233
  # include HTTParty
214
234
  # headers 'Accept' => 'text/html'
215
235
  # end
216
- def headers(h = {})
217
- raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
218
- default_options[:headers] ||= {}
219
- default_options[:headers].merge!(h.to_hash)
236
+ def headers(h = nil)
237
+ if h
238
+ raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
239
+ default_options[:headers] ||= {}
240
+ default_options[:headers].merge!(h.to_hash)
241
+ else
242
+ default_options[:headers] || {}
243
+ end
220
244
  end
221
245
 
222
246
  def cookies(h = {})
@@ -377,6 +401,22 @@ module HTTParty
377
401
  default_options[:ssl_version] = version
378
402
  end
379
403
 
404
+ # Deactivate automatic decompression of the response body.
405
+ # This will require you to explicitly handle body decompression
406
+ # by inspecting the Content-Encoding response header.
407
+ #
408
+ # Refer to docs/README.md "HTTP Compression" section for
409
+ # further details.
410
+ #
411
+ # @example
412
+ # class Foo
413
+ # include HTTParty
414
+ # skip_decompression
415
+ # end
416
+ def skip_decompression(value = true)
417
+ default_options[:skip_decompression] = !!value
418
+ end
419
+
380
420
  # Allows setting of SSL ciphers to use. This only works in Ruby 1.9+.
381
421
  # You can get a list of valid specific ciphers from OpenSSL::Cipher.ciphers.
382
422
  # You also can specify a cipher suite here, listed here at openssl.org:
@@ -543,10 +583,22 @@ module HTTParty
543
583
  perform_request Net::HTTP::Mkcol, path, options, &block
544
584
  end
545
585
 
586
+ def lock(path, options = {}, &block)
587
+ perform_request Net::HTTP::Lock, path, options, &block
588
+ end
589
+
590
+ def unlock(path, options = {}, &block)
591
+ perform_request Net::HTTP::Unlock, path, options, &block
592
+ end
593
+
546
594
  attr_reader :default_options
547
595
 
548
596
  private
549
597
 
598
+ def validate_timeout_argument(timeout_type, value)
599
+ raise ArgumentError, "#{ timeout_type } must be an integer or float" unless value && (value.is_a?(Integer) || value.is_a?(Float))
600
+ end
601
+
550
602
  def ensure_method_maintained_across_redirects(options)
551
603
  unless options.key?(:maintain_method_across_redirects)
552
604
  options[:maintain_method_across_redirects] = true
@@ -555,26 +607,21 @@ module HTTParty
555
607
 
556
608
  def perform_request(http_method, path, options, &block) #:nodoc:
557
609
  options = ModuleInheritableAttributes.hash_deep_dup(default_options).merge(options)
558
- process_headers(options)
610
+ HeadersProcessor.new(headers, options).call
559
611
  process_cookies(options)
560
612
  Request.new(http_method, path, options).perform(&block)
561
613
  end
562
614
 
563
- def process_headers(options)
564
- if options[:headers] && headers.any?
565
- options[:headers] = headers.merge(options[:headers])
566
- end
567
- end
568
-
569
615
  def process_cookies(options) #:nodoc:
570
616
  return unless options[:cookies] || default_cookies.any?
571
617
  options[:headers] ||= headers.dup
572
- options[:headers]["cookie"] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
618
+ options[:headers]['cookie'] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string
573
619
  end
574
620
 
575
621
  def validate_format
576
622
  if format && parser.respond_to?(:supports_format?) && !parser.supports_format?(format)
577
- raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{parser.supported_formats.map(&:to_s).sort.join(', ')}"
623
+ supported_format_names = parser.supported_formats.map(&:to_s).sort.join(', ')
624
+ raise UnsupportedFormat, "'#{format.inspect}' Must be one of: #{supported_format_names}"
578
625
  end
579
626
  end
580
627
  end
@@ -632,6 +679,7 @@ module HTTParty
632
679
  end
633
680
 
634
681
  require 'httparty/hash_conversions'
682
+ require 'httparty/utils'
635
683
  require 'httparty/exceptions'
636
684
  require 'httparty/parser'
637
685
  require 'httparty/request'
@@ -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,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  - Sandro Turriate
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-25 00:00:00.000000000 Z
12
+ date: 2022-12-30 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: mini_mime
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.0.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,15 @@ 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
- - ".simplecov"
40
- - ".travis.yml"
41
55
  - CONTRIBUTING.md
56
+ - Changelog.md
42
57
  - Gemfile
43
58
  - Guardfile
44
- - History
45
59
  - MIT-LICENSE
46
60
  - README.md
47
61
  - Rakefile
@@ -51,86 +65,53 @@ files:
51
65
  - examples/README.md
52
66
  - examples/aaws.rb
53
67
  - examples/basic.rb
68
+ - examples/body_stream.rb
54
69
  - examples/crack.rb
55
70
  - examples/custom_parsers.rb
56
71
  - examples/delicious.rb
57
72
  - examples/google.rb
58
73
  - examples/headers_and_user_agents.rb
74
+ - examples/idn.rb
59
75
  - examples/logging.rb
76
+ - examples/microsoft_graph.rb
77
+ - examples/multipart.rb
60
78
  - examples/nokogiri_html_parser.rb
79
+ - examples/peer_cert.rb
61
80
  - examples/rescue_json.rb
62
81
  - examples/rubyurl.rb
63
82
  - examples/stackexchange.rb
83
+ - examples/stream_download.rb
64
84
  - examples/tripit_sign_in.rb
65
85
  - examples/twitter.rb
66
86
  - 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
87
  - httparty.gemspec
82
88
  - lib/httparty.rb
83
89
  - lib/httparty/connection_adapter.rb
84
90
  - lib/httparty/cookie_hash.rb
91
+ - lib/httparty/decompressor.rb
85
92
  - lib/httparty/exceptions.rb
86
93
  - lib/httparty/hash_conversions.rb
94
+ - lib/httparty/headers_processor.rb
87
95
  - lib/httparty/logger/apache_formatter.rb
88
96
  - lib/httparty/logger/curl_formatter.rb
89
97
  - lib/httparty/logger/logger.rb
98
+ - lib/httparty/logger/logstash_formatter.rb
90
99
  - lib/httparty/module_inheritable_attributes.rb
91
100
  - lib/httparty/net_digest_auth.rb
92
101
  - lib/httparty/parser.rb
93
102
  - lib/httparty/request.rb
103
+ - lib/httparty/request/body.rb
104
+ - lib/httparty/request/multipart_boundary.rb
94
105
  - lib/httparty/response.rb
95
106
  - lib/httparty/response/headers.rb
107
+ - lib/httparty/response_fragment.rb
108
+ - lib/httparty/text_encoder.rb
109
+ - lib/httparty/utils.rb
96
110
  - lib/httparty/version.rb
97
111
  - 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
112
  - website/css/common.css
132
113
  - website/index.html
133
- homepage: http://jnunemaker.github.com/httparty
114
+ homepage: https://github.com/jnunemaker/httparty
134
115
  licenses:
135
116
  - MIT
136
117
  metadata: {}
@@ -142,63 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
123
  requirements:
143
124
  - - ">="
144
125
  - !ruby/object:Gem::Version
145
- version: 1.9.3
126
+ version: 2.3.0
146
127
  required_rubygems_version: !ruby/object:Gem::Requirement
147
128
  requirements:
148
129
  - - ">="
149
130
  - !ruby/object:Gem::Version
150
131
  version: '0'
151
132
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.4.5.1
154
- signing_key:
133
+ rubygems_version: 3.3.7
134
+ signing_key:
155
135
  specification_version: 4
156
136
  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
137
+ test_files: []
data/.simplecov DELETED
@@ -1 +0,0 @@
1
- SimpleCov.start "test_frameworks"
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.8
6
- - 2.2.4
7
- - 2.3.0
8
- bundler_args: --without development
9
- before_install: gem install bundler
@@ -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"]'