astro-em-http-request 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,8 @@ module EventMachine
38
38
 
39
39
  # Length of content as an integer, or nil if chunked/unspecified
40
40
  def content_length
41
- Integer(self[HttpClient::CONTENT_LENGTH]) rescue nil
41
+ @content_length ||= ((s = self[HttpClient::CONTENT_LENGTH]) &&
42
+ (s =~ /^(\d+)$/)) ? $1.to_i : nil
42
43
  end
43
44
 
44
45
  # Cookie header from the server
@@ -380,17 +381,11 @@ module EventMachine
380
381
  if @response_header.chunked_encoding?
381
382
  @state = :chunk_header
382
383
  elsif @response_header.content_length
383
- if @response_header.content_length > 0
384
- @state = :body
385
- @bytes_remaining = @response_header.content_length
386
- else
387
- @state = :body
388
- @bytes_remaining = nil
389
- end
384
+ @state = :body
385
+ @bytes_remaining = @response_header.content_length
390
386
  else
391
- @state = :invalid
392
- on_error "no HTTP response"
393
- return false
387
+ @state = :body
388
+ @bytes_remaining = nil
394
389
  end
395
390
 
396
391
  if decoder_class = HttpDecoders.decoder_for_encoding(response_header[CONTENT_ENCODING])
@@ -72,10 +72,10 @@ module EventMachine
72
72
  c.options = options
73
73
  if options.has_key?(:timeout) && options[:timeout]
74
74
  c.comm_inactivity_timeout = options[:timeout]
75
- c.pending_connect_timeout = options[:timeout]
75
+ c.pending_connect_timeout = options[:timeout] if c.respond_to?(:pending_connect_timeout)
76
76
  elsif options.has_key?(:timeout)
77
77
  c.comm_inactivity_timeout = 5
78
- c.pending_connect_timeout = 5
78
+ c.pending_connect_timeout = 5 if c.respond_to?(:pending_connect_timeout)
79
79
  end
80
80
  }
81
81
  rescue RuntimeError => e
data/test/test_request.rb CHANGED
@@ -365,6 +365,7 @@ describe EventMachine::HttpRequest do
365
365
  http.errback { failed }
366
366
  http.callback {
367
367
  http.response.should match(/Foo/)
368
+ http.response_header['CONTENT_LENGTH'].should_not == 0
368
369
 
369
370
  @s.stop
370
371
  EventMachine.stop
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: astro-em-http-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-20 00:00:00 +02:00
13
+ date: 2009-10-21 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 0.12.9
24
+ version: 0.12.2
25
25
  version:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: addressable