httparty 0.2.9 → 0.2.10

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.

data/History CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.10 2009-01-29
2
+ * 1 minor enhancement
3
+ * Made encoding on query parameters treat everything except URI::PATTERN::UNRESERVED as UNSAFE to force encoding of '+' character (Julian Russell)
4
+
1
5
  == 0.2.9 2009-01-29
2
6
  * 3 minor enhancements
3
7
  * Added a 'headers' accessor to the response with a hash of any HTTP headers. (Don Peterson)
data/Manifest CHANGED
@@ -33,6 +33,7 @@ Rakefile
33
33
  README
34
34
  setup.rb
35
35
  spec/as_buggery_spec.rb
36
+ spec/core_extensions_spec.rb
36
37
  spec/fixtures/delicious.xml
37
38
  spec/fixtures/empty.xml
38
39
  spec/fixtures/google.html
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{httparty}
5
- s.version = "0.2.9"
5
+ s.version = "0.2.10"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Nunemaker"]
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.email = %q{nunemaker@gmail.com}
13
13
  s.executables = ["httparty"]
14
14
  s.extra_rdoc_files = ["bin/httparty", "lib/core_extensions.rb", "lib/httparty/cookie_hash.rb", "lib/httparty/exceptions.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "lib/module_level_inheritable_attributes.rb", "README"]
15
- s.files = ["bin/httparty", "cucumber.yml", "examples/aaws.rb", "examples/basic.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "features/basic_authentication.feature", "features/command_line.feature", "features/deals_with_http_error_codes.feature", "features/handles_multiple_formats.feature", "features/steps/env.rb", "features/steps/httparty_response_steps.rb", "features/steps/httparty_steps.rb", "features/steps/mongrel_helper.rb", "features/steps/remote_service_steps.rb", "features/supports_redirection.feature", "History", "httparty.gemspec", "lib/core_extensions.rb", "lib/httparty/cookie_hash.rb", "lib/httparty/exceptions.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "lib/module_level_inheritable_attributes.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README", "setup.rb", "spec/as_buggery_spec.rb", "spec/fixtures/delicious.xml", "spec/fixtures/empty.xml", "spec/fixtures/google.html", "spec/fixtures/twitter.json", "spec/fixtures/twitter.xml", "spec/fixtures/undefined_method_add_node_for_nil.xml", "spec/httparty/cookie_hash_spec.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"]
15
+ s.files = ["bin/httparty", "cucumber.yml", "examples/aaws.rb", "examples/basic.rb", "examples/delicious.rb", "examples/google.rb", "examples/rubyurl.rb", "examples/twitter.rb", "examples/whoismyrep.rb", "features/basic_authentication.feature", "features/command_line.feature", "features/deals_with_http_error_codes.feature", "features/handles_multiple_formats.feature", "features/steps/env.rb", "features/steps/httparty_response_steps.rb", "features/steps/httparty_steps.rb", "features/steps/mongrel_helper.rb", "features/steps/remote_service_steps.rb", "features/supports_redirection.feature", "History", "httparty.gemspec", "lib/core_extensions.rb", "lib/httparty/cookie_hash.rb", "lib/httparty/exceptions.rb", "lib/httparty/request.rb", "lib/httparty/response.rb", "lib/httparty/version.rb", "lib/httparty.rb", "lib/module_level_inheritable_attributes.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README", "setup.rb", "spec/as_buggery_spec.rb", "spec/core_extensions_spec.rb", "spec/fixtures/delicious.xml", "spec/fixtures/empty.xml", "spec/fixtures/google.html", "spec/fixtures/twitter.json", "spec/fixtures/twitter.xml", "spec/fixtures/undefined_method_add_node_for_nil.xml", "spec/httparty/cookie_hash_spec.rb", "spec/httparty/request_spec.rb", "spec/httparty_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "website/css/common.css", "website/index.html"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://httparty.rubyforge.org}
18
18
  s.post_install_message = %q{When you HTTParty, you must party hard!}
@@ -310,7 +310,7 @@ class Hash
310
310
  #
311
311
  # @return <String> This key value pair as a param
312
312
  #
313
- # @example normalize_param(:name, "Bob") #=> "name=Bob&"
313
+ # @example normalize_param(:name, "Bob Jones") #=> "name=Bob%20Jones&"
314
314
  def normalize_param(key, value)
315
315
  param = ''
316
316
  stack = []
@@ -320,7 +320,7 @@ class Hash
320
320
  elsif value.is_a?(Hash)
321
321
  stack << [key,value]
322
322
  else
323
- param << "#{key}=#{URI.encode(value.to_s)}&"
323
+ param << "#{key}=#{URI.encode(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}&"
324
324
  end
325
325
 
326
326
  stack.each do |parent, hash|
@@ -1,3 +1,3 @@
1
1
  module HTTParty
2
- Version = '0.2.9'
2
+ Version = '0.2.10'
3
3
  end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe "Core Extensions" do
4
+ describe Hash do
5
+ describe "#to_params" do
6
+ def should_be_same_params(query_string, expected)
7
+ query_string.split(/&/).sort.should == expected.split(/&/).sort
8
+ end
9
+
10
+ it "should encode characters in URL parameters" do
11
+ {:q => "?&\" +"}.to_params.should == "q=%3F%26%22%20%2B"
12
+ end
13
+
14
+ it "should handle multiple parameters" do
15
+ should_be_same_params({:q1 => "p1", :q2 => "p2"}.to_params, "q1=p1&q2=p2")
16
+ end
17
+
18
+ it "should handle nested hashes like rails does" do
19
+ should_be_same_params({
20
+ :name => "Bob",
21
+ :address => {
22
+ :street => '111 Ruby Ave.',
23
+ :city => 'Ruby Central',
24
+ :phones => ['111-111-1111', '222-222-2222']
25
+ }
26
+ }.to_params, "name=Bob&address[city]=Ruby%20Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111%20Ruby%20Ave.")
27
+ end
28
+ end
29
+ end
30
+ end
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.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -85,6 +85,7 @@ files:
85
85
  - README
86
86
  - setup.rb
87
87
  - spec/as_buggery_spec.rb
88
+ - spec/core_extensions_spec.rb
88
89
  - spec/fixtures/delicious.xml
89
90
  - spec/fixtures/empty.xml
90
91
  - spec/fixtures/google.html