riak-client 0.8.0.beta → 0.8.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/lib/active_support/cache/riak_store.rb +15 -0
- data/lib/riak.rb +0 -1
- data/lib/riak/cache_store.rb +1 -0
- data/lib/riak/util/headers.rb +20 -0
- data/spec/riak/headers_spec.rb +19 -2
- metadata +4 -3
data/Gemfile
CHANGED
@@ -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'
|
data/lib/riak.rb
CHANGED
data/lib/riak/cache_store.rb
CHANGED
data/lib/riak/util/headers.rb
CHANGED
@@ -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
|
data/spec/riak/headers_spec.rb
CHANGED
@@ -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
|
-
-
|
10
|
-
version: 0.8.0.
|
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-
|
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
|