Sha256: dff53f72f86c5bd7f0488f925fb4df28733d6fdfdd68a4b139ab9f57a1b9507a

Contents?: true

Size: 904 Bytes

Versions: 9

Compression:

Stored size: 904 Bytes

Contents

require 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

9 entries across 9 versions & 1 rubygems

Version Path
mechanize-0.7.5 test/tc_keep_alive.rb
mechanize-0.7.8 test/test_keep_alive.rb
mechanize-0.7.0 test/tc_keep_alive.rb
mechanize-0.7.1 test/tc_keep_alive.rb
mechanize-0.7.2 test/tc_keep_alive.rb
mechanize-0.7.3 test/tc_keep_alive.rb
mechanize-0.7.4 test/tc_keep_alive.rb
mechanize-0.7.6 test/tc_keep_alive.rb
mechanize-0.7.7 test/test_keep_alive.rb