spec/client_spec.rb in em-http-request-1.0.0.beta.3 vs spec/client_spec.rb in em-http-request-1.0.0.beta.4

- old
+ new

@@ -226,10 +226,29 @@ EventMachine.stop } } end + it "should return peer's IP address" do + EventMachine.run { + + conn = EventMachine::HttpRequest.new('http://127.0.0.1:8090/') + conn.peer.should be_nil + + http = conn.get + http.peer.should be_nil + + http.errback { failed(http) } + http.callback { + conn.peer.should == '127.0.0.1' + http.peer.should == '127.0.0.1' + + EventMachine.stop + } + } + end + it "should remove all newlines from long basic auth header" do EventMachine.run { auth = {'authorization' => ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']} http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/auth').get :head => auth http.errback { failed(http) } @@ -300,9 +319,29 @@ http.response_header["CONTENT_ENCODING"].should == "gzip" http.response.should == "compressed" EventMachine.stop } + } + end + + it "should not decode the response when configured so" do + EventMachine.run { + + http = EventMachine::HttpRequest.new('http://127.0.0.1:8090/gzip').get :head => { + "accept-encoding" => "gzip, compressed" + }, :decoding => false + + http.errback { failed(http) } + http.callback { + http.response_header.status.should == 200 + http.response_header["CONTENT_ENCODING"].should == "gzip" + + raw = http.response + Zlib::GzipReader.new(StringIO.new(raw)).read.should == "compressed" + + EventMachine.stop + } } end it "should timeout after 0.1 seconds of inactivity" do EventMachine.run {