Sha256: 5985afb60bf53676b247a6ea95f294a0182accc6b3d3672a040ce1b5ef2e862d

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'helper'

requires_connection do

  describe ZMachine::HttpRequest do

    it "should perform successful pipelined GETs" do
      ZMachine.run do

        # Mongrel doesn't support pipelined requests - bah!
        conn = ZMachine::HttpRequest.new('http://www.igvita.com/')

        pipe1 = conn.get :keepalive => true
        pipe2 = conn.get :path => '/archives/', :keepalive => true

        processed = 0
        stop = proc { ZMachine.stop if processed == 2}

        pipe1.errback { failed(conn) }
        pipe1.callback {
          processed += 1
          pipe1.response_header.status.should == 200
          stop.call
        }

        pipe2.errback { failed(conn) }
        pipe2.callback {
          processed += 1
          pipe2.response_header.status.should == 200
          pipe2.response.should match(/html/i)
          stop.call
        }

      end
    end

    it "should perform successful pipelined HEAD requests" do
      ZMachine.run do
        conn = ZMachine::HttpRequest.new('http://www.igvita.com/')

        pipe1 = conn.head :keepalive => true
        pipe2 = conn.head :path => '/archives/', :keepalive => true

        processed = 0
        stop = proc { ZMachine.stop if processed == 2}

        pipe1.errback { failed(conn) }
        pipe1.callback {
          processed += 1
          pipe1.response_header.status.should == 200
          stop.call
        }

        pipe2.errback { failed(conn) }
        pipe2.callback {
          processed += 1
          pipe2.response_header.status.should == 200
          stop.call
        }

      end

    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
z-http-request-0.2.0 spec/pipelining_spec.rb
z-http-request-0.1.0 spec/pipelining_spec.rb