Sha256: 6ec09e53c2ef5b913f7d40ef255bf76e98b3bc762aad94031af8ee18604565fa

Contents?: true

Size: 931 Bytes

Versions: 15

Compression:

Stored size: 931 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "helper"))

class TestKeepAlive < Test::Unit::TestCase
  def setup
    @agent = WWW::Mechanize.new
  end

  def test_keep_alive
    page = @agent.get('http://localhost/http_headers')
    headers = {}
    page.body.split(/[\r\n]+/).each do |header|
      headers.[]=(*header.chomp.split(/\|/))
    end
    assert(headers.has_key?('connection'))
    assert_equal('keep-alive', headers['connection'])
    assert(headers.has_key?('keep-alive'))
    assert_equal('300', headers['keep-alive'])
  end

  def test_close_connection
    @agent.keep_alive = false
    page = @agent.get('http://localhost/http_headers')
    headers = {}
    page.body.split(/[\r\n]+/).each do |header|
      headers.[]=(*header.chomp.split(/\|/))
    end
    assert(headers.has_key?('connection'))
    assert_equal('close', headers['connection'])
    assert(!headers.has_key?('keep-alive'))
  end
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
eric-mechanize-0.9.3.20090623142847 test/test_keep_alive.rb
knu-mechanize-0.9.3.20090623142847 test/test_keep_alive.rb
tenderlove-mechanize-0.9.3.20090617085936 test/test_keep_alive.rb
tenderlove-mechanize-0.9.3.20090623142847 test/test_keep_alive.rb
mechanize-ntlm-0.9.1 test/test_keep_alive.rb
mechanize-0.8.0 test/test_keep_alive.rb
mechanize-0.8.3 test/test_keep_alive.rb
mechanize-0.8.4 test/test_keep_alive.rb
mechanize-0.8.2 test/test_keep_alive.rb
mechanize-0.8.1 test/test_keep_alive.rb
mechanize-0.9.1 test/test_keep_alive.rb
mechanize-0.9.2 test/test_keep_alive.rb
mechanize-0.9.3 test/test_keep_alive.rb
mechanize-0.8.5 test/test_keep_alive.rb
mechanize-0.9.0 test/test_keep_alive.rb