path: root/test/webrick
AgeCommit message (Collapse)Author
2020-12-10Move webrick library into internal test toolchainHiroshi SHIBATA
Notes: Merged:
2020-11-13[ruby/webrick] Allow empty POST and PUT requests without content lengthJeremy Evans
RFC 7230 section 3.3.3 allows for this. Fixes #30
2020-09-25Revert "[ruby/webrick] Add test for shutdown_pipe"Hiroshi SHIBATA
This reverts commit c06eab13290757fc326bb2a6e3ac25cd53e00894.
2020-09-25Revert "[ruby/webrick] Fix shutdown_pipe test issue"Hiroshi SHIBATA
This reverts commit b8fdd38b2e01abcfd4cc8d007a3b3afb285f5ddb.
2020-09-24Revert "[ruby/webrick] Allow empty POST and PUT requests without content length"Hiroshi SHIBATA
This reverts commit ed12019ce6abe87aac87ec77ac081d37b25180a2.
2020-09-24[ruby/webrick] Manually pick commit from upstream repoHiroshi SHIBATA
Fix test when run with US-ASCII encoding
2020-09-24[ruby/webrick] Only run test_big_bodies test on Ruby 2.5+Jeremy Evans
It was added after Ruby 2.5, and it looks like it never ran correctly on Ruby <2.5.
2020-09-24[ruby/webrick] Allow empty POST and PUT requests without content lengthJeremy Evans
RFC 7230 section 3.3.3 allows for this. Fixes #30
2020-09-24[ruby/webrick] Allow EPROTOTYPE error when writing junk to a socketJeremy Evans
MacOS seems to raise this error in some cases.
2020-09-24[ruby/webrick] Fix shutdown_pipe test issueJohn W Higgins
2020-09-24[ruby/webrick] Ensure server port numbers are numeric and ensure they are ↵John W Higgins
stored as integers
2020-09-24[ruby/webrick] Add test for shutdown_pipeJohn W Higgins
2020-09-24[ruby/webrick] Do not use ensure in a block without beginJeremy Evans
This syntax is not supported until Ruby 2.5, and Webrick still targets Ruby 2.3+.
2020-09-24[ruby/webrick] Skip env-locale-sensitive CGI test on the "java" platformCharles Oliver Nutter
JRuby's environment variables are provided by the Java Development Kit's (JDK's) classes, which present them as a map from string to string. In order to do this, those environment variable names and values must be decoded into characters, which breaks any variables that are intended to be "raw" bytes not necessarily decodable with the default system encoding. This issue is detailed in jruby/jruby#6248. The only solution on the JRuby side will be to bypass the JDK environment variable API and go directly to the native getenv/setenv system calls. This is not likely to happen in the near future, due to the complexity of such a change and the rarity of undecodable environment values. The exclude here was added due to the Windows platform also having a similar sensitivity to character encodings when working with environment variables. It seems appropriate to expand this skip to the "java" platform, as the root issue is largely the same.
2020-06-22Add tests of nested multibyte path and DirectoryIndexKazuhiro NISHIYAMA
2020-06-20Use section sign instead of Hiragana Letter AKazuhiro NISHIYAMA
It can convert to Windows-1252and Windows-31J. ``` "\u00a7".encode("Windows-1252") #=> "\xA7" "\u00a7".encode("Windows-31J") #=> "\x{8198}" ``` ``` 1) Failure: WEBrick::TestFileHandler#test_cjk_in_path [D:/a/ruby/ruby/src/test/webrick/utils.rb:72]: exceptions on 2 threads: webrick log start: [2020-06-19 14:49:38] ERROR Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and Windows-1252 D:/a/ruby/ruby/src/lib/webrick/httpservlet/filehandler.rb:341:in `+' D:/a/ruby/ruby/src/lib/webrick/httpservlet/filehandler.rb:341:in `set_filename' D:/a/ruby/ruby/src/lib/webrick/httpservlet/filehandler.rb:310:in `exec_handler' D:/a/ruby/ruby/src/lib/webrick/httpservlet/filehandler.rb:245:in `do_GET' D:/a/ruby/ruby/src/lib/webrick/httpservlet/abstract.rb:105:in `service' D:/a/ruby/ruby/src/lib/webrick/httpservlet/filehandler.rb:241:in `service' D:/a/ruby/ruby/src/lib/webrick/httpserver.rb:140:in `service' D:/a/ruby/ruby/src/lib/webrick/httpserver.rb:96:in `run' D:/a/ruby/ruby/src/lib/webrick/server.rb:307:in `block in start_thread' ```
2020-06-19Use filesystem encoding as FileHandler's encodingKazuhiro NISHIYAMA
instead of `@root.encoding`. And fallback to ASCII-8BIT when filesystem encoding is US-ASCII. When `@root.encoding` is not compatible filesystem encoding, `Encoding::CompatibilityError` raised at `webrick/httpservlet/filehandler.rb:341`. So `DocumentRoot` must be compatible with filesystem encoding.
2020-06-19Fix failure on mswin CIKazuhiro NISHIYAMA ``` 1) Failure: WEBrick::TestFileHandler#test_cjk_in_path [D:/tmp/mswin-build20200619-14304-utgij/ruby/test/webrick/utils.rb:72]: exceptions on 2 threads: webrick log start: [2020-06-19 16:28:42] ERROR `/あ.txt' not found. webrick log end Filesystem encoding is Windows-31J. <"200"> expected but was <"404">. --- <[]> expected but was <["[2020-06-19 16:28:42] ERROR `/\xE3\x81\x82.txt' not found.\n"]>. ``` `prevent_directory_traversal` treats `path_info` as filesystem encoding. So path_info should be filesystem encoding in request URL. On some environments, fallback to ASCII-8BIT when EncodingError.
2020-06-19test/webrick/test_httpresponse.rb: Use a longer indicator for crackYusuke Endoh
"hack" was too short. The tests checks the error html, which includes hostname. GitHub Actions hostname seems randomly generated, and it may include the indicator string. ``` 1) Failure: WEBrick::TestHTTPResponse#test_prevent_response_splitting_cookie_headers_cr [/home/runner/work/ruby/ruby/src/test/webrick/test_httpresponse.rb:71]: Expected /hack/ to not match "HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/html; charset=ISO-8859-1\r\n\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n<HTML>\n <HEAD><TITLE>Internal Server Error</TITLE></HEAD>\n <BODY>\n <H1>Internal Server Error</H1>\n WEBrick::HTTPResponse::InvalidHeader\n <HR>\n <ADDRESS>\n WEBrick/1.6.0 (Ruby/2.8.0/2020-06-18) at\n\n </ADDRESS>\n </BODY>\n</HTML>\n". ``` This change uses longer indicator "cracked_indicator_for_test" instead.
2020-06-18lib/webrick/httpservlet/filehandler.rb: always handle a path as UTF-8Yusuke Endoh ``` 1) Failure: WEBrick::TestFileHandler#test_cjk_in_path [D:/tmp/mswin-build20200618-84004-1t0dh8f/ruby/test/webrick/utils.rb:72]: exceptions on 2 threads: webrick log start: [2020-06-18 22:18:07] ERROR `/??.txt' not found. webrick log end Filesystem encoding is Windows-31J. <"200"> expected but was <"404">. ```
2020-06-18Read in ASCII-8BIT to get rid of invalid encoding errorNobuyoshi Nakada
2020-06-18test/webrick/test_filehandler.rb: implicitly fall back to UTF-8Yusuke Endoh ``` 2) Failure: WEBrick::TestFileHandler#test_cjk_in_path [D:/a/ruby/ruby/src/test/webrick/utils.rb:72]: exceptions on 1 threads: U+3042 to WINDOWS-1252 in conversion from UTF-8 to WINDOWS-1252 ```
2020-06-18test/webrick/test_filehandler.rb: remove unused variableYusuke Endoh
2020-06-18test/webrick/test_filehandler.rb: no `.encode("filesystem")` if US-ASCIIYusuke Endoh ``` I, [2020-06-18T00:28:11.661066 #31625] INFO -- : 1) Failure: I, [2020-06-18T00:28:11.661157 #31625] INFO -- : WEBrick::TestFileHandler#test_cjk_in_path [/tmp/ruby/v3/src/trunk-theap-asserts/test/webrick/utils.rb:72]: I, [2020-06-18T00:28:11.661216 #31625] INFO -- : exceptions on 1 threads: I, [2020-06-18T00:28:11.661269 #31625] INFO -- : U+3042 from UTF-8 to US-ASCII ```
2020-06-18test/webrick/test_filehandler.rb: Second try to fix the CI errorYusuke Endoh
93e6fa1d319d19ce7fba37e4b9924862447b9f38 failed to fix the issue. I suspect that the request path must be encoded as filesystem encoding.
2020-06-17Show filesystem encoding in failure messageKazuhiro NISHIYAMA
`test_cjk_in_path` failed on mswinci yet. ``` 1) Failure: WEBrick::TestFileHandler#test_cjk_in_path [D:/tmp/mswin-build20200617-120024-1brdn58/ruby/test/webrick/utils.rb:72]: exceptions on 2 threads: webrick log start: [2020-06-17 06:12:53] ERROR `/あ.txt' not found. webrick log end. <"200"> expected but was <"404">. --- <[]> expected but was <["[2020-06-17 06:12:53] ERROR `/\xE3\x81\x82.txt' not found.\n"]>. ```
2020-06-11[ruby/webrick] Fix httpd error in CJK directoryKazuhiro NISHIYAMA
[Bug #16753]
2020-02-29restore server[:DocumentRootOptions] setting.Koichi Sasada
Surprisingly (at least for me), `server[:DocumentRootOptions]` on Webrick is global information and it affect the result of test_short_filename. Random order test fails because of global information change. I doubt it is bug, but to fix random order test, I restore the value.
2020-02-13support multi-run test for test/webrick/test_filehandler.rbS-H-GAMELINKS
Notes: Merged:
2019-11-30[ruby/webrick] Check the feature by itself, instead of the version numberNobuyoshi Nakada
2019-11-30[ruby/webrick] Enabled chunked encoding if Transfer-Encoding: chunked header ↵Jeremy Evans
is set Patch from Leonard Garvey. Fixes Ruby Bug 9986.
2019-11-30[ruby/webrick] Allow WEBrick::HTTPServlet::CGIHandler :CGIInterpreter option ↵Jeremy Evans
to be array This way you don't need to escape each entry. Implements Ruby Feature 15170.
2019-10-24[ruby/webrick] Support literal IPv6 addresses in X-Forwarded-HostJeremy Evans
2019-10-24[ruby/webrick] Remove the squishing of whitespace in header valuesJeremy Evans
While the stripping of header values is required by RFC 2616 4.2 and RFC 7230 3.2.4, the squishing is not and can break things, such as when one header contains an HMAC of another header. Fixes Ruby Bug 7021.
2019-10-24[ruby/webrick] after ruby-2.6.0, set Net::HTTP#write_timeoutthekuwayama
2019-10-01WEBrick: prevent response splitting and header injectionYusuke Endoh
This is a follow up to d9d4a28f1cdd05a0e8dabb36d747d40bbcc30f16. The commit prevented CRLR, but did not address an isolated CR or an isolated LF. Co-Authored-By: NARUSE, Yui <>
2019-10-01Loop with String#scan without creating substringsNobuyoshi Nakada
Create the substrings necessary parts only, instead of cutting the rest of the buffer. Also removed a useless, probable typo, regexp.
2019-08-11Adjust indent [ci skip]Nobuyoshi Nakada
2019-08-08Aliases capture_output to capture_io for test-unit compatiblity.Hiroshi SHIBATA
2019-07-11remove an unused variable.Tanaka Akira
2019-07-11WEBrick::HTTPResponse create tempfile if required.Tanaka Akira
WEBrick::HTTPProxyServer implementes HTTP proxy using WEBrick and Net::HTTP. WEBrick accepts HTTP/1.0 clients and Net::HTTP uses always HTTP/1.1. However HTTP/1.1 supports chunked transfer coding HTTP/1.0 doesn't. Chunked transfer coding doesn't require that content-length before the content is sent. But non-chunked transfer coding require content-length before the content is sent. So, when HTTP/1.0 clients connects WEBrick::HTTPProxyServer and origin server returns chunked response, WEBrick::HTTPProxyServer needs to store whole content to know the length of it. This patch do it using tempfile.
2019-06-24httpstatus.rb 100% coveragemasakazutakewaka
2019-06-24Remove extraneous spaces at the end of status lineNobuyoshi Nakada
Remove extraneous spaces after the status code that is non-compliant with RFC, i.e `HTTP 200 OK `, to unnecessary confusion for WEBrick users, by a risk that WEBrick instances in the wild will have server responses flagged as suspicious or malicious due to a similar bug in [Cobalt Strike misconfiguration]. Reported by Matt Tennis <> [Cobalt Strike misconfiguration]:
2019-06-13test/webrick/test_ssl_server.rb: Use EnvUtil.timeout for timeout scale factorYusuke Endoh
2019-06-06test/webrick/test_filehandler.rb: extend the timeout for Solaris CIYusuke Endoh
2019-06-01Update String#crypt tests to work on OpenBSDJeremy Evans
Skip the webrick httpauth tests that use crypt when testing on OpenBSD. Fixes [Bug #11363]
2019-06-01Ignore warnings about ambiguous first argument of regexp with assert match.Hiroshi SHIBATA
2019-03-11Added to check MJIT constant for the Ruby 2.3-2.5.hsbt
This commit picked from Co-authored-by: Colby Swandale <> git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-28webrick/test_utils.rb: loosen timeout severityk0kubun
to stabilize CI failure like: git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-19webrick: add the ability to override res, req creationnormal
So that a customized HTTPServer subclass can use it's own Request/Response classes. To apply the override, make a subclass of WEBrick::HTTPServer and override the `create_request_and_response(with_webrick_config)` method. The method should return an Array of [request, response]. To check whether the Server supports this method (i.e. when using older versions of WEBrick when needing this functionality), you can ask the server if it responds to the method server.respond_to?(:create_request_and_response) This is backportable. [ruby-core:69604] [Feature #11266] From: Julik Tarkhanov <> git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e