summaryrefslogtreecommitdiff
path: root/test/net/http
AgeCommit message (Collapse)Author
2025-04-03Use EnvUtil.apply_timeout_scaleHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/13058
2025-04-03Extend open_timeout for test failure on s390xHiroshi SHIBATA
https://rubyci.s3.amazonaws.com/s390x/ruby-master/log/20250403T060004Z.fail.html.gz Notes: Merged: https://github.com/ruby/ruby/pull/13058
2024-12-31[ruby/net-http] Don't double-interrupt the test HTTP serverCharles Oliver Nutter
The shutdown process here attempted to terminate the test server by interrupting it with Thread#kill, and then proceeded to close the server and join the thread. The kill does indeed interrupt the accept call, but the close call could also interrupt the thread as part of notifying blocked threads waiting on that socket call. In JRuby, where all of this can happen at the same time, it leads to the following scenario: * The server thread enters TCPServer#accept and blocks. * The main thread calls Thread#kill to interrupt the accept call. * The server thread wakes up and starts to propagate the kill. There is a slight delay between this wakeup and removing the server thread from the TCPServer's blocked threads list. * The main thread calls TCPServer#close, which sees that the server thread is still in the blocked list, so it initiates a second interrupt to raise IOError "closed in another thread" on the server thread. * As the kill is bubbling out, another check for interrupts occurs, causing it to see the new raise interrupt and propagate that instead of the active kill. * Because the server is now closed and the rescue here is empty, the server loop will endlessly attempt and fail to call accept. I was unable to determine how CRuby avoids this race. There may be code that prevents an active kill interrupt from triggering further interrupts. In order to get these tests running on JRuby, I've made the following changes: * Only kill the thread; one interrupt is sufficient to break it out of the accept call. * Ensure outside the server loop that the server gets closed. This happens within the server thread, so triggers no new interrupts. * Minor cleanup for the pattern of using @ssl_server or @server. This change avoids the race in JRuby (and possibly other parallel- threaded implementations) and does not impact the behavior of the tests. https://github.com/ruby/net-http/commit/54025b3870
2024-11-15Do not wait connection attempt delay without in progress fds (#12087)Misaki Shioi
Do not wait Connection Attempt Delay without in progress fds Reset Connection Attempt Delay when connection fails and there is no other socket connection in progress. This is intended to resolve an issue that was temporarily worked around in Pull Request #12062. `TCPServer::new` (used in tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`) can only connect over either IPv6 or IPv4, depending on the environment. Since HEv2 attempts to connect over IPv6 first, environments where IPv6 connections are unavailable return ECONNREFUSED immediately. In such cases, the client should immediately retry the connection over IPv4. However, HEv2 includes a specification for a "Connection Attempt Delay," where it waits 250ms after the previous connection attempt before starting the next one. This delay causes Net::OpenTimeout (100ms) to be exceeded while waiting for the next connection attempt to start. With this change, when a connection attempt fails, if there are sockets still attempting to connect and there are addresses yet to be tried, the Connection Attempt Delay will be resetted, allowing the next connection attempt to start immediately. --- Additionally, the following minor fixes have been made: - The `nfds` value used for select(2) is now reset with each wait. Notes: Merged-By: shioimm <[email protected]>
2024-11-12Allow Net::HTTP#request to raise Net::OpenTimeout (#12062)Misaki Shioi
with a TCPSoerver that is only listening to avoid AssertionFailedError on Ubuntu. --- The tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write` expect to raise a `Net::WriteTimeout` due to a failure in writing to the server. However, on Ubuntu environments, the server immediately returns a "Connection Refused" in such cases. The socket created with `TCPSocket.new` that supports HEv2 catches this immediately and raises a `Net::OpenTimeout`. As a result, these tests fail due to raising a different exception than expected. This PR adds `Net::OpenTimeout` asexceptions to avoid these test failures. Notes: Merged-By: shioimm <[email protected]>
2024-09-13[ruby/net-http] Prevent warningsYusuke Endoh
``` /home/chkbuild/chkbuild/tmp/build/20240913T003003Z/ruby/test/net/http/utils.rb:32: warning: assigned but unused variable - e /home/chkbuild/chkbuild/tmp/build/20240913T003003Z/ruby/test/net/http/utils.rb:61: warning: assigned but unused variable - version /home/chkbuild/chkbuild/tmp/build/20240913T003003Z/ruby/test/net/http/utils.rb:124: warning: method redefined; discarding old query ``` https://github.com/ruby/net-http/commit/6f818346ce
2024-07-30Wait for server threads to finishNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11273
2024-07-26[ruby/net-http] Removed needless NullWriter classHiroshi SHIBATA
https://github.com/ruby/net-http/commit/ddb2a81aed
2024-07-17To avoid fd leak with fetch request for SSL serverHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/11171
2024-07-17Fixed fd leak from TCPServerHiroshi SHIBATA
``` Leaked file descriptor: HTTPSProxyTest#test_https_proxy_ssl_connection: 8 : #<TCPServer:fd 8, AF_INET, 127.0.0.1, 63104> ``` Notes: Merged: https://github.com/ruby/ruby/pull/11171
2024-07-12Use fixture certificates to fix test failure with RHEL9.Hiroshi SHIBATA
http://rubyci.s3.amazonaws.com/rhel9/ruby-master/log/20240711T213004Z.fail.html.gz ``` 1) Error: HTTPSProxyTest#test_https_proxy_ssl_connection: OpenSSL::X509::CertificateError: invalid digest /home/chkbuild/chkbuild/tmp/build/20240711T213004Z/ruby/test/net/http/test_https_proxy.rb:63:in 'OpenSSL::X509::Certificate#sign' /home/chkbuild/chkbuild/tmp/build/20240711T213004Z/ruby/test/net/http/test_https_proxy.rb:63:in 'HTTPSProxyTest#test_https_proxy_ssl_connection' ```
2024-07-11[ruby/net-http] implement talking SSL to the proxy tooEvgeni Golov
https://bugs.ruby-lang.org/issues/16482 https://github.com/ruby/net-http/commit/ae2d83f88b
2024-07-11[ruby/net-http] Add ability to configure default settings for new connectionsfatkodima
https://github.com/ruby/net-http/commit/fed3dcd0c2
2024-07-11[ruby/net-http] test_https.rb - fix test_session_reuse_but_expireMSP-Greg
https://github.com/ruby/net-http/commit/5544243c41
2024-07-10* append newline at EOF. [ci skip]git
2024-07-10[ruby/net-http] Commented out unfinished chunked testHiroshi SHIBATA
https://github.com/ruby/net-http/commit/6376592cb4
2024-07-10[ruby/net-http] Removed needless warningHiroshi SHIBATA
https://github.com/ruby/net-http/commit/d867edc0fe
2024-07-10[ruby/net-http] Split POST test because new dummy server can't handle ↵Hiroshi SHIBATA
continuouse POST request https://github.com/ruby/net-http/commit/54a99b9f0c
2024-07-10[ruby/net-http] Write log after server start, not handling requestHiroshi SHIBATA
https://github.com/ruby/net-http/commit/205bac757a
2024-07-10[ruby/net-http] Split test class because TCPServer couldn't accept localhost ↵Hiroshi SHIBATA
and 127.0.0.1 both https://github.com/ruby/net-http/commit/749a1b3197
2024-07-10[ruby/net-http] Support chunked data and fixed test failure with ↵Hiroshi SHIBATA
multipart/form-data https://github.com/ruby/net-http/commit/b38c2795a9
2024-07-10[ruby/net-http] Removed server-side log testHiroshi SHIBATA
https://github.com/ruby/net-http/commit/9c16c383ce
2024-07-10[ruby/net-http] Fix wrong hostname with test_max_version testHiroshi SHIBATA
https://github.com/ruby/net-http/commit/f00d198433
2024-07-10[ruby/net-http] Rewrite WEBrick server with TCPServer and ↵Hiroshi SHIBATA
OpenSSL::SSL::SSLServer https://github.com/ruby/net-http/commit/b01bcf6d7f
2024-04-25[ruby/net-http] Skip test_session_reuse_but_expire with OpenSSL 3.3Xi Ruoyao
OpenSSL 3.3.0 9 Apr 2024 is also broken. Signed-off-by: Xi Ruoyao <[email protected]> https://github.com/ruby/net-http/commit/ab525c956d
2024-02-07Fix test session reuse but expire (#9824)NARUSE, Yui
* OpenSSL 3.2.1 30 Jan 2024 is also broken Import 45064610725ddd81a5ea3775da35aa46985bc789 from ruby_3_3 branch tentatively.
2024-02-03Show OpenSSL version in the error message of assert_equalNARUSE, Yui
2024-01-05[ruby/net-http] Don't invoke response block more than once due to retryJeremy Evans
If a socket error occurs while performing a streaming download via the response block provided to transport_request, avoid calling the response block again as this would result in duplicate data received by the client. Fixes https://github.com/ruby/net-http/pull/86 Fixes https://github.com/ruby/net-http/pull/87 Fixes [Bug #11526] https://github.com/ruby/net-http/commit/114d01b092 Co-authored-by: Jeremy Stanley <[email protected]>
2023-11-26Omit test_session_reuse_but_expire if OpenSSL 3.2.0Nobuyoshi Nakada
2023-11-24Omit a broken https test on MinGWTakashi Kokubun
This started to reliably fail on MinGW at an irrelevant commit: https://github.com/ruby/ruby/actions/runs/6981002841/job/18997302124 https://github.com/ruby/ruby/actions/runs/6981946473/job/19000104223 https://github.com/ruby/ruby/actions/runs/6983823136/job/19005613809 https://github.com/ruby/ruby/actions/runs/6983912116/job/19005844596 https://github.com/ruby/ruby/actions/runs/6984215921/job/19006649495 https://github.com/ruby/ruby/actions/runs/6984383103/job/19007100446 https://github.com/ruby/ruby/actions/runs/6986489509/job/19012000642 So this failure is not detecting a new bug. Let's skip this until we fix this test for MinGW.
2023-10-30[ruby/net-http] fix a false-negative testChristian van Rensen
* no_proxy is meant to operate on the destination address, not on the name of the proxy * if both end with `'.example'`, the test does not nail down the behaviour https://github.com/ruby/net-http/commit/bb9a5cfa3d
2023-10-16[ruby/net-http] Force TLS version to 1.2 when using LibreSSLJeremy Evans
This comment previously specified TLS 1.2, but actually set the version to TLS 1.0. LibreSSL 3.8.1 (included in OpenBSD 7.4) dropped support for TLS 1.0/1.1 for security reasons, which broke this test. Switch the test to use TLS 1.2 as documented so it will continue to work on OpenBSD 7.4+. https://github.com/ruby/net-http/commit/97be4de53a
2023-10-05[ruby/net-http] Net::HTTPResponse nil checkingBrian Hawley
Fix nil handling in read_body and stream_check. Fixes: #70 https://github.com/ruby/net-http/commit/36f916ac18
2023-03-06s/mjit/rjit/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2023-03-06s/MJIT/RJIT/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2022-11-26[ruby/net-http] Fix test for Ruby headPeter Zhu
The error raised for broken coderanges was changed in ruby/ruby@571d21f and the test was fixed in that commit but not ported to this repo. ruby/net-http@e6185dda26ea6db7a3515d4f47ab231f5f4ac902
2022-11-24Make String#rstrip{,!} raise Encoding::CompatibilityError for broken coderangeJeremy Evans
It's questionable whether we want to allow rstrip to work for strings where the broken coderange occurs before the trailing whitespace and not after, but this approach is probably simpler, and I don't think users should expect string operations like rstrip to work on broken strings. In some cases, this changes rstrip to raise Encoding::CompatibilityError instead of ArgumentError. However, as the problem is related to an encoding issue in the receiver, and due not due to an issue with an argument, I think Encoding::CompatibilityError is the more appropriate error. Fixes [Bug #18931] Notes: Merged: https://github.com/ruby/ruby/pull/6282
2022-09-28[ruby/net-http] Remove ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFEJeremy Evans
This list is out of date. At least OpenBSD since 2013 does not allow one user to read the environment variables of a process run by another user. While we could try to keep the list updated, I think it's a bad idea to not use the user/password from the environment, even if another user on the system could read it. If http_proxy exists in the environment, and other users can read it, it doesn't make it more secure for Ruby to ignore it. You could argue that it encourages poor security practices, but net/http should provide mechanism, not policy. Fixes [Bug #18908] https://github.com/ruby/net-http/commit/1e4585153d
2022-06-16[ruby/net-http] Make `Net::HTTPHeader#content_range` return nil on non-byte ↵Shishir Joshi
units * Returning nil from the `content_range` method instead of raising an error when the unit in the content-range header is not "bytes". Fix https://bugs.ruby-lang.org/issues/11450 https://github.com/ruby/net-http/commit/0b5030dd86 Co-Authored-By: Nobuyoshi Nakada <[email protected]>
2022-06-16Revert "HTTPHeader.content_range throws error on non-byte units"Nobuyoshi Nakada
This reverts commit 63546bfc1581d4abec2a0d846106a1c0afc0efa9.
2022-06-16HTTPHeader.content_range throws error on non-byte unitsShishir Joshi
* Added a nil check in Net::HTTPHeader#initialize_http_header for keys in the header that do not have any value * Returning nil from the content_range method instead of raising an error when the unit in the content-range header is not bytes * Modified initialize_http_header to match trunk fix [Bug #11450] fix https://github.com/ruby/ruby/pull/1018 Notes: Merged-By: nurse <[email protected]>
2022-04-20[ruby/net-http] Feature detect to make net/http usable with JRubyKarol Bucek
Handle missing session_new_cb= and do not call session_cache_mode=, as JRuby SSL does not support these methods. https://github.com/ruby/net-http/commit/3237ef4d8c
2022-04-20[ruby/net-http] Add ignore_eof access to HTTP and HTTPResponseJeremy Evans
The ignore_eof setting on HTTPResponse makes it so an EOFError is raised when reading bodies with a defined Content-Length, if the body read was truncated due to the socket be closed. The ignore_eof setting on HTTP sets the values used in responses that are created by the object. For backwards compatibility, the default is for both settings is true. However, unless you are specifically tested for and handling truncated responses, it's a good idea to set ignore_eof to false so that errors are raised for truncated responses, instead of those errors silently being ignored. Fixes [Bug #14972] https://github.com/ruby/net-http/commit/4d47e34995
2022-04-14[ruby/net-http] Update the content-length heading when decoding bodiesJeremy Evans
Previously, the content-encoding header was removed and the body was modified, but the content-length header was not modified, resulting in the content-length header not matching the body length. Don't delete content-length before yielding inflate body, as that causes a switch to read the entire body instead of reading in chunks. Fixes [Bug #16672] https://github.com/ruby/net-http/commit/58284e9710 Co-authored-by: st0012 <[email protected]>
2022-04-12[ruby/net-http] Add HTTP#response_body_encoding for setting response body ↵Jeremy Evans
encoding This allows for the ability to opt-in to a method to set the encoding of response bodies. By setting the accessor to a String or Encoding instance, it will use the specified encoding. Setting the value of true will try to detect the encoding of the response body, either using the Content-Type header (assuming it specifies charset) or by scanning for a <meta> tag in the document that specifies the encoding. The default is false in which case no forcing of encoding will be done (same as before the patch). Implements [Feature #2567] Implements [Feature #15517] https://github.com/ruby/net-http/commit/6233e6b7c1 Co-authored-by: Yui Naruse <[email protected]>
2022-04-03[ruby/net-http] Revert "Update the content-length heading when decoding bodies"Jeremy Evans
This reverts commit https://github.com/ruby/net-http/commit/a7cb30124cf1. This is causing errors in Ruby's CI, will revert for now and try again after testing a fix with Ruby's CI. https://github.com/ruby/net-http/commit/7b852b1feb
2022-04-02[ruby/net-http] Update the content-length heading when decoding bodiesJeremy Evans
Previously, the content-encoding header was removed and the body was modified, but the content-length header was not modified, resulting in the content-length header not matching the body length. Fixes [Bug #16672] https://github.com/ruby/net-http/commit/a7cb30124c
2022-02-03[ruby/net-http] Do not set SNI hostname if connecting to IP addressJeremy Evans
RFC 6066, section 3, explicitly disallows the use of an IP address as an SNI server name. So check if the connection is being made to an IP address using the resolv regexps, and do not set an SNI hostname in that case. Recent changes to LibreSSL make it more strictly follow RFC 6066, resulting an s.hostname= raising an error if passed an IP address. When such verions of LibreSSL are used, this change not only fixes the net/http tests, it also fixes tests for webrick and open-uri, which both make SSL connections to 127.0.0.1 using net/http in their tests. Avoid warning in the openssl extension by unsetting @ssl_context.verify_hostname if connecting to an IP address. Make changes so that the post_connection_check still happens when connecting to an IP address, which is necessary to keep checking that the certificate returned includes the IP address, which one of the tests depends on. Revert the previous change that modified the regexp used for checking the error message. https://github.com/ruby/net-http/commit/fa68e64bee
2022-01-17[ruby/net-http] Remove redundant MJIT conditionKazuhiro NISHIYAMA
ref https://github.com/ruby/ruby/commit/da0f67c0383f57129c7a76255964b1ee739d8db8 https://github.com/ruby/net-http/commit/dbeb5f1c8f
2022-01-14[ruby/net-http] Fix unescaped `.` in RegexpKazuhiro NISHIYAMA
Use `include?` instead. https://github.com/ruby/net-http/commit/05022744a9