Sha256: 6eaa2c0e39ada05f3c38888eaad001499de4c8a8f6aae11f5d9cadfa54220955

Contents?: true

Size: 972 Bytes

Versions: 17

Compression:

Stored size: 972 Bytes

Contents

require 'test/unit'
require 'http11'


class HttpParserTest < Test::Unit::TestCase
    
  def test_parse_simple
    parser = HttpParser.new
    req = {}
    http = "GET / HTTP/1.1\r\n\r\n"
    nread = parser.execute(req, http);
    assert nread == http.length, "Failed to parse the full HTTP request"
    assert parser.finished?, "Parser didn't finish"
    assert !parser.error?, "Parser had error"
    assert nread == parser.nread, "Number read returned from execute does not match"
    parser.reset
    assert parser.nread == 0, "Number read after reset should be 0"
  end
  
  
  def test_parse_error
    parser = HttpParser.new
    req = {}
    bad_http = "GET / SsUTF/1.1"

    error = false
    begin
      nread = parser.execute(req, bad_http)
    rescue => details
      error = true
    end

    assert error, "failed to throw exception"
    assert !parser.finished?, "Parser shouldn't be finished"
    assert parser.error?, "Parser SHOULD have error"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mongrel-0.2.2 test/test_http11.rb
mongrel-0.2.1 test/test_http11.rb
mongrel-0.3.10.1 test/test_http11.rb
mongrel-0.2.0 test/test_http11.rb
mongrel-0.3.1 test/test_http11.rb
mongrel-0.3.10 test/test_http11.rb
mongrel-0.3.11 test/test_http11.rb
mongrel-0.3.8 test/test_http11.rb
mongrel-0.3.7.1 test/test_http11.rb
mongrel-0.3.6 test/test_http11.rb
mongrel-0.3.7 test/test_http11.rb
mongrel-0.3.3 test/test_http11.rb
mongrel-0.3.4 test/test_http11.rb
mongrel-0.3.5 test/test_http11.rb
mongrel-0.3.2 test/test_http11.rb
mongrel-0.3 test/test_http11.rb
mongrel-0.3.9 test/test_http11.rb