Sha256: 3af355adec378c5e157d840b52a6bacc3fb1373305c704ea5e139df682619003

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

require "test_helper"

require "puma/puma_http11"

class Http10ParserTest < Minitest::Test
  def test_parse_simple
    parser = Puma::HttpParser.new
    req = {}
    http = "GET / HTTP/1.0\r\n\r\n"
    nread = parser.execute(req, http, 0)

    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"

    assert_equal '/', req['REQUEST_PATH']
    assert_equal 'HTTP/1.0', req['HTTP_VERSION']
    assert_equal '/', req['REQUEST_URI']
    assert_equal 'GET', req['REQUEST_METHOD']
    assert_nil req['FRAGMENT']
    assert_nil req['QUERY_STRING']

    parser.reset
    assert parser.nread == 0, "Number read after reset should be 0"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puma-simon-3.7.2 test/test_http10.rb
puma-simon-3.7.1 test/test_http10.rb