aboutsummaryrefslogtreecommitdiffstats
path: root/lib/net/http
Commit message (Collapse)AuthorAgeFilesLines
* Added dependencies for net-httpHiroshi SHIBATA2020-12-021-0/+1
|
* Added dependency for net-protocolHiroshi SHIBATA2020-11-061-0/+2
|
* Added the missing licenses field to some default gemsHiroshi SHIBATA2020-08-181-0/+1
|
* Extract version number from the sourceNobuyoshi Nakada2020-07-302-11/+9
| | | | | | | | | | | "requiring version.rb" strategy has some issues. - cannot work when cross-compiling - often introduces wrong namespace - must know the superclasses - costs at each runtime than at build-time etc.
* Fix error raised by Net::HTTPResponse#inflater if the block raisesBenoit Daloze2020-05-311-2/+3
| | | | * See https://bugs.ruby-lang.org/issues/13882#note-6
* Improve documentation for Net::HTTPHeader#set_form [ci skip]Jeremy Evans2020-05-271-16/+36
| | | | Fixes [Misc #16916]
* The current net-http is only works with Ruby 2.6+Hiroshi SHIBATA2020-04-081-1/+1
|
* Add workaround for test-bundler failureKazuhiro NISHIYAMA2020-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/ruby/actions/runs/500526558?check_suite_focus=true#step:16:127 ``` Failures: 1) Bundler.setup when Bundler is bundled doesn't blow up Failure/Error: expect(err).to be_empty expected `"fatal: not a git repository (or any of the parent directories): .git\nfatal: not a git repository (o...the parent directories): .git\nfatal: not a git repository (or any of the parent directories): .git".empty?` to return true, got false Commands: $ /home/runner/work/actions/actions/snapshot-master/ruby \ -I/home/runner/work/actions/actions/snapshot-master/lib:/home/runner/work/actions/actions/snapshot-master/spec/bundler \ -rsupport/hax -rsupport/artifice/fail \ /home/runner/work/actions/actions/snapshot-master/libexec/bundle install --retry 0 Resolving dependencies... Using bundler 2.1.4 Bundle complete! 1 Gemfile dependency, 1 gem now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git # $? => 0 $ /home/runner/work/actions/actions/snapshot-master/ruby \ -I/home/runner/work/actions/actions/snapshot-master/lib:/home/runner/work/actions/actions/snapshot-master/spec/bundler \ -rsupport/hax -rsupport/artifice/fail \ /home/runner/work/actions/actions/snapshot-master/libexec/bundle exec ruby -e \ require\ \'bundler\'\;\ Bundler.setup fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git # $? => 0 # ./spec/bundler/runtime/setup_spec.rb:1056:in `block (3 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:111:in `block (3 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:111:in `block (2 levels) in <top (required)>' # ./spec/bundler/spec_helper.rb:78:in `block (2 levels) in <top (required)>' make: *** [yes-test-bundler] Error 1 ```
* Promote net-http to the default gems.Hiroshi SHIBATA2020-02-212-0/+34
| | | | | test/net/http/test_https.rb: rename fixture methods to read_fixture because it conflicts with test-unit gem.
* Revert "lib/net/http/response.rb: support raw deflate correctly"Yusuke Endoh2019-12-161-3/+3
| | | | | | | | | | | | | | | | This reverts commit 5105240b1e851410020b3b3f1a2bead7ffdd4291. 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]
* lib/net/http/response.rb: support raw deflate correctlyYusuke Endoh2019-12-161-3/+3
| | | | | | | | | | | | | | 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]
* Fix a typo [ci skip]Kazuhiro NISHIYAMA2019-11-151-1/+1
|
* Improve Net::HTTP docs:zverok2019-10-262-6/+12
| | | | | | | * Make links from Net::GenericHTTPRequest work; * Document +dest+ param of HTTPResponse#read_body; * Slightly improve reference to particular response classes from HTTPResponse class docs.
* Remove uselsess shebangPavel Valena2019-10-091-1/+0
| | | as the file is not executable anyway.
* Fix typo: duplicated the [skip-ci]ohbarye2019-08-091-1/+1
|
* Show the caller's locationNobuyoshi Nakada2019-07-241-2/+2
| | | | | * lib/net/http/header.rb: show the caller's location instead of the current lines.
* ReFix r663197nobu2018-12-111-10/+10
| | | | | | | 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
* Fix r663197nobu2018-12-111-10/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Preserve HTTP header key as string [Bug #15394]naruse2018-12-101-12/+14
| | | | | | | | 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
* lib/*: Prefer require_relative over require.marcandre2018-11-021-1/+1
| | | | | | [#15206] [Fix GH-1976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/http: Improve net/http header error message.marcandre2018-09-191-1/+1
| | | | | | Patch by Matt Larraz. [Fix GH-1849]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Get rid of warnings of test/specusa2018-06-141-1/+0
| | | | | | | | | * 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
* Use `Net::HTTPClientException` instead of `Net::HTTPServerException`naruse2018-06-061-1/+1
| | | | | | | | | | | | | | | | | `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
* Add Net::HTTPClientException [Bug #14688]naruse2018-06-061-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Raise ArgumentError if host component is nilnaruse2018-03-081-0/+2
| | | | | | | From: oss92 <mohamed.o.alnagdy@gmail.com> fix https://github.com/ruby/ruby/pull/1278 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/http: use writev for HTTP chunked request bodiesnormal2018-01-141-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces both user and system CPU time for large uploads with dynamically-generated request bodies. user system total real before: 0.393334 1.580000 1.973334 ( 1.971066) after: 0.223334 0.976666 1.200000 ( 1.198514) ------ require 'socket' require 'net/http' require 'benchmark' nr = 1024 * 1024 * 1024 s = TCPServer.new('127.0.0.1', 0) addr = s.addr at_exit { Process.waitall } fork do c = s.accept # not exactly accurate but fast IO.copy_stream(c, '/dev/null', nr + 500000) begin buf = c.readpartial(16384) tmp = '' until buf.end_with?(-"0\r\n\r\n") buf << c.readpartial(16384, tmp) end rescue EOFError end c.write "HTTP/1.1 201 Created\r\nConnection:close\r\n\r\n" c.close end r, w = IO.pipe fork do r.close IO.copy_stream('/dev/zero', w, nr) w.close end w.close Net::HTTP.start(addr[3], addr[1]) do |http| put = Net::HTTP::Put.new('/dev0/foo') put['Content-Type'] = 'application/content-type' put['Transfer-Encoding'] = 'chunked' put.body_stream = r puts(Benchmark.measure { http.request(put) }) end ------ * lib/net/http/generic_request.rb (write): use multi-arg write * lib/net/protocol.rb (write): support multi-arg (write0): ditto [ruby-core:84845] [Feature #14339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `103 Early Hints` to `Net::HTTP::STATUS_CODES` [ci skip]kazu2018-01-121-0/+1
| | | | | | Update by `ruby lib/net/http/status.rb | sponge lib/net/http/status.rb` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/http: clear compressed chunk after decompressionnormal2018-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We no longer need the compressed data once the inflate block is called; so clear it ASAP to reduce memory overhead. This is a small chunk, so it only saves a few hundred kilobytes with the script below. before: RssAnon: 5976 kB after: RssAnon: 5564 kB ------ require 'net/http' require 'zlib' response_gz = ARGV.shift or abort "#$0 TEMPORARY_FILE" # pre-create response since compressing is slower than decompressing unless File.readable?(response_gz) nr = 16384 * 2 buf = ((0..255).map(&:chr).join * 128) File.open(response_gz, 'wb') do |fp| gzip = Zlib::GzipWriter.new(fp) nr.times { gzip.write(buf) } gzip.close end buf.clear end response_gz = File.open(response_gz) s = TCPServer.new('127.0.0.1', 0) pid = fork do c = s.accept c.readpartial(16384).clear c.write("HTTP/1.1 200 OK\r\n" \ "Content-Length: #{response_gz.stat.size}\r\n" \ "Content-Encoding: gzip\r\n" \ "Accept-Ranges: bytes\r\n" \ "\r\n") IO.copy_stream(response_gz, c) c.close end addr = s.addr Net::HTTP.start(addr[3], addr[1]) do |http| http.request_get(-'/') do |res| res.read_body(&:clear) end end puts File.readlines(-'/proc/self/status').grep(/RssAnon/)[0] Process.waitpid2(pid) ------ * lib/net/http/response.rb (inflate_adapter): clear compressed_chunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update Status Codekazu2018-01-061-11/+15
| | | | | | see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add 103 Early Hintskazu2018-01-061-0/+4
| | | | | | see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Specify frozen_string_literal: truekazu2018-01-061-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* raise error if value contains CR/LF in iniheader of initialize_http_headernaruse2017-12-201-3/+7
| | | | | | like r59693, initialize_http_header also should raise error. [Bug #14208] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add uplevel keyword to Kernel#warn and use itshyouhei2017-12-123-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If uplevel keyword is given, the warning message is prepended with caller file and line information and the string "warning: ". The use of the uplevel keyword makes Kernel#warn format output similar to how rb_warn formats output. This patch modifies net/ftp and net/imap to use Kernel#warn instead of $stderr.puts or $stderr.printf, since they are used for printing warnings. This makes lib/cgi/core and tempfile use $stderr.puts instead of warn for debug logging, since they are used for debug printing and not for warning. This does not modify bundler, rubygems, or rdoc, as those are maintained outside of ruby and probably wish to remain backwards compatible with older ruby versions. rb_warn_m code is originally from nobu, but I've changed it so that it only includes the path and lineno from uplevel (not the method), and also prepends the string "warning: ", to make it more similar to rb_warn. From: Jeremy Evans code@jeremyevans.net Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixed misspelling words.hsbt2017-10-221-2/+2
| | | | | | These are detected by https://github.com/client9/misspell git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use caller with length to reduce unused stringskazu2017-10-211-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* HTTPHeader#add_field should allow binary [Bug #13926]naruse2017-09-251-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* to_str -> to_sko12017-08-301-1/+1
| | | | | | | * lib/net/http/header.rb (set_field): `val` can not have `to_str`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* A HTTP Header value must not contain CR or LF.naruse2017-08-301-2/+30
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix `NameError: uninitialized constant Net`kazu2017-08-041-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Define classes for r58800naruse2017-05-191-5/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]naruse2017-05-191-0/+81
| | | | | | | | Note that 418 I'm a teapot doesn't exist because RFC 2324 and RFC 7168 are not registered in IANA repository. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add more HTTP status classesnaruse2017-05-191-1/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix undefined method 'dump' for nil:NilClass (NoMethodError)a_matsuda2016-11-081-1/+3
| | | | | | | | | Patch by: Dmitry Vorotilin <d.vorotilin@gmail.com> (@route) Signed-off-by: Akira Matsuda <ronnie@dio.jp> closes #1475 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/response.rb: Improve document readability.hsbt2016-10-051-2/+2
| | | | | | [fix GH-1411][ci skip] Patch by @stz-seongheon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/header.rb: Fix typo. [ci skip][fix GH-1407]hsbt2016-08-161-1/+1
| | | | | | * transcode.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/generic_rquest.rb (write_header): A Request-Line mustshugo2016-07-061-1/+6
| | | | | | not contain CR or LF. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/header.rb: [DOC] add documentation thatktsj2016-05-041-0/+10
| | | | | | | Net::HTTPHeader#{each_header,each_name,each_capitalized_name, each_value,each_capitalized} without block returns an enumerator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/header.rb (Net::HTTPHeader#{each_header,each_name,ktsj2016-05-041-5/+5
| | | | | | | | | each_capitalized_name,each_value,each_capitalized}): Return sized enumerators. * test/net/http/test_httpheader.rb: add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* net/http/header.rb: refactornobu2016-04-251-12/+8
| | | | | | | | | * lib/net/http/header.rb (connection_close?): match headers without making intermediate arrays. * lib/net/http/header.rb (connection_keep_alive?): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/header.rb: Warn nil variable on HTTP Header.hsbt2016-01-291-2/+5
| | | | | | | It caused to NoMethodError. [fix GH-952][fix GH-641] Patch by @teosz * test/net/http/test_httpheader.rb: Added test for nil HTTP Header. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e