httsoiree 0.13.1.1 → 0.13.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b96e1f9c5ddf1d48bf3c1e775c74b3e8ee7ae37b
4
- data.tar.gz: c12b50e32aa15f2d29266305d9bb55d0d36a2895
3
+ metadata.gz: 3c7ed88eddd591d2874d80dafab53ea630a49c97
4
+ data.tar.gz: 98ab50d2c6e1854bbe432541278e77f547a07388
5
5
  SHA512:
6
- metadata.gz: f5142045a09dedf5b7e62e898173aaf7d12ff5a0818d3d451d50bd645a7a2317f8f38d932062e5397288ef93216c8706a013109198d94f324457abca99c73cf9
7
- data.tar.gz: 95bb1a46d509354a2b7b0233bb19d4f0bcf299de8bca27fedae2033df2b934f5da7349051bbe657547ca6a908902f2a3bb6b6b4b1790d30f8bbf20d6c7a2503e
6
+ metadata.gz: 963f349a908e914f7a32662da3cdc245afb8c6e7f876224ff9f82a41e826d3b78255314df9a4480bd188460120353c881f89e0bb06ba565b12f1742f1fea6b20
7
+ data.tar.gz: 378d4875409f133f4ec7be1dac5df54a93e588fab2cbafa1ef3cfb27807f1528d580af3939762b9e8810e85ddb8f9e2aeb2d995bbaeaf7e386772fd1cf2ca902
data/History CHANGED
@@ -1,8 +1,76 @@
1
- == 0.10.1 2013-01-26
1
+ == 0.13.3
2
+ * minor improvement
3
+ * added option to allow for streaming large files without loading them into memory (672cdae)
4
+
5
+ == 0.13.2
6
+ * minor improvement
7
+ * [Set correct path on redirect to filename](https://github.com/jnunemaker/httparty/pull/337)
8
+ * ensure logger works with curl format
9
+
10
+ == 0.13.1 2014-04-08
11
+ * new
12
+ * [Added ability to specify a body_stream in HttpRequest](https://github.com/jnunemaker/httparty/pull/275)
13
+ * [Added read_timeout and open_timeout options](https://github.com/jnunemaker/httparty/pull/278)
14
+ * change
15
+ * [Initialize HTTParty requests with an URI object and a String](https://github.com/jnunemaker/httparty/pull/274)
16
+ * minor improvement
17
+ * [Add stackexchange API example](https://github.com/jnunemaker/httparty/pull/280)
18
+
19
+ == 0.13.0 2014-02-14
20
+ * new
21
+ * [Add CSV support](https://github.com/jnunemaker/httparty/pull/269)
22
+ * [Allows PKCS12 client certificates](https://github.com/jnunemaker/httparty/pull/246)
23
+ * bug fix
24
+ * [Digest auth no longer fails when multiple headers are sent by the server](https://github.com/jnunemaker/httparty/pull/272)
25
+ * [Use 'Basement.copy' when calling 'HTTParty.copy'](https://github.com/jnunemaker/httparty/pull/268)
26
+ * [No longer appends ampersand when queries are embedded in paths](https://github.com/jnunemaker/httparty/pull/252)
27
+ * change
28
+ * [Merge - instead of overwrite - default headers with request provided headers](https://github.com/jnunemaker/httparty/pull/270)
29
+ * [Modernize respond_to implementations to support second param](https://github.com/jnunemaker/httparty/pull/264)
30
+ * [Sort query parameters by key before processing](https://github.com/jnunemaker/httparty/pull/245)
31
+ * minor improvement
32
+ * [Add HTTParty::Error base class](https://github.com/jnunemaker/httparty/pull/260)
33
+
34
+ == 0.12.0 2013-10-10
35
+ * new
36
+ * [Added initial logging support](https://github.com/jnunemaker/httparty/pull/243)
37
+ * [Add support for local host and port binding](https://github.com/jnunemaker/httparty/pull/238)
38
+ * [content_type_charset_support](https://github.com/jnunemaker/httparty/commit/82e351f0904e8ecc856015ff2854698a2ca47fbc)
39
+ * bug fix
40
+ * [No longer attempt to decompress the body on HEAD requests](https://github.com/jnunemaker/httparty/commit/f2b8cc3d49e0e9363d7054b14f30c340d7b8e7f1)
41
+ * [Adding java check in aliasing of multiple choices](https://github.com/jnunemaker/httparty/pull/204/commits)
42
+ * change
43
+ * [MIME-type files of javascript are returned as a string instead of JSON](https://github.com/jnunemaker/httparty/pull/239)
44
+ * [Made SSL connections use the system certificate store by default](https://github.com/jnunemaker/httparty/pull/226)
45
+ * [Do not pass proxy options to Net::HTTP connection if not specified](https://github.com/jnunemaker/httparty/pull/222)
46
+ * [Replace multi_json with stdlib json](https://github.com/jnunemaker/httparty/pull/214)
47
+ * [Require Ruby >= 1.9.3]
48
+ * [Response returns array of returned cookie strings](https://github.com/jnunemaker/httparty/pull/218)
49
+ * [Allow '=' within value of a cookie]
50
+ * minor improvements
51
+ * [Improve documentation of ssl_ca_file, ssl_ca_path](https://github.com/jnunemaker/httparty/pull/223)
52
+ * [Fix example URLs](https://github.com/jnunemaker/httparty/pull/232)
53
+
54
+ == 0.11.0 2013-04-10
55
+ * new
56
+ * [Add COPY http request handling](https://github.com/jnunemaker/httparty/pull/190)
57
+ * [Ruby 2.0 tests](https://github.com/jnunemaker/httparty/pull/194)
58
+ * [Ruby >= 2.0.0 support both multiple_choice? and multiple_choices?]
59
+ * bug fix
60
+ * [Maintain blocks passed to 'perform' in redirects](https://github.com/jnunemaker/httparty/pull/191)
61
+ * [Fixed nc value being quoted, this was against spec](https://github.com/jnunemaker/httparty/pull/196)
62
+ * [Request#uri no longer duplicates non-relative-path params](https://github.com/jnunemaker/httparty/pull/189)
63
+ * change
64
+ * [Client-side-only cookie attributes are removed: case-insensitive](https://github.com/jnunemaker/httparty/pull/188)
2
65
 
66
+ == 0.10.2 2013-01-26
67
+ * bug fix
68
+ * [hash_conversions misnamed variable](https://github.com/jnunemaker/httparty/pull/187)
69
+
70
+ == 0.10.1 2013-01-26
3
71
  * new
4
- * [added support for MOVE requests](https://github.com/jnunemaker/httparty/pull/183)
5
- * [bump multi xml version](https://github.com/jnunemaker/httparty/pull/181)
72
+ * [Added support for MOVE requests](https://github.com/jnunemaker/httparty/pull/183)
73
+ * [Bump multi xml version](https://github.com/jnunemaker/httparty/pull/181)
6
74
 
7
75
  == 0.10.0 2013-01-10
8
76
  * changes
@@ -12,7 +80,6 @@
12
80
  * new
13
81
  * [support for connection adapters](https://github.com/jnunemaker/httparty/pull/157)
14
82
  * [allow ssl_version on ruby 1.9](https://github.com/jnunemaker/httparty/pull/159)
15
-
16
83
  * bug fixes
17
84
  * [don't treat port 4430 as ssl](https://github.com/jnunemaker/httparty/commit/a296b1c97f83d7dcc6ef85720a43664c265685ac)
18
85
  * [deep clone default options](https://github.com/jnunemaker/httparty/commit/f74227d30f9389b4b23a888c9af49fb9b8248e1f)
@@ -282,20 +349,20 @@
282
349
  == 0.1.3 2008-08-22
283
350
 
284
351
  * 3 major enhancements:
285
- * Added http_proxy key for setting proxy server and port (francxk@gmail.com)
286
- * Now raises exception when http error occurs (francxk@gmail.com)
287
- * Changed auto format detection from file extension to response content type (Jay Pignata)
352
+ * Added http_proxy key for setting proxy server and port (francxk@gmail.com)
353
+ * Now raises exception when http error occurs (francxk@gmail.com)
354
+ * Changed auto format detection from file extension to response content type (Jay Pignata)
288
355
 
289
356
  == 0.1.2 2008-08-09
290
357
 
291
358
  * 1 major enhancement:
292
- * default_params were not being appended to query string if option[:query] was blank
359
+ * default_params were not being appended to query string if option[:query] was blank
293
360
 
294
361
  == 0.1.1 2008-07-30
295
362
 
296
363
  * 2 major enhancement:
297
- * Added :basic_auth key for options when making a request
298
- * :query and :body both now work with query string or hash
364
+ * Added :basic_auth key for options when making a request
365
+ * :query and :body both now work with query string or hash
299
366
 
300
367
  == 0.1.0 2008-07-27
301
368
 
data/README.md CHANGED
@@ -71,11 +71,4 @@ httsoiree "https://api.stackexchange.com/2.2/questions?site=stackoverflow"
71
71
 
72
72
  ## Contributing
73
73
 
74
- * Fork the project.
75
- * Run `bundle`
76
- * Run `bundle exec rake`
77
- * Make your feature addition or bug fix.
78
- * Add tests for it. This is important so I don't break it in a future version unintentionally.
79
- * Run `bundle exec rake` (No, REALLY :))
80
- * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
81
- * Send me a pull request. Bonus points for topic branches.
74
+ Contribute to https://github.com/jnunemaker/httparty. This fork will stay pegged to the latest version.
data/Rakefile CHANGED
@@ -3,7 +3,6 @@ Spec::Rake::SpecTask.new(:spec) do |spec|
3
3
  spec.ruby_opts << '-rubygems'
4
4
  spec.libs << 'lib' << 'spec'
5
5
  spec.spec_files = FileList['spec/**/*_spec.rb']
6
- spec.spec_opts = ['--options', 'spec/spec.opts']
7
6
  end
8
7
 
9
8
  require 'cucumber/rake/task'
@@ -0,0 +1,64 @@
1
+ ## Examples
2
+
3
+ * [Amazon Book Search](aaws.rb)
4
+ * Httparty included into poro class
5
+ * Uses `get` requests
6
+ * Transforms query params to uppercased params
7
+
8
+ * [Google Search](google.rb)
9
+ * Httparty included into poro class
10
+ * Uses `get` requests
11
+
12
+ * [Crack Custom Parser](crack.rb)
13
+ * Creates a custom parser for XML using crack gem
14
+ * Uses `get` request
15
+
16
+ * [Create HTML Nokogiri parser](nokogiri_html_parser.rb)
17
+ * Adds Html as a format
18
+ * passed the body of request to Nokogiri
19
+
20
+ * [More Custom Parsers](custom_parsers.rb)
21
+ * Create an additional parser for atom or make it the ONLY parser
22
+
23
+ * [Basic Auth, Delicious](delicious.rb)
24
+ * Basic Auth, shows how to merge those into options
25
+ * Uses `get` requests
26
+
27
+ * [Passing Headers, User Agent](headers_and_user_agents.rb)
28
+ * Use the class method of Httparty
29
+ * Pass the User-Agent in the headers
30
+ * Uses `get` requests
31
+
32
+ * [Basic Post Request](basic.rb)
33
+ * Httparty included into poro class
34
+ * Uses `post` requests
35
+
36
+ * [Access Rubyurl Shortener](rubyurl.rb)
37
+ * Httparty included into poro class
38
+ * Uses `post` requests
39
+
40
+ * [Add a custom log file](logging.rb)
41
+ * create a log file and have httparty log requests
42
+
43
+ * [Accessing StackExchange](stackexchange.rb)
44
+ * Httparty included into poro class
45
+ * Creates methods for different endpoints
46
+ * Uses `get` requests
47
+
48
+ * [Accessing Tripit](tripit_sign_in.rb)
49
+ * Httparty included into poro class
50
+ * Example of using `debug_output` to see headers/urls passed
51
+ * Getting and using Cookies
52
+ * Uses `get` requests
53
+
54
+ * [Accessing Twitter](twitter.rb)
55
+ * Httparty included into poro class
56
+ * Basic Auth
57
+ * Loads settings from a config file
58
+ * Uses `get` requests
59
+ * Uses `post` requests
60
+
61
+ * [Accessing WhoIsMyRep](whoismyrep.rb)
62
+ * Httparty included into poro class
63
+ * Uses `get` requests
64
+ * Two ways to pass params to get, inline on the url or in query hash
@@ -153,6 +153,7 @@ module HTTParty
153
153
  end
154
154
 
155
155
  # Client certificate authentication
156
+ # Note: options[:pem] must contain the content of a PEM file having the private key appended
156
157
  if options[:pem]
157
158
  http.cert = OpenSSL::X509::Certificate.new(options[:pem])
158
159
  http.key = OpenSSL::PKey::RSA.new(options[:pem], options[:pem_password])
@@ -5,7 +5,7 @@ module HTTParty
5
5
  module Logger
6
6
  def self.build(logger, level, formatter)
7
7
  level ||= :info
8
- format ||= :apache
8
+ formatter ||= :apache
9
9
 
10
10
  case formatter
11
11
  when :curl
@@ -44,7 +44,10 @@ module Net
44
44
  private
45
45
 
46
46
  def parse(response_header)
47
- response_header['www-authenticate'] =~ /Digest (.*)/
47
+ header = response_header['www-authenticate']
48
+ .gsub(/qop=(auth(?:-int)?)/, %Q(qop="\\1"))
49
+
50
+ header =~ /Digest (.*)/
48
51
  params = {}
49
52
  $1.gsub(/(\w+)="(.*?)"/) { params[$1] = $2 }
50
53
  params
@@ -40,6 +40,7 @@ module HTTParty
40
40
  parser: Parser,
41
41
  connection_adapter: ConnectionAdapter
42
42
  }.merge(o)
43
+ set_basic_auth_from_uri
43
44
  end
44
45
 
45
46
  def path=(uri)
@@ -55,6 +56,10 @@ module HTTParty
55
56
  end
56
57
 
57
58
  def uri
59
+ if redirect && path.relative? && path.path[0] != "/"
60
+ path.path = @last_uri.path.gsub(/[^\/]+$/, "") + path.path
61
+ end
62
+
58
63
  new_uri = path.relative? ? URI.parse("#{base_uri}#{path}") : path.clone
59
64
 
60
65
  # avoid double query string on redirects [#12]
@@ -95,7 +100,7 @@ module HTTParty
95
100
  chunks = []
96
101
 
97
102
  http_response.read_body do |fragment|
98
- chunks << fragment
103
+ chunks << fragment unless options[:stream_body]
99
104
  block.call(fragment)
100
105
  end
101
106
 
@@ -335,5 +340,12 @@ module HTTParty
335
340
  def post?
336
341
  Net::HTTP::Post == http_method
337
342
  end
343
+
344
+ def set_basic_auth_from_uri
345
+ if path.userinfo
346
+ username, password = path.userinfo.split(':')
347
+ options[:basic_auth] = {:username => username, :password => password}
348
+ end
349
+ end
338
350
  end
339
351
  end
@@ -1,3 +1,3 @@
1
1
  module HTTParty
2
- VERSION = "0.13.1.1"
2
+ VERSION = "0.13.3"
3
3
  end
@@ -75,6 +75,17 @@ describe Net::HTTPHeader::DigestAuthenticator do
75
75
  end
76
76
  end
77
77
 
78
+ context "when quality of protection (qop) is unquoted" do
79
+ before do
80
+ @digest = setup_digest({
81
+ 'www-authenticate' => 'Digest realm="myhost@testrealm.com", nonce="NONCE", qop=auth',
82
+ })
83
+ end
84
+
85
+ it "should still set qop" do
86
+ authorization_header.should include(%Q(qop="auth"))
87
+ end
88
+ end
78
89
 
79
90
  context "with unspecified quality of protection (qop)" do
80
91
  before do
@@ -56,6 +56,23 @@ describe HTTParty::Request do
56
56
  request = HTTParty::Request.new(Net::HTTP::Get, 'http://google.com', connection_adapter: my_adapter)
57
57
  request.connection_adapter.should == my_adapter
58
58
  end
59
+
60
+ context "when basic authentication credentials provided in uri" do
61
+ context "when basic auth options wasn't set explicitly" do
62
+ it "sets basic auth from uri" do
63
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://user1:pass1@example.com')
64
+ request.options[:basic_auth].should == {:username => 'user1', :password => 'pass1'}
65
+ end
66
+ end
67
+
68
+ context "when basic auth options was set explicitly" do
69
+ it "uses basic auth from url anyway" do
70
+ basic_auth = {:username => 'user2', :password => 'pass2'}
71
+ request = HTTParty::Request.new(Net::HTTP::Get, 'http://user1:pass1@example.com', :basic_auth => basic_auth)
72
+ request.options[:basic_auth].should == {:username => 'user1', :password => 'pass1'}
73
+ end
74
+ end
75
+ end
59
76
  end
60
77
 
61
78
  describe "#format" do
@@ -127,6 +144,32 @@ describe HTTParty::Request do
127
144
  end
128
145
 
129
146
  describe "#uri" do
147
+ context "redirects" do
148
+ it "returns correct path when the server sets the location header to a filename" do
149
+ @request.last_uri = URI.parse("http://example.com/foo/bar")
150
+ @request.path = URI.parse("bar?foo=bar")
151
+ @request.redirect = true
152
+
153
+ @request.uri.should == URI.parse("http://example.com/foo/bar?foo=bar")
154
+ end
155
+
156
+ it "returns correct path when the server sets the location header to an absolute path" do
157
+ @request.last_uri = URI.parse("http://example.com/foo/bar")
158
+ @request.path = URI.parse("/bar?foo=bar")
159
+ @request.redirect = true
160
+
161
+ @request.uri.should == URI.parse("http://example.com/bar?foo=bar")
162
+ end
163
+
164
+ it "returns correct path when the server sets the location header to a full uri" do
165
+ @request.last_uri = URI.parse("http://example.com/foo/bar")
166
+ @request.path = URI.parse("http://example.com/bar?foo=bar")
167
+ @request.redirect = true
168
+
169
+ @request.uri.should == URI.parse("http://example.com/bar?foo=bar")
170
+ end
171
+ end
172
+
130
173
  context "query strings" do
131
174
  it "does not add an empty query string when default_params are blank" do
132
175
  @request.options[:default_params] = {}
@@ -346,7 +389,6 @@ describe HTTParty::Request do
346
389
  end
347
390
  end
348
391
 
349
-
350
392
  describe 'with non-200 responses' do
351
393
  context "3xx responses" do
352
394
  it 'returns a valid object for 304 not modified' do
@@ -699,6 +699,16 @@ describe HTTParty do
699
699
  end.should == chunks.join
700
700
  end
701
701
 
702
+ it "should return an empty body if stream_body option is turned on" do
703
+ chunks = ["Chunk1", "Chunk2", "Chunk3", "Chunk4"]
704
+ options = {stream_body: true, format: 'html'}
705
+ stub_chunked_http_response_with(chunks, options)
706
+
707
+ HTTParty.get('http://www.google.com', options) do |fragment|
708
+ chunks.should include(fragment)
709
+ end.should == nil
710
+ end
711
+
702
712
  it "should be able parse response type json automatically" do
703
713
  stub_http_response_with('twitter.json')
704
714
  tweets = HTTParty.get('http://twitter.com/statuses/public_timeline.json')
@@ -13,14 +13,14 @@ module HTTParty
13
13
  HTTParty::Request.should_receive(:new).and_return(http_request)
14
14
  end
15
15
 
16
- def stub_chunked_http_response_with(chunks)
16
+ def stub_chunked_http_response_with(chunks, options={format: "html"})
17
17
  response = Net::HTTPResponse.new("1.1", 200, nil)
18
18
  response.stub(:chunked_data).and_return(chunks)
19
19
  def response.read_body(&block)
20
20
  @body || chunked_data.each(&block)
21
21
  end
22
22
 
23
- http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', format: "html")
23
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', options)
24
24
  http_request.stub_chain(:http, :request).and_yield(response).and_return(response)
25
25
 
26
26
  HTTParty::Request.should_receive(:new).and_return(http_request)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httsoiree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1.1
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-07 00:00:00.000000000 Z
13
+ date: 2015-03-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -60,6 +60,7 @@ files:
60
60
  - bin/httparty
61
61
  - bin/httsoiree
62
62
  - cucumber.yml
63
+ - examples/README.md
63
64
  - examples/aaws.rb
64
65
  - examples/basic.rb
65
66
  - examples/crack.rb
@@ -135,7 +136,6 @@ files:
135
136
  - spec/httparty/response_spec.rb
136
137
  - spec/httparty/ssl_spec.rb
137
138
  - spec/httparty_spec.rb
138
- - spec/spec.opts
139
139
  - spec/spec_helper.rb
140
140
  - spec/support/ssl_test_helper.rb
141
141
  - spec/support/ssl_test_server.rb
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.2.2
165
+ rubygems_version: 2.4.5
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Makes http fun! Also, makes consuming restful web services dead easy.
@@ -209,9 +209,7 @@ test_files:
209
209
  - spec/httparty/response_spec.rb
210
210
  - spec/httparty/ssl_spec.rb
211
211
  - spec/httparty_spec.rb
212
- - spec/spec.opts
213
212
  - spec/spec_helper.rb
214
213
  - spec/support/ssl_test_helper.rb
215
214
  - spec/support/ssl_test_server.rb
216
215
  - spec/support/stub_response.rb
217
- has_rdoc:
@@ -1,2 +0,0 @@
1
- --colour
2
- --backtrace