Sha256: 0a011533ff90440a30df49f69bde5cfa0cd40ffe59a2340c9f7b60f7dfe79ac1

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'digest/sha1'

describe Request, 'legacy Mongrel tests' do
  it 'should raise error on large header names' do
    proc { R("GET /#{rand_data(10,120)} HTTP/1.1\r\nX-#{rand_data(1024, 1024+(1024))}: Test\r\n\r\n") }.
      should raise_error(InvalidRequest)
  end

  it 'should raise error on large mangled field values' do
    proc { R("GET /#{rand_data(10,120)} HTTP/1.1\r\nX-Test: #{rand_data(1024, 100*1024+(1024), false)}\r\n\r\n") }.
      should raise_error(InvalidRequest)
  end
  
  it 'should raise error on big fat ugly headers' do
    get = "GET /#{rand_data(10,120)} HTTP/1.1\r\n"
    get << "X-Test: test\r\n" * (80 * 1024)
    proc { R(get) }.should raise_error(InvalidRequest)
  end

  it 'should raise error on random garbage' do
    proc { R("GET #{rand_data(1024, 1024+(1024), false)} #{rand_data(1024, 1024+(1024), false)}\r\n\r\n") }.
      should raise_error(InvalidRequest)
  end
  
  private
    def rand_data(min, max, readable=true)
      count = min + ((rand(max)+1) *10).to_i
      res = count.to_s + "/"

      if readable
        res << Digest::SHA1.hexdigest(rand(count * 100).to_s) * (count / 40)
      else
        res << Digest::SHA1.digest(rand(count * 100).to_s) * (count / 20)
      end

      return res
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
thin-0.6.4 spec/request/mongrel_spec.rb
thin-0.6.4-x86-mswin32-60 spec/request/mongrel_spec.rb
thin-0.7.0-x86-mswin32-60 spec/request/mongrel_spec.rb
thin-0.6.3-x86-mswin32-60 spec/request/mongrel_spec.rb
thin-0.6.3 spec/request/mongrel_spec.rb
thin-0.7.0 spec/request/mongrel_spec.rb