Sha256: 599e1a5d8c50c7a89dd52f2a0a66b4a0afdcbf74757359dfa466bdb85b557487

Contents?: true

Size: 936 Bytes

Versions: 43

Compression:

Stored size: 936 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))

require 'test/unit'
require 'rex/proto/http'

class Rex::Proto::Http::Packet::Header::UnitTest < Test::Unit::TestCase

	Klass = Rex::Proto::Http::Packet::Header

	def test_to_s
		h = Klass.new

		h['Foo']     = 'Fishing'
		h['Chicken'] = 47

		assert_equal(
			"Foo: Fishing\r\n" +
			"Chicken: 47\r\n\r\n", h.to_s)
	end

	def test_from_s
		h = Klass.new

		h.from_s(
			"POST /foo HTTP/1.0\r\n" +
			"Lucifer: Beast\r\n" +
			"HoHo: Satan\r\n" +
			"Eat: Babies\r\n" +
			"\r\n")

		assert_equal('Babies', h['Eat'], 'header')
		assert_equal('Satan', h['HoHo'], 'header')
		assert_equal('Satan', h['hOhO'], 'header')

		assert_equal("POST /foo HTTP/1.0\r\n", h.cmd_string, 'cmd_string')
	end

	def test_just_cmdstring
		h = Klass.new

		h.from_s("POST /foo HTTP/1.0")
		assert_equal("POST /foo HTTP/1.0\r\n", h.cmd_string, 'just cmd_string')
	end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.63 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.54 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.53 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.52 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.51 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.50 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.49 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.48 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.47 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.46 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.44 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.43 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.42 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.41 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.40 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.39 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.38 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.37 lib/rex/proto/http/header.rb.ut.rb
librex-0.0.36 lib/rex/proto/http/header.rb.ut.rb