Sha256: 55f59a83ccab9f4e5a1099fc3c1a196e59ff800712774f02abc180440b37ba16

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

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

describe Server, 'on TCP socket' do
  before do
    start_server do |env|
      body = env.inspect + env['rack.input'].read
      [200, { 'Content-Type' => 'text/html', 'Content-Length' => body.size.to_s }, body]
    end
  end
    
  it 'should GET from Net::HTTP' do
    get('/?cthis').should include('cthis')
  end
  
  it 'should GET from TCPSocket' do
    send_data("GET /?this HTTP/1.1\r\n\r\n").
      should include("HTTP/1.1 200 OK",
                     "Content-Type: text/html", "Content-Length: ",
                     "Connection: close", "this")
  end
  
  it 'should return empty string on incomplete headers' do
    send_data("GET /?this HTTP/1.1\r\nHost:").should be_empty
  end
  
  it 'should return empty string on incorrect Content-Length' do
    send_data("POST / HTTP/1.1\r\nContent-Length: 300\r\n\r\naye").should be_empty
  end
  
  it 'should POST from Net::HTTP' do
    post('/', :arg => 'pirate').should include('arg=pirate')
  end
  
  it 'should handle big POST' do
    big = 'X' * (20 * 1024)
    post('/', :big => big).should include(big)
  end
  
  it "should handle GET in less then #{get_request_time = 0.004} RubySecond" do
    proc { get('/') }.should be_faster_then(get_request_time)
  end
  
  it "should handle POST in less then #{post_request_time = 0.007} RubySecond" do
    proc { post('/', :file => 'X' * 1000) }.should be_faster_then(post_request_time)
  end
  
  it "should retreive remote address" do
    get('/').should include('"REMOTE_ADDR"=>"127.0.0.1"')
  end
  
  after do
    stop_server
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thin-0.6.3-x86-mswin32-60 spec/server/tcp_spec.rb
thin-0.6.4-x86-mswin32-60 spec/server/tcp_spec.rb
thin-0.6.3 spec/server/tcp_spec.rb
thin-0.6.4 spec/server/tcp_spec.rb