httpclient 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/httpclient.rb CHANGED
@@ -231,8 +231,7 @@ require 'httpclient/cookie'
231
231
  #
232
232
  class HTTPClient
233
233
  RUBY_VERSION_STRING = "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
234
- /: (\S+) (\S+)/ =~ %q$Id$
235
- LIB_NAME = "(#{$1}/#{$2}, #{RUBY_VERSION_STRING})"
234
+ LIB_NAME = "(#{VERSION}, #{RUBY_VERSION_STRING})"
236
235
 
237
236
  include Util
238
237
 
@@ -337,6 +336,8 @@ class HTTPClient
337
336
  attr_proxy(:receive_timeout, true)
338
337
  # Reuse the same connection within this timeout in sec. from last used.
339
338
  attr_proxy(:keep_alive_timeout, true)
339
+ # Size of reading block for non-chunked response.
340
+ attr_proxy(:read_block_size, true)
340
341
  # Negotiation retry count for authentication. 5 by default.
341
342
  attr_proxy(:protocol_retry_count, true)
342
343
  # if your ruby is older than 2005-09-06, do not set socket_sync = false to
@@ -918,8 +918,8 @@ class HTTPClient
918
918
 
919
919
  def read_body_length(&block)
920
920
  return nil if @content_length == 0
921
- buf = ''
922
921
  while true
922
+ buf = ''
923
923
  maxbytes = @read_block_size
924
924
  maxbytes = @content_length if maxbytes > @content_length
925
925
  timeout(@receive_timeout, ReceiveTimeoutError) do
@@ -969,8 +969,8 @@ class HTTPClient
969
969
  yield @readbuf
970
970
  @readbuf = nil
971
971
  end
972
- buf = ''
973
972
  while true
973
+ buf = ''
974
974
  timeout(@receive_timeout, ReceiveTimeoutError) do
975
975
  begin
976
976
  @socket.readpartial(@read_block_size, buf)
@@ -1,3 +1,3 @@
1
1
  class HTTPClient
2
- VERSION = '2.2.3'
2
+ VERSION = '2.2.4'
3
3
  end
@@ -33,7 +33,7 @@ class TestHTTPClient < Test::Unit::TestCase
33
33
  @client.get(serverurl)
34
34
  lines = str.split(/(?:\r?\n)+/)
35
35
  assert_equal("= Request", lines[0])
36
- assert_match(/^User-Agent: agent_name_foo/, lines[4])
36
+ assert_match(/^User-Agent: agent_name_foo \(#{HTTPClient::VERSION}/, lines[4])
37
37
  end
38
38
 
39
39
  def test_from
@@ -591,6 +591,16 @@ EOS
591
591
  assert_nil(res.content)
592
592
  end
593
593
 
594
+ def test_get_with_block_chunk_string_recycle
595
+ @client.read_block_size = 2
596
+ body = []
597
+ res = @client.get(serverurl + 'servlet') { |str|
598
+ body << str
599
+ }
600
+ assert_equal(2, body.size)
601
+ assert_equal("get", body.join) # Was "tt" by String object recycle...
602
+ end
603
+
594
604
  def test_post
595
605
  assert_equal("post", @client.post(serverurl + 'servlet').content[0, 4])
596
606
  res = @client.post(serverurl + 'servlet', {1=>2, 3=>4})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-28 00:00:00.000000000 Z
12
+ date: 2011-12-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: nahi@ruby-lang.org