summaryrefslogtreecommitdiff
path: root/lib/webrick/httpproxy.rb
AgeCommit message (Collapse)Author
2018-03-28revert r62985 (r62966 in trunk)naruse
It breaks test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28webrick/httpproxy: stream request and response bodiesnaruse
Reading entire request or response bodies into memory can lead to trivial denial-of-service attacks. Introduce Fibers in both cases to allow streaming. WEBrick::HTTPRequest gains a new body_reader method to prepare itself as a source for IO.copy_stream. This allows the WEBrick::HTTPRequest object to be used as the Net::HTTPGenericRequest#body_stream= arg for Net::HTTP. For HTTP proxy response bodies, we also use a Fiber to to make the HTTP request and read the response body. * lib/webrick/httprequest.rb (body_reader): new method (readpartial): ditto * lib/webrick/httpproxy.rb (perform_proxy_request): use Fiber to stream response body (do_GET, do_HEAD): adjust call (do_POST): adjust call and supply body_reader * test/webrick/test_httprequest.rb (test_chunked): test for IO.copy_stream compatibility * test/webrick/test_httpproxy.rb (test_big_bodies): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19webrick: handle EAGAIN/EWOULDBLOCK on proxy connectionsnormal
* lib/webrick/httpproxy.rb (do_CONNECT): high-level IO methods [ruby-core:82861] [Bug #12130] Patch by: Keisuke NISHI git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-10stdlib: avoid extra calls to eliminate "\n" from Base64normal
We may use the '0' (zero) to avoid adding the line feed. Furthermore, the '*' (asterisk) modifier is not needed for a single-element arrays. * ext/psych/lib/psych/visitors/yaml_tree.rb (visit_String): eliminate chomp * lib/net/http.rb (connect): eliminate delete * lib/net/http/header.rb (basic_encode): ditto * lib/net/imap.rb (authenticate): eliminate gsub (self.encode_utf7): shorten delete arg * lib/net/smtp.rb (base64_encode): eliminate gsub * lib/open-uri.rb (OpenURI.open_http): eliminate delete * lib/rss/rss.rb: ditto * lib/securerandom.rb (base64): ditto (urlsafe_base64): eliminate delete! * lib/webrick/httpauth/digestauth.rb (split_param_value): eliminate chop * lib/webrick/httpproxy.rb (do_CONNECT): eliminate delete (setup_upstream_proxy_authentication): ditto [ruby-core:72666] [Feature #11938] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13httpproxy.rb: fix typos [ci skip]nobu
* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#do_CONNECT): fix typos in debugger statements. [Fix GH-967] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-08* lib/webrick/httpproxy.rb: remove needless conditionhsbt
for old ruby version. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-26* lib/webrick/httpproxy.rb: remvoe useless assigned variables.hsbt
* lib/webrick/httpservlet/cgihandler.rb: ditto. * lib/webrick/httpservlet/erbhandler.rb: ditto. * lib/webrick/server.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-04* lib/webrick/httpproxy.rb: [DOC] Fix typoa_matsuda
s/bacause/because/ [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-08* lib/webrick/httpproxy.rb: Fix typos in HTTPProxyServer [Bug #8013]zzak
Patch by Nobuhiro IMAI [ruby-core:53127] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-26* lib/webrick/accesslog.rb: Improved WEBrick documentation.drbrain
* lib/webrick/cgi.rb: ditto. * lib/webrick/config.rb: ditto. * lib/webrick/cookie.rb: ditto. * lib/webrick/httpauth/authenticator.rb: ditto. * lib/webrick/httpauth/basicauth.rb: ditto. * lib/webrick/httpauth/digestauth.rb: ditto. * lib/webrick/httpproxy.rb: ditto. * lib/webrick/httprequest.rb: ditto. * lib/webrick/httpresponse.rb: ditto. * lib/webrick/https.rb: ditto. * lib/webrick/httpserver.rb: ditto. * lib/webrick/httpservlet/cgihandler.rb: ditto. * lib/webrick/httpservlet/filehandler.rb: ditto. * lib/webrick/httpservlet/prochandler.rb: ditto. * lib/webrick/httputils.rb: ditto. * lib/webrick/httpversion.rb: ditto. * lib/webrick/log.rb: ditto. * lib/webrick/server.rb: ditto. * lib/webrick/ssl.rb: ditto. * lib/webrick/utils.rb: ditto. * lib/webrick/version.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-02* lib/webrick.rb: Moved proxy rewriting to WEBrick::HTTPProxy.drbrain
* lib/webrick/httpproxy.rb: Add examples of creating a proxy server and response rewriting using HTTPProxy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-10 * lib/webrick: Add Documentationdrbrain
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06* {ext,lib,test}/**/*.rb: removed trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-08* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#do_CONNECT):matz
use #bytesize instead of #size. a patch submitted from raspberry lemon in [ruby-core:18571]. * lib/webrick/httpauth/digestauth.rb, lib/webrick/httpproxy.rb, lib/webrick/httprequest.rb, lib/webrick/httpservlet/cgi_runner.rb, lib/webrick/httpservlet/abstract.rb, lib/webrick/httpresponse.rb, lib/webrick/httpservlet/cgihandler.rb, lib/webrick/utils.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-04* lib/rdoc.rb: massive spelling correction patch from Evan Farrarmatz
<evanfarrar at gmail.com> in [ruby-doc:1382] applied. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_service):gotoyuzo
call do_XXX which corespond with request method. (WEBrick::HTTPProxyServer#do_CONNECT,do_GET,do_POST,do_HEAD): added. * test/webrick/test_httpproxy.rb: add test for WEBrick::HTTPProxyServer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-18* lib/rss/parser.rb, lib/rss/atom.rb, lib/rss/rss.rb,gotoyuzo
test/rss/rss-assertions.rb, test/rss/test_atom.rb: use pack/unpack("m") instead of base64 library. * lib/webrick/httpproxy.rb: use delete("\n") instead of chomp/chop because the result of pack("m") might be multi-line. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-08-07* lib/webrick/httpproxy.rb (HTTPProxyServer#intialize),gotoyuzo
lib/webrick/httpserver.rb (HTTPServer#intialize), lib/webrick/httpservlet/cgihandler.rb (CGIHandler#initialize), lib/webrick/httpservlet/erbhandler.rb (ERBHandler#initialize), lib/webrick/httpservlet/filehandler.rb(DefaultFileHandler#initialize): super (called with no arguments) takes default value of optional arguments. [ruby-dev:26743] * lib/webrick/httputils.rb: add a media-type "text/html" for .xhtml. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-07* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_service):gotoyuzo
should delete trailing LF from the result of pack("m*"). * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect): - should delete trailing LF from the result of pack("m*"). - clear Request-Line not to send the sesponse by HTTPServer#run. * lib/webrick/httputils (WEBrick::HTTPUtils.parse_qvalues): refine regexp (and change the name of a local variable). * lib/webrick/server.rb (WEBrick::Daemon.start): prepared stdio don't allow changing its mode. * test/webrick/*, sample/webrick/httpproxy.rb: add new files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-02* missed in last commit.gotoyuzo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-08-21* lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):gotoyuzo
should call :ProxyContentHandler before finishing CONNECT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-23* lib/webrick: imported.gotoyuzo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e