Sha256: 584502c05f62c0b65286e714eb78625827bc29d39ce45687e879019d4afcd297

Contents?: true

Size: 1.17 KB

Versions: 24

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Riak::Util::Headers do
  it "should include the Net::HTTPHeader module" do
    Riak::Util::Headers.included_modules.should include(Net::HTTPHeader)
  end

  it "should be initially empty" do
    Riak::Util::Headers.new.to_hash.should == {}
  end

  it "should parse a header line into the key and value" do
    Riak::Util::Headers.parse("Content-Type: text/plain\r\n").should == ["Content-Type", "text/plain"]
  end

  it "should parse a header line and add it to the collection" do
    h = Riak::Util::Headers.new
    h.parse("Content-Type: text/plain\r\n")
    h.to_hash.should == {"content-type" => ["text/plain"]}
  end

  it "should split headers larger than 8KB" do
    # This really tests Net::HTTPHeader#each_capitalized, which is
    # used by Net::HTTP to write the headers to the socket. It does
    # not cover the case where a single value is larger than 8KB. If
    # you're doing that, you have something else wrong.
    h = Riak::Util::Headers.new
    10.times do
      h.add_field "Link", "f" * 820
    end
    count = 0
    h.each_capitalized do |k,v|
      count += 1
      "#{k}: #{v}\r\n".length.should < 8192
    end
    count.should > 1
  end
end

Version data entries

24 entries across 14 versions & 2 rubygems

Version Path
riak-client-1.4.4 spec/riak/headers_spec.rb
riak-client-1.4.3 spec/riak/headers_spec.rb
riak-client-1.4.2 spec/riak/headers_spec.rb
riak-client-1.4.1 spec/riak/headers_spec.rb
riak-client-1.4.0 spec/riak/headers_spec.rb
riak-client-1.2.0 spec/riak/headers_spec.rb
riak-client-1.1.1 spec/riak/headers_spec.rb
riak-client-1.1.0 spec/riak/headers_spec.rb
riak-client-1.0.5 spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.0/spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/spec/riak/headers_spec.rb
riak-client-1.0.3 spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.0/spec/riak/headers_spec.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/spec/riak/headers_spec.rb
riak-client-1.0.2 pkg/riak-client-1.0.0/spec/riak/headers_spec.rb
riak-client-1.0.2 pkg/riak-client-1.0.1/spec/riak/headers_spec.rb
riak-client-1.0.2 spec/riak/headers_spec.rb