glebtv-httpclient 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f60ae5d8ff1599208d3444724647db9d54b8b05
4
- data.tar.gz: d3cc6ddcd4da48b914b330f12f73e705928c9d6e
3
+ metadata.gz: 1b3a52b69fd448d0c599833a4a537da54d5e2fe0
4
+ data.tar.gz: c4dabdf30e8d87b39956940f1b59884635c35912
5
5
  SHA512:
6
- metadata.gz: c4fb73b7d1bc0600169d1005c9cf25981db8221418fc8085c99ec34f29d371f2442002fa29d13abaff5ac170726d3a14ed4d2f88ec9310839bd9bcfe33335923
7
- data.tar.gz: f7c0801250447ed0672efc01685698dcc5632ac024524ca4013684f083d1b780410cf190741e27f24654317214f3005a324eb09cce00c399a647f2fbf0b6c2ac
6
+ metadata.gz: f2fb7a147cf97fbd8b294378c2087b6a4756c87a86822b98d83e5dcda96698792aa9709a0c5c4636d62ce4db020ee9ff6b7f681f628ca5e094b199e094aae839
7
+ data.tar.gz: a26ef8ba9516957134d043da93f2411a0f237e8846998784289e7dc6d8f827eb77f94f46ef700ef7aa18dd66cbc1c5639c7be359a782687221af6c4b7165e71d
@@ -982,22 +982,22 @@ class HTTPClient
982
982
  buf = HTTPClient::Util.get_buf
983
983
  while true
984
984
  len = @socket.gets(RS)
985
- if len.nil? # EOF
985
+ if len.nil? # EOF
986
986
  close
987
987
  return
988
988
  end
989
989
  @chunk_length = len.hex
990
- if @chunk_length == 0
990
+ if @chunk_length == 0
991
991
  @content_length = 0
992
992
  @socket.gets(RS)
993
993
  return
994
994
  end
995
- timeout(@receive_timeout, ReceiveTimeoutError) do
995
+ timeout(@receive_timeout, ReceiveTimeoutError) do
996
996
  @socket.read(@chunk_length, buf)
997
997
  @socket.read(2) # CRLF
998
998
  end
999
- unless buf.empty?
1000
- yield buf.slice(0, @chunk_length)
999
+ unless buf.empty?
1000
+ yield buf
1001
1001
  end
1002
1002
  end
1003
1003
  end
@@ -1,3 +1,3 @@
1
1
  class HTTPClient
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2' unless defined?(VERSION)
3
3
  end
data/lib/httpclient.rb CHANGED
@@ -74,7 +74,7 @@ require 'httpclient/cookie'
74
74
  #
75
75
  # === Invoking other HTTP methods
76
76
  #
77
- # See head, get, post, put, delete, options, propfind, proppatch and trace.
77
+ # See head, get, post, put, delete, options, propfind, proppatch and trace.
78
78
  # It returns a HTTP::Message instance as a response.
79
79
  #
80
80
  # 1. Do HEAD request.
@@ -703,12 +703,12 @@ class HTTPClient
703
703
  def propfind(uri, *args, &block)
704
704
  request(:propfind, uri, argument_to_hash(args, :header), &block)
705
705
  end
706
-
706
+
707
707
  # Sends PROPPATCH request to the specified URL. See request for arguments.
708
708
  def proppatch(uri, *args, &block)
709
709
  request(:proppatch, uri, argument_to_hash(args, :body, :header), &block)
710
710
  end
711
-
711
+
712
712
  # Sends TRACE request to the specified URL. See request for arguments.
713
713
  def trace(uri, *args, &block)
714
714
  request('TRACE', uri, argument_to_hash(args, :query, :header), &block)
@@ -823,14 +823,14 @@ class HTTPClient
823
823
  header = keyword_argument(args, :header)
824
824
  request_async(:propfind, uri, nil, nil, header || PROPFIND_DEFAULT_EXTHEADER)
825
825
  end
826
-
826
+
827
827
  # Sends PROPPATCH request in async style. See request_async for arguments.
828
828
  # It immediately returns a HTTPClient::Connection instance as a result.
829
829
  def proppatch_async(uri, *args)
830
830
  body, header = keyword_argument(args, :body, :header)
831
831
  request_async(:proppatch, uri, nil, body, header || {})
832
832
  end
833
-
833
+
834
834
  # Sends TRACE request in async style. See request_async for arguments.
835
835
  # It immediately returns a HTTPClient::Connection instance as a result.
836
836
  def trace_async(uri, *args)
@@ -958,8 +958,13 @@ private
958
958
  body.pos = pos if pos
959
959
  res = do_request(method, uri, query, body, header, &filtered_block)
960
960
  if res.redirect?
961
- method = :get if res.see_other? # See RFC2616 10.3.4
962
- method = :get if res.found? # All browsers convert POST to GET on 302 redirects for historical reasons
961
+ # See RFC2616 10.3.4
962
+ # All browsers convert POST to GET on 302 redirects for historical reasons
963
+ if res.see_other? || res.found?
964
+ method = :get
965
+ body = ''
966
+ pos = nil
967
+ end
963
968
  uri = urify(@redirect_uri_callback.call(uri, res))
964
969
  retry_number += 1
965
970
  else
@@ -973,7 +978,7 @@ private
973
978
  if res.ok?
974
979
  return res.content
975
980
  else
976
- raise BadResponseError.new("unexpected response: #{res.header.inspect}", res)
981
+ raise BadResponseError.new("unexpected response:\n#{res.header.dump}\n#{res.content}", res)
977
982
  end
978
983
  end
979
984
 
data/test/test_cookie.rb CHANGED
@@ -137,7 +137,7 @@ class TestCookieManager < Test::Unit::TestCase
137
137
 
138
138
  def teardown()
139
139
  end
140
-
140
+
141
141
  def test_parse()
142
142
  str = "inkid=n92b0ADOgACIgUb9lsjHqAAAHu2a; expires=Wed, 01-Dec-2010 00:00:00 GMT; path=/"
143
143
  @cm.parse(str, urify('http://www.test.jp'))
@@ -174,7 +174,7 @@ class TestCookieManager < Test::Unit::TestCase
174
174
  assert_equal(true, cookie.secure?)
175
175
  assert_equal(true, cookie.http_only?)
176
176
  end
177
-
177
+
178
178
  def test_parse_double_semicolon()
179
179
  str = "xmen=off,0,0,1;; path=\"/;;\"; domain=.excite.co.jp; expires=Wednesday, 31-Dec-2037 12:00:00 GMT"
180
180
  @cm.parse(str, urify('http://www.excite.co.jp'))
@@ -275,10 +275,10 @@ class TestCookieManager < Test::Unit::TestCase
275
275
  begin
276
276
  File.open("tmp_test.tmp","w") {|f|
277
277
  f.write <<EOF
278
- http://www.zdnet.co.jp/news/0106/08/e_gibson.html NGUserID d29b8f49-10875-992421294-1 2145801600 www.zdnet.co.jp / 9 0
279
- http://www.zdnet.co.jp/news/0106/08/e_gibson.html PACK zd3-992421294-7436 1293839999 .zdnet.co.jp / 13 0
280
- http://example.org/ key value 0 .example.org / 13 0
281
- http://example.org/ key value .example.org / 13 0
278
+ http://www.zdnet.co.jp/news/0106/08/e_gibson.html NGUserID d29b8f49-10875-992421294-1 2145801600 www.zdnet.co.jp / 9 0
279
+ http://www.zdnet.co.jp/news/0106/08/e_gibson.html PACK zd3-992421294-7436 1293839999 .zdnet.co.jp / 13 0
280
+ http://example.org/ key value 0 .example.org / 13 0
281
+ http://example.org/ key value .example.org / 13 0
282
282
  EOF
283
283
  }
284
284
 
@@ -604,9 +604,13 @@ EOS
604
604
  def test_post_content_io
605
605
  post_body = StringIO.new("1234567890")
606
606
  assert_equal('post,1234567890', @client.post_content(serverurl + 'servlet', post_body))
607
- post_body = StringIO.new("1234567890")
607
+
608
608
  # all browsers use GET for 302
609
- assert_equal('get', @client.post_content(serverurl + 'servlet_redirect', post_body))
609
+ post_body = StringIO.new("1234567890")
610
+ assert_equal('', @client.get_content(serverurl + 'servlet_redirect_413'))
611
+ assert_equal('', @client.post_content(serverurl + 'servlet_redirect_413', post_body))
612
+
613
+
610
614
  post_body = StringIO.new("1234567890")
611
615
  assert_equal('post,1234567890', @client.post_content(serverurl + 'servlet_temporary_redirect', post_body))
612
616
  post_body = StringIO.new("1234567890")
@@ -1614,7 +1618,8 @@ private
1614
1618
  :hello, :sleep, :servlet_redirect, :servlet_temporary_redirect, :servlet_see_other,
1615
1619
  :redirect1, :redirect2, :redirect3,
1616
1620
  :redirect_self, :relative_redirect, :redirect_see_other, :chunked,
1617
- :largebody, :status, :compressed, :charset, :continue
1621
+ :largebody, :status, :compressed, :charset, :continue,
1622
+ :servlet_redirect_413, :servlet_413
1618
1623
  ].each do |sym|
1619
1624
  @server.mount(
1620
1625
  "/#{sym}",
@@ -1648,9 +1653,19 @@ private
1648
1653
  def do_servlet_redirect(req, res)
1649
1654
  res.set_redirect(WEBrick::HTTPStatus::Found, serverurl + "servlet")
1650
1655
  end
1656
+
1657
+ def do_servlet_redirect_413(req, res)
1658
+ res.set_redirect(WEBrick::HTTPStatus::Found, serverurl + "servlet_413")
1659
+ end
1660
+
1661
+ def do_servlet_413(req, res)
1662
+ res.body = req.body.to_s
1663
+ end
1664
+
1651
1665
  def do_servlet_temporary_redirect(req, res)
1652
1666
  res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, serverurl + "servlet")
1653
1667
  end
1668
+
1654
1669
  def do_servlet_see_other(req, res)
1655
1670
  res.set_redirect(WEBrick::HTTPStatus::SeeOther, serverurl + "servlet")
1656
1671
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-16 00:00:00.000000000 Z
11
+ date: 2013-06-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: glebtv@gmail.com
@@ -18,61 +18,61 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - bin/httpclient
21
- - lib/httpclient.rb
22
- - lib/hexdump.rb
23
- - lib/glebtv-httpclient.rb
21
+ - lib/http-access2/http.rb
22
+ - lib/http-access2/cookie.rb
23
+ - lib/httpclient/ssl_config.rb
24
24
  - lib/httpclient/cacert.p7s
25
- - lib/httpclient/http.rb
26
- - lib/httpclient/cookie.rb
27
- - lib/httpclient/timeout.rb
28
- - lib/httpclient/version.rb
29
- - lib/httpclient/include_client.rb
30
- - lib/httpclient/auth.rb
31
25
  - lib/httpclient/connection.rb
32
- - lib/httpclient/ssl_config.rb
33
26
  - lib/httpclient/session.rb
27
+ - lib/httpclient/http.rb
34
28
  - lib/httpclient/util.rb
29
+ - lib/httpclient/version.rb
30
+ - lib/httpclient/auth.rb
31
+ - lib/httpclient/include_client.rb
32
+ - lib/httpclient/timeout.rb
33
+ - lib/httpclient/cookie.rb
34
+ - lib/httpclient.rb
35
35
  - lib/oauthclient.rb
36
+ - lib/hexdump.rb
37
+ - lib/glebtv-httpclient.rb
36
38
  - lib/http-access2.rb
37
- - lib/http-access2/http.rb
38
- - lib/http-access2/cookie.rb
39
- - sample/cookie.rb
39
+ - sample/ssl/1000cert.pem
40
+ - sample/ssl/0cert.pem
41
+ - sample/ssl/htdocs/index.html
42
+ - sample/ssl/1000key.pem
43
+ - sample/ssl/0key.pem
44
+ - sample/ssl/ssl_client.rb
45
+ - sample/ssl/webrick_httpsd.rb
46
+ - sample/dav.rb
47
+ - sample/howto.rb
48
+ - sample/auth.rb
49
+ - sample/thread.rb
50
+ - sample/oauth_twitter.rb
40
51
  - sample/stream.rb
41
52
  - sample/async.rb
42
- - sample/auth.rb
53
+ - sample/cookie.rb
43
54
  - sample/oauth_friendfeed.rb
44
- - sample/howto.rb
45
55
  - sample/oauth_buzz.rb
46
- - sample/dav.rb
47
- - sample/oauth_twitter.rb
48
- - sample/thread.rb
49
- - sample/ssl/1000key.pem
50
- - sample/ssl/0key.pem
51
- - sample/ssl/webrick_httpsd.rb
52
- - sample/ssl/1000cert.pem
53
- - sample/ssl/0cert.pem
54
- - sample/ssl/ssl_client.rb
55
- - sample/ssl/htdocs/index.html
56
56
  - sample/wcat.rb
57
- - test/test_http-access2.rb
58
- - test/test_auth.rb
59
57
  - test/htpasswd
58
+ - test/sslsvr.rb
59
+ - test/test_cookie.rb
60
+ - test/htdigest
61
+ - test/test_ssl.rb
62
+ - test/subca.cert
63
+ - test/test_http-access2.rb
64
+ - test/test_httpclient.rb
65
+ - test/server.key
66
+ - test/test_hexdump.rb
60
67
  - test/helper.rb
68
+ - test/test_auth.rb
69
+ - test/test_include_client.rb
70
+ - test/client.cert
61
71
  - test/ca-chain.cert
62
- - test/test_hexdump.rb
63
- - test/subca.cert
64
72
  - test/server.cert
65
- - test/server.key
73
+ - test/client.key
66
74
  - test/runner.rb
67
- - test/test_include_client.rb
68
- - test/test_httpclient.rb
69
- - test/test_cookie.rb
70
- - test/sslsvr.rb
71
75
  - test/ca.cert
72
- - test/test_ssl.rb
73
- - test/htdigest
74
- - test/client.key
75
- - test/client.cert
76
76
  - README.rdoc
77
77
  homepage: http://github.com/glebtv/httpclient
78
78
  licenses: