Changeset 300
- Timestamp:
- 01/03/07 19:04:22 (2 years ago)
- Files:
-
- version_0/lib/protocols/httpclient.rb (modified) (1 diff)
- version_0/Rakefile (modified) (1 diff)
- version_0/tests/test_httpclient.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
version_0/lib/protocols/httpclient.rb
r299 r300 150 150 data = ary.last 151 151 if ary.first == "" 152 @read_state = :content 152 if @content_length and @content_length > 0 153 @read_state = :content 154 else 155 dispatch_response 156 @read_state = :base 157 end 153 158 else 154 159 @headers << ary.first version_0/Rakefile
r298 r300 197 197 task :test_protocols => [ :test_hc, :test_ltp ] 198 198 199 desc "Test HTTP client" 200 task :test_httpclient do |t| 201 run_tests t, :extension, "test_httpclient.rb" 202 end 203 199 204 200 205 desc "Build everything" version_0/tests/test_httpclient.rb
r233 r300 90 90 91 91 92 #----------------------------------------- 93 94 # Test a server that returns a page with a zero content-length. 95 # This caused an early version of the HTTP client not to generate a response, 96 # causing this test to hang. Observe, there was no problem with responses 97 # lacking a content-length, just when the content-length was zero. 98 # 99 class EmptyContent < EventMachine::Connection 100 def initialize *args 101 super 102 end 103 def receive_data data 104 send_data "HTTP/1.0 404 ...\r\nContent-length: 0\r\n\r\n" 105 close_connection_after_writing 106 end 107 end 108 109 def test_http_empty_content 110 ok = false 111 EventMachine.run { 112 EventMachine.start_server "127.0.0.1", 9701, EmptyContent 113 c = EventMachine::Protocols::HttpClient.send :request, :host => "127.0.0.1", :port => 9701 114 c.callback {|result| 115 ok = true 116 EventMachine.stop 117 } 118 } 119 assert ok 120 end 121 92 122 end 93 123
