spec/client_spec.rb in em-http-request-1.1.5 vs spec/client_spec.rb in em-http-request-1.1.6

- old
+ new

@@ -254,10 +254,23 @@ EventMachine.stop } } end + xit "should support expect-continue header" do + EventMachine.run { + http = EventMachine::HttpRequest.new('http://127.0.0.1:8090').post :body => "data", :head => { 'expect' => '100-continue' } + + http.errback { failed(http) } + http.callback { + http.response_header.status.should == 200 + http.response.should == "data" + EventMachine.stop + } + } + end + it "should perform successful GET with custom header" do EventMachine.run { http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/').get :head => {'if-none-match' => 'evar!'} http.errback { p http; failed(http) } @@ -787,10 +800,32 @@ EventMachine.stop } } end + it "streams POST request from disk via Pathname" do + EventMachine.run { + http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/').post :body => Pathname.new('spec/fixtures/google.ca') + http.errback { failed(http) } + http.callback { + http.response.should match('google') + EventMachine.stop + } + } + end + + it "streams POST request from IO object" do + EventMachine.run { + http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/').post :body => StringIO.new(File.read('spec/fixtures/google.ca')) + http.errback { failed(http) } + http.callback { + http.response.should match('google') + EventMachine.stop + } + } + end + it "should reconnect if connection was closed between requests" do EventMachine.run { conn = EM::HttpRequest.new('http://127.0.0.1:8090/') req = conn.get @@ -935,9 +970,29 @@ http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/echo-user-agent').get(:head => { 'user-agent'=>nil }) http.errback { failed(http) } http.callback { http.response.should == 'nil' + EventMachine.stop + } + } + end + end + + context "IPv6" do + it "should perform successful GET" do + EventMachine.run { + @s = StubServer.new({ + response: "HTTP/1.1 200 OK\r\n\r\nHello IPv6", + port: 8091, + host: '::1', + }) + http = EventMachine::HttpRequest.new('http://[::1]:8091/').get + + http.errback { failed(http) } + http.callback { + http.response_header.status.should == 200 + http.response.should match(/Hello IPv6/) EventMachine.stop } } end end