Граф коммитов

788 Коммитов

Автор SHA1 Сообщение Дата
Kazuhiro NISHIYAMA 299db37957 Use while instead of loop 2019-12-17 21:56:09 +09:00
NARUSE, Yui 5be34d6a33 ensure to close the data connection [Bug #16413] 2019-12-17 08:24:47 +09:00
Yusuke Endoh 251f5d8226 Revert "lib/net/http/response.rb: support raw deflate correctly"
This reverts commit 5105240b1e.

In RFC 2616:

```
   deflate
        The "zlib" format defined in RFC 1950 [31] in combination with
        the "deflate" compression mechanism described in RFC 1951 [29].
```

So "Content-Encoding: deflate" means zlib format, not raw deflate.

[Bug #11268]
2019-12-16 23:39:10 +09:00
Yusuke Endoh 5105240b1e lib/net/http/response.rb: support raw deflate correctly
Net::HTTP had used `Zlib::Inflate.new(32 + Zlib::MAX_WBITS)` for all
content encoding (deflate, zlib, and gzip).
But the argument `32 + Zlib::MAX_WBITS` means zlib and gzip decoding
with automatic header detection, so (raw) deflate compression had not
been supported.

This change makes it support raw deflate correctly by passing an
argument `-Zlib::MAX_WBITS` (which means raw deflate) to
`Zlib::Inflate.new`.  All deflate-mode tests are fixed too.

[Bug #11268]
2019-12-16 23:20:42 +09:00
NARUSE, Yui af11efd377 fix ipaddr parameter of Net::HTTP.start to support proxy
54072e329c
2019-12-10 19:12:21 +09:00
Yusuke Endoh 3ca3c8d768 lib/net/http.rb: align the indentation 2019-12-10 14:15:35 +09:00
NARUSE, Yui c2dc27d643 fix typo of 54072e329c 2019-12-09 20:48:35 +09:00
NARUSE, Yui 54072e329c Add ipaddr optional parameter to Net::HTTP#start
to replace the address for TCP/IP connection [Feature #5180]

There're 3 layers of hostname:
* host address for TCP/IP
* TLS server name
* HTTP Host header value
To test DNS round robin or check server certificate from server local,
people sometimes want to connect server with given IP address but keep
TLS server name and HTTP Host header value.

closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977
2019-12-09 20:21:49 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Kazuhiro NISHIYAMA 6744593b8c
Fix a typo [ci skip] 2019-11-15 11:01:06 +09:00
Hiroshi SHIBATA 3c252651e1
Fixed test failure related Net::Protocol 2019-11-07 17:09:22 +09:00
Hiroshi SHIBATA c916f9600b
SMTP is not module 2019-11-07 16:44:38 +09:00
Hiroshi SHIBATA 223d3c460a
Promote net-smtp to default gems 2019-11-07 16:36:14 +09:00
Hiroshi SHIBATA eb0b13596d
Promote net-pop to default gems 2019-11-07 16:36:14 +09:00
zverok 6221248294 Improve Net::HTTP docs:
* Make links from Net::GenericHTTPRequest work;
* Document +dest+ param of HTTPResponse#read_body;
* Slightly improve reference to particular response
  classes from HTTPResponse class docs.
2019-10-26 10:24:20 -07:00
zverok de147bb721 Net::FTP: fix formatting problems for #status method 2019-10-26 10:24:20 -07:00
Pavel Valena b439ee1b8f Remove uselsess shebang
as the file is not executable anyway.
2019-10-09 12:41:41 +09:00
Jeremy Evans 2b6a9f3a1f Ignore Errno::EPIPE when sending requests in net/http
An EPIPE when sending the request should be ignored.  Even if you
cannot write more data, you may still be able to read the server's
response.

Fixes [Bug #14466]
2019-09-27 07:43:32 -07:00
Shugo Maeda 633ae3278e
Add Net::FTP#features and Net::FTP#option
Patch by darkphnx (Dan Wentworth) .  Thanks!
[Feature #15964]
2019-09-02 14:43:51 +09:00
Jeremy Evans d08e1004e0 Fix keyword argument separation issues in lib
Mostly requires adding ** in either calls or method definitions.
2019-08-30 12:39:31 -07:00
ohbarye b1678338e5
Fix typo: duplicated the [skip-ci] 2019-08-09 16:23:49 -07:00
Nobuyoshi Nakada c9826c20d2
Show the caller's location
* lib/net/http/header.rb: show the caller's location instead of
  the current lines.
2019-07-24 00:26:28 +09:00
Jeremy Evans 14b0c94ac3 Fix documentation for Net::SMTPServerBusy
Fixes [Bug #11628]
2019-06-27 16:57:19 -07:00
Jeremy Evans 4a5e07d8e1 Avoid verbose warning when using Net::POP3 with SSL
Patch from Jos Kamphorst.

Fixes [Bug #14822]
2019-06-20 10:22:01 -07:00
knu 246723a34c Support SNI (Reapplying r67488)
This fixes connecting using TLS 1.3 to imap.gmail.com

[Fix GH-2077] [Feature #15594]

From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-15 10:52:34 +00:00
kazu 25c1fd3b90 Reverting all commits from r67479 to r67496 because of CI failures
Because hard to specify commits related to r67479 only.
So please commit again.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 09:15:21 +00:00
shugo e553d94f01 Support SNI
This fixes connecting using TLS 1.3 to imap.gmail.com

[Fix GH-2077] [Feature #15594]

From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09 23:35:02 +00:00
glass 9065336909 * lib/net/http.rb: handle Errno::ETIMEDOUT in Net::HTTP#transport_request
A patch from casperisfine (Jean byroot Boussier).
  [Fix GH-2012]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-21 06:23:55 +00:00
glass c5e8627f65 Revert "lib/net/http.rb: use connect_timeout instead of Timeout"
This reverts commit 69a1db96fe.
getaddrinfo(3) doesn't support timeout.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 01:09:30 +00:00
glass 69a1db96fe lib/net/http.rb: use connect_timeout instead of Timeout
lib/net/pop.rb: ditto

lib/net/ftp.rb: ditto

lib/net/smtp.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 00:46:07 +00:00
nobu 1680a13a92 Fix Net::Protocol::BufferedIO#write when sending large multi-byte string
This commit should fix Net::Protocol::BufferedIO#write when sending
large multi-byte string like following example.

```
$ ruby -rnet/http -rjson -v -e "Net::HTTP.post(URI('http://httpbin.org/post'), { text: 'あ'*100_000 }.to_json, 'Content-Type' => 'application/json')"
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
Traceback (most recent call last):
        19: from -e:1:in `<main>'
        18: from lib/ruby/2.6.0/net/http.rb:500:in `post'
        17: from lib/ruby/2.6.0/net/http.rb:605:in `start'
        16: from lib/ruby/2.6.0/net/http.rb:920:in `start'
        15: from lib/ruby/2.6.0/net/http.rb:502:in `block in post'
        14: from lib/ruby/2.6.0/net/http.rb:1281:in `post'
        13: from lib/ruby/2.6.0/net/http.rb:1493:in `send_entity'
        12: from lib/ruby/2.6.0/net/http.rb:1479:in `request'
        11: from lib/ruby/2.6.0/net/http.rb:1506:in `transport_request'
        10: from lib/ruby/2.6.0/net/http.rb:1506:in `catch'
         9: from lib/ruby/2.6.0/net/http.rb:1507:in `block in transport_request'
         8: from lib/ruby/2.6.0/net/http/generic_request.rb:123:in `exec'
         7: from lib/ruby/2.6.0/net/http/generic_request.rb:189:in `send_request_with_body'
         6: from lib/ruby/2.6.0/net/protocol.rb:247:in `write'
         5: from lib/ruby/2.6.0/net/protocol.rb:265:in `writing'
         4: from lib/ruby/2.6.0/net/protocol.rb:248:in `block in write'
         3: from lib/ruby/2.6.0/net/protocol.rb:275:in `write0'
         2: from lib/ruby/2.6.0/net/protocol.rb:275:in `each_with_index'
         1: from lib/ruby/2.6.0/net/protocol.rb:275:in `each'
lib/ruby/2.6.0/net/protocol.rb:280:in `block in write0': undefined method `bytesize' for nil:NilClass (NoMethodError)
```

[Fix GH-2058]

From: Eito Katagiri <eitoball@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-27 04:49:12 +00:00
naruse 6ecafe0c98 Move autoload to toplevel
So that classes which uses Net::HTTP with https can use OpenSSL
namespace for example exception classes like OpenSSL::SSL::SSLError.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14 09:44:20 +00:00
nobu f6e800dab0 ReFix r663197
Stringify after downcase, to restrict arguments.
[Bug#15394]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-11 00:36:46 +00:00
nobu 0bdc2287bc Fix r663197
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-11 00:05:53 +00:00
naruse 1bf066dcfa Preserve HTTP header key as string [Bug #15394]
to prevent send Host header twice accidentally.

From: Sangyong Sim <sangyong-sim@cookpad.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-10 23:54:14 +00:00
usa 5f91caceea Net::ReadTimeout and Net::WriteTimeout should tell the cause socket
* lib/net/protocol.rb (ReadTimeout, WriteTimeout): Net::ReadTimeout and Net::WriteTimeout should tell the cause socket
  [Feature #14832] [ruby-core:87440]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-10 07:11:18 +00:00
kazu c01a5ee85e Use delete_prefix instead of `sub(/\Afixed-pattern/, '')`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04 08:22:10 +00:00
kazu 972cf8c91e Fix up r65505 [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05 07:01:49 +00:00
marcandre e859e668d2 lib/*: Prefer require_relative over require.
[#15206] [Fix GH-1976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-02 17:52:33 +00:00
stomar 281d45ab0a lib/net/http.rb: [DOC] fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 20:00:46 +00:00
naruse 57c033bc5b Add negotiated SSL protocol and cipher to Net::HTTP debug output
From: Bart de Water <bartdewater@gmail.com>
https://github.com/ruby/ruby/pull/1877 [Feature #15009]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 11:29:38 +00:00
aycabta 4ae20f046e Improve doc of multipart/form-data [Bug #15019]
* lib/net/http.rb: Documentation for Net::HTTP claims that
  multipart/form-data is not supported, but Net::HTTPHeader#set_form
  supports it since 1.9.3.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 11:09:34 +00:00
marcandre d93dcd2840 net/http: Improve net/http header error message.
Patch by Matt Larraz. [Fix GH-1849].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-19 17:12:04 +00:00
kazu aa5d99280d Use unpack1 instead of unpack and `[0]`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-03 13:52:09 +00:00
rhe 1dfc377ae3 net/http, net/ftp: fix session resumption with TLS 1.3
When TLS 1.3 is in use, the session ticket may not have been sent yet
even though a handshake has finished. Also, the ticket could change if
multiple session ticket messages are sent by the server. Use
SSLContext#session_new_cb instead of calling SSLSocket#session
immediately after a handshake. This way also works with earlier protocol
versions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08 14:13:55 +00:00
usa 60c7fcf03a Get rid of warnings of test/spec
* lib/net/http/exceptions.rb: revert a part of r63590.  to deprecate
  Net::ProtoServerError seems to be wrong.
  see [ruby-core:87488] [Feature#14688]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-14 09:01:38 +00:00
naruse 51cfea31e5 write_timeout doc upates [skip ci]
From: MSP-Greg <MSP-Greg@users.noreply.github.com>
fix https://github.com/ruby/ruby/pull/1885

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-08 17:20:20 +00:00
kazu 905e89675f Fix typos [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-07 12:06:15 +00:00
naruse 439e50789b Use `Net::HTTPClientException` instead of `Net::HTTPServerException`
`Net::HTTPServerException` has been deprecated since r63590. [Bug #14688]
And `net/http/responses.rb` uses the deprecated constant, so Ruby warns of the deprecation.

Example:

```bash
$ ruby -r net/http -e ''
/home/pocke/.rbenv/versions/trunk/lib/ruby/2.6.0/net/http/responses.rb:22: warning: constant Net::HTTPServerException is deprecated
```

This change suppresses the warning.
From: Masataka Pocke Kuwabara <kuwabara@pocke.me>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-06 12:13:16 +00:00