riak-client 0.8.0.beta → 0.8.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Gemfile
2
2
  source :gemcutter
3
3
 
4
- gem 'activesupport', '~>2.3.5' # '3.0.0.rc'
4
+ gem 'activesupport', '~>2.3.5' # '3.0.0'
5
5
  gem 'i18n'
6
6
 
7
7
  gem 'rspec', "~>2.0.0.beta.18"
@@ -0,0 +1,15 @@
1
+ # Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'riak'
15
+ require 'riak/cache_store'
@@ -37,7 +37,6 @@ module Riak
37
37
  # Cache store - only supports Rails 3 style
38
38
  if ActiveSupport::VERSION::STRING >= "3.0.0"
39
39
  autoload :CacheStore, "riak/cache_store"
40
- ::ActiveSupport::Cache.autoload :RiakStore, "riak/cache_store"
41
40
  end
42
41
 
43
42
  # Exceptions
@@ -17,6 +17,7 @@ module Riak
17
17
  attr_accessor :client
18
18
 
19
19
  def initialize(options = {})
20
+ super
20
21
  @bucket_name = options.delete(:bucket) || '_cache'
21
22
  @n_value = options.delete(:n_value) || 2
22
23
  @r = options.delete(:r) || 1
@@ -13,6 +13,26 @@
13
13
  # limitations under the License.
14
14
  require 'riak'
15
15
 
16
+ # Splits headers into < 8KB chunks
17
+ module Net::HTTPHeader
18
+ def each_capitalized
19
+ # 1.9 check
20
+ respond_to?(:enum_for) and (block_given? or return enum_for(__method__))
21
+ @header.each do |k,v|
22
+ base_length = "#{k}: \r\n".length
23
+ values = v.map {|i| i.split(", ") }.flatten
24
+ while !values.empty?
25
+ current_line = ""
26
+ while values.first && current_line.length + base_length + values.first.length + 2 < 8192
27
+ val = values.shift.strip
28
+ current_line += current_line.empty? ? val : ", #{val}"
29
+ end
30
+ yield capitalize(k), current_line
31
+ end
32
+ end
33
+ end
34
+ end
35
+
16
36
  module Riak
17
37
  module Util
18
38
  # Represents headers from an HTTP response
@@ -23,12 +23,29 @@ describe Riak::Util::Headers do
23
23
  end
24
24
 
25
25
  it "should parse a header line into the key and value" do
26
- Riak::Util::Headers.parse("Content-Type: text/plain\n").should == ["Content-Type", "text/plain"]
26
+ Riak::Util::Headers.parse("Content-Type: text/plain\r\n").should == ["Content-Type", "text/plain"]
27
27
  end
28
28
 
29
29
  it "should parse a header line and add it to the collection" do
30
30
  h = Riak::Util::Headers.new
31
- h.parse("Content-Type: text/plain\n")
31
+ h.parse("Content-Type: text/plain\r\n")
32
32
  h.to_hash.should == {"content-type" => ["text/plain"]}
33
33
  end
34
+
35
+ it "should split headers larger than 8KB" do
36
+ # This really tests Net::HTTPHeader#each_capitalized, which is
37
+ # used by Net::HTTP to write the headers to the socket. It does
38
+ # not cover the case where a single value is larger than 8KB. If
39
+ # you're doing that, you have something else wrong.
40
+ h = Riak::Util::Headers.new
41
+ 10.times do
42
+ h.add_field "Link", "f" * 820
43
+ end
44
+ count = 0
45
+ h.each_capitalized do |k,v|
46
+ count += 1
47
+ "#{k}: #{v}\r\n".length.should < 8192
48
+ end
49
+ count.should > 1
50
+ end
34
51
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 8
8
8
  - 0
9
- - beta
10
- version: 0.8.0.beta
9
+ - beta2
10
+ version: 0.8.0.beta2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Cribbs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-24 00:00:00 -04:00
18
+ date: 2010-08-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -118,6 +118,7 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - Gemfile
120
120
  - Gemfile.lock
121
+ - lib/active_support/cache/riak_store.rb
121
122
  - lib/riak/bucket.rb
122
123
  - lib/riak/cache_store.rb
123
124
  - lib/riak/client/curb_backend.rb