Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/http/packet/header_spec.rb
Views: 11791
1require 'spec_helper'23RSpec.describe Rex::Proto::Http::Packet::Header do45it_behaves_like "hash with insensitive keys"67let :original_str do8"POST /foo HTTP/1.0\r\n" \9"Content-Length: 0\r\n" \10"Foo: Bar\r\n" \11"Bar: Baz\r\n" \12"Combine-me: one\r\n" \13"Combine-me: two\r\n" \14"\r\n"15end1617describe "#from_s" do18subject(:headers) do19h = described_class.new20h.from_s(original_str)21h22end2324it "should create keys and values for each header" do25expect(headers['Foo']).to eq "Bar"26expect(headers['Content-Length']).to eq "0"27end2829it "should combine headers" do30expect(headers['Combine-me']).to eq "one, two"31end3233context "with folding" do34let :original_str do35"POST /foo HTTP/1.0\r\n" \36"Spaces:\r\n" \37" Bar\r\n" \38"Tabs:\r\n" \39"\tBar\r\n" \40"\r\n"41end42it "should recognize spaces" do43expect(headers['Spaces']).to eq "Bar"44end45it "should recognize tabs" do46expect(headers['Tabs']).to eq "Bar"47end48end4950end5152describe "#to_s" do53subject(:header_string) do54h = described_class.new55h.from_s(original_str)56h.to_s57end5859context "without combining" do60let :original_str do61"POST /foo HTTP/1.0\r\n" \62"Foo: Bar\r\n" \63"Bar: Baz\r\n" \64"\r\n"65end6667it "should return the same string" do68expect(header_string).to eq original_str69end70end71context "with combining" do72let :original_str do73"POST /foo HTTP/1.0\r\n" \74"Foo: Bar\r\n" \75"Foo: Baz\r\n" \76"Foo: Bab\r\n" \77"\r\n"78end79it "should produce an equivalent string" do80#pending "who knows"81combined = "Foo: Bar, Baz, Bab\r\n\r\n"82expect(header_string).to eq combined83end84end85end8687end888990