summaryrefslogtreecommitdiff
path: root/test/net/http
AgeCommit message (Collapse)Author
21 hours[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 <xry111@xry111.site> 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 <jeremy@instructure.com>
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 <nobu@ruby-lang.org>
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 <naruse@airemix.jp>
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 <stan001212@gmail.com>
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 <naruse@ruby-lang.org>
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
2022-01-11[ruby/net-http] Use omit instead of skip for test-unitHiroshi SHIBATA
https://github.com/ruby/net-http/commit/843d4548de
2022-01-04[ruby/net-http] Handle invalid use of IP addresses in SNIJeremy Evans
Server Name Indication does not allow IP addresses (RFC 6066, section 3: `Literal IPv4 and IPv6 addresses are not permitted in "HostName".`). Recent versions of LibreSSL enforce this restriction, which raises when setting the hostname to an IP address (s.hostname=), before attempting to setup the SSL connection. Since the certificate used in the test is already for localhost, we cannot connect to localhost. However, as all the test does is check for a specific exception, just modify the regexp used so it handles both cases. https://github.com/ruby/net-http/commit/6ab399db45
2021-12-13Prepare for removing RubyVM::JIT (#5262)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2021-11-15Sync test_http_request.rb after fix to net-httpJeremy Evans
2021-11-16[ruby/net-http] Fix tests after change to allow HEAD to send Accept-EncodingJeremy Evans
https://github.com/ruby/net-http/commit/ca7bb8c51c
2021-11-11quick fix for `test_initialize_HEAD`Koichi Sasada
https://github.com/ruby/ruby/commit/52ab9bbee918c63faad32e3851b162691b984d40 makes a failure. ``` 1) Failure: HTTPRequestTest#test_initialize_HEAD [/tmp/ruby/v3/src/trunk/test/net/http/test_http_request.rb:53]: <{"accept"=>["*/*"], "user-agent"=>["Ruby"]}> expected but was <{"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"], "accept"=>["*/*"], "user-agent"=>["Ruby"]}>. ``` I'm not sure it is correct, so please review later.
2021-11-04[ruby/net-http] Reset keep_alive timer on new connectionKazuki Yamaguchi
The last_communicated timestamp is for HTTP persistent connection, to decide whether the current TCP connection may be reused for the subsequent requests or not. Naturally, the timer must be reset if the connection is recreated since it is no longer relevant. https://github.com/ruby/net-http/commit/0a013de42d
2021-09-11[ruby/net-http] Use omit instead of skip for test-unitHiroshi SHIBATA
https://github.com/ruby/net-http/commit/5bb14fd3bc
2021-07-29Fix test failure of 60b02db5161625dd5f7d22d31989dd966837333c with WindowsHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4691
2021-07-29[ruby/net-http] Enforce write timeout when body_stream is usedMiguel Teixeira
The existing implementation of `Net::HTTP#write_timeout` relies on `Net::BefferedIO` to trigger the `Net::WriteTimeout` error. This commit changes `send_request_with_body_stream` to remove the optimization that was making `Net::HTTP#write_timeout` not work when `body_stream` is used. Open issue: https://bugs.ruby-lang.org/issues/17933 https://github.com/ruby/net-http/commit/a0fab1ab52
2021-05-06[ruby/net-http] Do not require stringioKazuki Yamaguchi
It is not used in net/http library code since commit 15ccd0118c13 (r36473 in ruby svn trunk, 2012). require's in test suite are also cleaned up. https://github.com/ruby/net-http/commit/996d18a43f
2021-05-04Fix test/net/http/test_https.rb host naming for WindowsMSP-Greg
Notes: Merged: https://github.com/ruby/ruby/pull/4424
2021-05-04Workaround failures on WindowsNobuyoshi Nakada
2021-04-28[ruby/net-http] Decode user and password from env configured proxyLukas Eipert
If someone sets an env variable defining a http_proxy, containing a username / password with percent-encoded characters, then the resulting base64 encoded auth header will be wrong. For example, suppose a username is `Y\X` and the password is `R%S] ?X`. Properly URL encoded the proxy url would be: http://Y%5CX:R%25S%5D%20%3FX@proxy.example:8000 The resulting proxy auth header should be: `WVxYOlIlU10gP1g=`, but the getters defined by ruby StdLib `URI` return a username `Y%5CX` and password `R%25S%5D%20%3FX`, resulting in `WSU1Q1g6UiUyNVMlNUQlMjAlM0ZY`. As a result the proxy will deny the request. Please note that this is my first contribution to the ruby ecosystem, to standard lib especially and I am not a ruby developer. References: - https://gitlab.com/gitlab-org/gitlab/-/issues/289836 - https://bugs.ruby-lang.org/projects/ruby-master/repository/trunk/revisions/58461 - https://bugs.ruby-lang.org/issues/17542 https://github.com/ruby/net-http/commit/e57d4f38aa
2021-01-23Fix a warningKazuhiro NISHIYAMA
``` .../ruby/test/net/http/test_httpresponse.rb:81: warning: constant RubyVM::MJIT is deprecated ```
2021-01-21[ruby/net-http] RubyVM::MJIT is deprecated, prefer RubyVM::JIT nowNobuyoshi Nakada
https://github.com/ruby/net-http/commit/abc6ea1877
2021-01-13Rename RubyVM::MJIT to RubyVM::JITTakashi Kokubun
because the name "MJIT" is an internal code name, it's inconsistent with --jit while they are related to each other, and I want to discourage future JIT implementation-specific (e.g. MJIT-specific) APIs by this rename. [Feature #17490]
2020-12-04Guard all accesses to RubyVM::MJIT with defined?(RubyVM::MJIT) &&Benoit Daloze
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
2020-09-24test/net/http/test_https.rb: The test logic was buggyYusuke Endoh
The expected certs must be `[CA_CERT, SERVER_CERT]` before 1.1.1g and `[SERVER_CERT]` after 1.1.1h.
2020-09-24test/net/http/test_https.rb: the order of verify_callback seems to varyYusuke Endoh
... depending upon the environment.
2020-09-24test/net/http/test_https.rb: Stop the error due to openssl 1.1.1hYusuke Endoh
On some environments that uses OpenSSL 1.1.1h, the two tests now fail. http://rubyci.s3.amazonaws.com/android29-x86_64/ruby-master/log/20200924T062352Z.fail.html.gz https://github.com/ruby/ruby/runs/1159288773?check_suite_focus=true ``` 1) Failure: TestNetHTTPS#test_get [/data/data/com.termux/files/home/cb/tmp/build/20200924T062352Z/ruby/test/net/http/test_https.rb:47]: <"0\x82\x03\xED0\x82\x02\xD5\xA0\x03..."> expected but was <"0\x82\x03\xE30\x82\x02\xCB\xA0\x03...">. ``` Not sure why, but verify_callback now seems to receive only SERVER_CERT but not CA_CERT. It would be good to investigate the issue furthermore, but tentatively, I want to stop the failures.
2020-08-03[ruby/net-http] Fix SSL session reuse test with LibreSSL 3.2+Jeremy Evans
https://github.com/ruby/net-http/commit/5ae9620fbc
2020-08-03[ruby/net-http] Switch invalid server name formatJeremy Evans
invalid_servername is not a valid name in an SSL request due to the use of the underscore, and LibreSSL 3.2.0 will raise an exception for this. These tests are not testing the allowed characters in the server name, but how net/http handles cases where the server name provided does not match the IP address you are trying to connect to, so I think it's better to just modify the tests to use a correct format. While here, fix a typo in a test name, and use better code in the ensure block so the same test doesn't issue both a failure and an error. https://github.com/ruby/net-http/commit/0e8dc91120
2020-06-22Skip test_read_body_block_mod for --jit-waitTakashi Kokubun