httpclient 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -160,8 +160,10 @@ class WebAgent
160
160
 
161
161
  def parse(str, url)
162
162
  @url = url
163
+ # TODO: should not depend on join_quotedstr. scan with escape like CSV.
163
164
  cookie_elem = str.split(/;/)
164
165
  cookie_elem = join_quotedstr(cookie_elem, ';')
166
+ cookie_elem -= [""] # del empty elements, a cookie might included ";;"
165
167
  first_elem = cookie_elem.shift
166
168
  if first_elem !~ /([^=]*)(\=(.*))?/
167
169
  return
@@ -170,7 +172,7 @@ class WebAgent
170
172
  @name = $1.strip
171
173
  @value = normalize_cookie_value($3)
172
174
  cookie_elem.each{|pair|
173
- key, value = pair.split(/=/) ## value may nil
175
+ key, value = pair.split(/=/, 2) ## value may nil
174
176
  key.strip!
175
177
  value = normalize_cookie_value(value)
176
178
  case key.downcase
@@ -320,7 +320,7 @@ module HTTP
320
320
  end
321
321
  if @chunked
322
322
  set('Transfer-Encoding', 'chunked')
323
- elsif keep_alive or @body_size != 0
323
+ elsif @body_size and (keep_alive or @body_size != 0)
324
324
  set('Content-Length', @body_size.to_s)
325
325
  end
326
326
  if @http_version >= 1.1
@@ -623,7 +623,7 @@ module HTTP
623
623
  def new_connect_request(uri)
624
624
  m = new
625
625
  m.header.init_connect_request(uri)
626
- m.header.body_size = 0
626
+ m.header.body_size = nil
627
627
  m
628
628
  end
629
629
 
@@ -645,8 +645,12 @@ module HTTP
645
645
  m.header.init_request(method, uri, query)
646
646
  m.body = Body.new
647
647
  m.body.init_request(body || '', boundary)
648
- m.header.body_size = m.body.size
649
- m.header.chunked = true if m.body.size.nil?
648
+ if body
649
+ m.header.body_size = m.body.size
650
+ m.header.chunked = true if m.body.size.nil?
651
+ else
652
+ m.header.body_size = nil
653
+ end
650
654
  m
651
655
  end
652
656
 
@@ -445,7 +445,7 @@ class HTTPClient
445
445
  include SocketWrap
446
446
 
447
447
  def initialize(host, port, response)
448
- super(StringIO.new(response))
448
+ super(response.is_a?(StringIO) ? response : StringIO.new(response))
449
449
  @host = host
450
450
  @port = port
451
451
  end
@@ -800,9 +800,13 @@ class HTTPClient
800
800
  maxbytes = @read_block_size
801
801
  maxbytes = @content_length if maxbytes > @content_length
802
802
  timeout(@receive_timeout, ReceiveTimeoutError) do
803
- @socket.readpartial(maxbytes, buf) rescue EOFError
803
+ begin
804
+ @socket.readpartial(maxbytes, buf)
805
+ rescue EOFError
806
+ buf = nil
807
+ end
804
808
  end
805
- if buf.length > 0
809
+ if buf && buf.length > 0
806
810
  @content_length -= buf.length
807
811
  yield buf
808
812
  else
@@ -840,7 +844,11 @@ class HTTPClient
840
844
  buf = ''
841
845
  while true
842
846
  timeout(@receive_timeout, ReceiveTimeoutError) do
843
- @socket.readpartial(@read_block_size, buf) rescue EOFError
847
+ begin
848
+ @socket.readpartial(@read_block_size, buf)
849
+ rescue EOFError
850
+ buf = nil
851
+ end
844
852
  end
845
853
  if buf && buf.length > 0
846
854
  yield buf
@@ -343,23 +343,28 @@ class HTTPClient
343
343
  if File.exist?(file)
344
344
  dist_cert =<<__DIST_CERT__
345
345
  -----BEGIN CERTIFICATE-----
346
- MIIC/jCCAmegAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJKUDER
347
- MA8GA1UECgwIY3Rvci5vcmcxFDASBgNVBAsMC0RldmVsb3BtZW50MRUwEwYDVQQD
348
- DAxodHRwLWFjY2VzczIwHhcNMDcwOTExMTM1ODMxWhcNMDkwOTEwMTM1ODMxWjBN
349
- MQswCQYDVQQGEwJKUDERMA8GA1UECgwIY3Rvci5vcmcxFDASBgNVBAsMC0RldmVs
350
- b3BtZW50MRUwEwYDVQQDDAxodHRwLWFjY2VzczIwgZ8wDQYJKoZIhvcNAQEBBQAD
351
- gY0AMIGJAoGBALi66ujWtUCQm5HpMSyr/AAIFYVXC/dmn7C8TR/HMiUuW3waY4uX
352
- LFqCDAGOX4gf177pX+b99t3mpaiAjJuqc858D9xEECzhDWgXdLbhRqWhUOble4RY
353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
365
370
  p7 = PKCS7.read_smime(File.open(file) { |f| f.read })
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.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - NAKAMURA, Hiroshi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-13 00:00:00 +09:00
12
+ date: 2009-05-25 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -35,9 +35,11 @@ files:
35
35
  - lib/httpclient/ssl_config.rb
36
36
  - lib/httpclient/timeout.rb
37
37
  - lib/httpclient/cookie.rb
38
+ - lib/httpclient/auth.rb.orig
38
39
  - lib/httpclient/cacert.p7s
39
40
  - lib/httpclient.rb
40
41
  - lib/http-access2.rb
42
+ - lib/httpclient.rb.orig
41
43
  has_rdoc: true
42
44
  homepage: http://dev.ctor.org/httpclient
43
45
  post_install_message: