Method: Rex::Proto::Http::Request::UnitTest#test_from_s

Defined in:
lib/rex/proto/http/request.rb.ut.rb

#test_from_sObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rex/proto/http/request.rb.ut.rb', line 27

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('POST', h.method, 'method')
  assert_equal('/foo', h.uri, 'uri')
  assert_equal('1.0', h.proto, 'proto')
  assert_equal('Babies', h['Eat'], 'header')

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

  h.method = 'GET'
  assert_equal("GET /foo HTTP/1.0\r\n", h.cmd_string, 'set method')

  h.uri = '/bar'
  assert_equal("GET /bar HTTP/1.0\r\n", h.cmd_string, 'set uri')

  h.proto = '1.2'
  assert_equal("GET /bar HTTP/1.2\r\n", h.cmd_string, 'set proto')
end