Sha256: a1fcbcb0ffe2c955b891d20431ef0d8636ddc2c66f114957fb722d170647a47b

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

require 'helper'

requires_connection do

  describe EventMachine::HttpRequest do

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

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

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

        processed = 0
        stop = proc { EM.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
      EventMachine.run do
        conn = EventMachine::HttpRequest.new('http://www.bing.com/')

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

        processed = 0
        stop = proc { EM.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

6 entries across 6 versions & 2 rubygems

Version Path
em-http-request-samesite-0.1.1 spec/pipelining_spec.rb
em-http-request-samesite-1.1.7 spec/pipelining_spec.rb
em-http-request-1.1.7 spec/pipelining_spec.rb
em-http-request-1.1.6 spec/pipelining_spec.rb
em-http-request-1.1.5 spec/pipelining_spec.rb
em-http-request-1.1.4 spec/pipelining_spec.rb