Projects
Mega:23.09
rubygem-excon
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:rubygem-excon.spec
Changed
@@ -1,14 +1,12 @@ %bcond_with bootstrap %global gem_name excon Name: rubygem-%{gem_name} -Version: 0.62.0 -Release: 3 +Version: 0.104.0 +Release: 1 Summary: Speed, persistence, http(s) License: MIT URL: https://github.com/excon/excon Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem -Patch0: rubygem-excon-0.62.0-Ruby-2.6-escapes-InvalidURIError-output.patch -Patch1: CVE-2019-16779.patch BuildRequires: ruby(release) rubygems-devel ruby %{_bindir}/openssl rubygem-rack BuildRequires: rubygem-shindo rubygem(activesupport) rubygem(delorean) rubygem(eventmachine) BuildRequires: rubygem(open4) rubygem(puma) rubygem(sinatra) rubygem(rspec) @@ -27,8 +25,6 @@ %prep %setup -q -n %{gem_name}-%{version} -%patch0 -p1 -%patch1 -p1 sed -i "/ciphers/ s/'.*'/'PROFILE=SYSTEM'/" lib/excon/constants.rb %build @@ -57,7 +53,6 @@ %files %dir %{gem_instdir} -%exclude %{gem_instdir}/.* %license %{gem_instdir}/LICENSE.md %{gem_libdir} %exclude %{gem_cache} @@ -66,16 +61,13 @@ %files help %doc %{gem_docdir} %doc %{gem_instdir}/CONTRIBUT* -%{gem_instdir}/Gemfile %doc %{gem_instdir}/README.md -%{gem_instdir}/Rakefile -%{gem_instdir}/benchmarks -%doc %{gem_instdir}/changelog.txt %{gem_instdir}/excon.gemspec -%{gem_instdir}/spec -%{gem_instdir}/tests %changelog +* Tue Nov 14 2023 xu_ping <707078654@qq.com> - 0.104.0-1 +- Upgrade version to 0.104.0 + * Mon Nov 1 2021 liwu <liwu13@huawei.com> - 0.62.0-3 - Fix CVE-2019-16779
View file
_service:tar_scm:CVE-2019-16779.patch
Deleted
@@ -1,67 +0,0 @@ -From 0ca3cd81f43bf250df08a209a9ee709584935600 Mon Sep 17 00:00:00 2001 -From: geemus <geemus@gmail.com> -Date: Mon, 1 Nov 2021 10:20:15 +0800 -Subject: PATCH fix for leftover data with interrupted persistent connections - ---- - lib/excon/connection.rb | 9 ++++++++- - tests/rackups/basic.rb | 8 ++++++++ - 2 files changed, 16 insertions(+), 1 deletion(-) - -diff --git a/lib/excon/connection.rb b/lib/excon/connection.rb -index d27827f..25f89a3 100644 ---- a/lib/excon/connection.rb -+++ b/lib/excon/connection.rb -@@ -252,6 +252,11 @@ module Excon - - datum:connection = self - -+ # cleanup data left behind on persistent connection after interrupt -+ if datum:persistent && !@persistent_socket_reusable -+ reset -+ end -+ - datum:stack = datum:middlewares.map do |middleware| - lambda {|stack| middleware.new(stack)} - end.reverse.inject(self) do |middlewares, middleware| -@@ -260,8 +265,9 @@ module Excon - datum = datum:stack.request_call(datum) - - unless datum:pipeline -+ @persistent_socket_reusable = false - datum = response(datum) -- -+ @persistent_socket_reusable = true - if datum:persistent - if key = datum:response:headers.keys.detect {|k| k.casecmp('Connection') == 0 } - if datum:response:headerskey.casecmp('close') == 0 -@@ -330,6 +336,7 @@ module Excon - if old_socket = sockets.delete(@socket_key) - old_socket.close rescue nil - end -+ @persistent_socket_reusable = true - end - - # Generate HTTP request verb methods -diff --git a/tests/rackups/basic.rb b/tests/rackups/basic.rb -index 0bddd9a..e474a58 100644 ---- a/tests/rackups/basic.rb -+++ b/tests/rackups/basic.rb -@@ -31,6 +31,14 @@ class Basic < Sinatra::Base - get('/echo dirty') do - echo - end -+ -+ get('/foo') do -+ 'foo' -+ end -+ -+ get('/bar') do -+ 'bar' -+ end - - private - --- -2.27.0 -
View file
_service:tar_scm:rubygem-excon-0.62.0-Ruby-2.6-escapes-InvalidURIError-output.patch
Deleted
@@ -1,23 +0,0 @@ -From d92263f73cfb20527ff0d689338bbe5348798d11 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> -Date: Tue, 5 Feb 2019 10:38:33 +0100 -Subject: PATCH Ruby 2.6 escapes InvalidURIError output. - -https://github.com/ruby/ruby/commit/684cdb4f8340f7a88b00bb91139da74b99ec1147 ---- - tests/error_tests.rb | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/error_tests.rb b/tests/error_tests.rb -index c1bf15fe..21d2103b 100644 ---- a/tests/error_tests.rb -+++ b/tests/error_tests.rb -@@ -35,7 +35,7 @@ - Excon.new('http://localhost', path: "foo\r\nbar: baz") - false - rescue => err -- err.to_s.include? "foo\r\nbar: baz" -+ err.to_s.include?(RUBY_VERSION >= '2.6.0' ? 'foo\r\nbar: baz' : "foo\r\nbar: baz") - end - end -
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/rubygem-excon.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:excon-0.62.0.gem/checksums.yaml.gz -> _service:tar_scm:excon-0.104.0.gem/checksums.yaml.gz
Changed
@@ -1,7 +1,7 @@ --- -SHA1: - metadata.gz: ece261b6f71e5d1d196cca01f591d973631ee0f3 - data.tar.gz: 6c4ec564c3ceb6cf87205d2d8430d01a194995bc +SHA256: + metadata.gz: d5178f794971246bbfa44097a97594cb9480a13ff11b9884c1fa1ac79e94c0a6 + data.tar.gz: c5ea1c85e77eddba09b655f18ad415f03eb824481e562ee88c0c756850c61463 SHA512: - metadata.gz: d6e40cc178da6850ce417ba0fce0630a99bb361199c07653a6f6dcefe829373a86af1083d4218b472c94419a1bac2a509083bf577640f1ce59e899759649c726 - data.tar.gz: 131bd06ee001c1246a6b3d720db1e545275146ba886a310d675724a86bd5fef6270c77c196d920c4002cf8661899a9591a00808b3e206ffea1cf4dca45578496 + metadata.gz: 210b6c6ca9be3b3668f9f24c509f95e6a41533c9f0290ccd4a967f92fed1f335f837ce8ff52b8bcc3d5fb3d21d236ed179a67d70df2c8c0202a3772a282c5840 + data.tar.gz: a1cf5fdb74468a879741b482bef3734e74b4c390551cbfbad7762b06bb892877a30255d872c27404ee0e0f137ad208c7fa73b167fb64fdddaffe063e8a3eb5bb
View file
_service:tar_scm:excon-0.62.0.gem/data/CONTRIBUTING.md -> _service:tar_scm:excon-0.104.0.gem/data/CONTRIBUTING.md
Changed
@@ -19,5 +19,4 @@ * Write and help edit documentation(https://github.com/excon/excon.github.com). * Translate documentation(https://github.com/excon/excon.github.com) in to other languages. * Organize or volunteer at events. -* Donate(https://www.gittip.com/geemus/)! * Discuss other ideas for contribution with geemus(mailto:geemus+excon@gmail.com).
View file
_service:tar_scm:excon-0.62.0.gem/data/CONTRIBUTORS.md -> _service:tar_scm:excon-0.104.0.gem/data/CONTRIBUTORS.md
Changed
@@ -1,140 +1,182 @@ -* Aaron Stone <aaron@serendipity.cx> -* Adam Esterline <adam@esterlines.com> -* Alexander Sandström <alexander@skovik.com> -* Andrew Katz <andrew.katz@outright.com> -* Andy Delcambre <adelcambre@gmail.com> -* Anshul Khandelwal <anshul@anshulkhandelwal.com> -* Ash Wilson <smashwilson@gmail.com> -* Ben Burkert <ben@benburkert.com> -* Benedikt Böhm <bb@xnull.de> -* Bo Jeanes <me@bjeanes.com> -* Brandur <brandur@mutelight.org> -* Brian D. Burns <iosctr@gmail.com> -* Brian Hartsock <brian.hartsock@gmail.com> -* Bryan Paxton <starbelly@pobox.com> -* Caio Chassot <dev@caiochassot.com> -* Caius Durling <dev@caius.name> -* Carl Hörberg <carl.hoerberg@gmail.com> -* Carl Hörberg <carl.hoerberg@gmail.com> -* Carlos Sanchez <csanchez@maestrodev.com> -* Casper Thomsen <ct@clearhaus.com> -* Chris Hanks <christopher.m.hanks@gmail.com> -* Claudio Poli <masterkain@gmail.com> -* Damien Mathieu <damien@heroku.com> -* Dan Hensgen <dan@methodhead.com> -* Dan Peterson <dpiddy@gmail.com> -* Dan Prince <dprince@redhat.com> -* Dane Harrigan <dane.harrigan@gmail.com> -* Dave Myron <therealdave.myron@gmail.com> -* Dave Newton <davelnewton@gmail.com> -* David Biehl <dbiehl@ncmedical.com> -* David Biehl <lazylodr@gmail.com> -* Dimitrij Denissenko <dimitrij@blacksquaremedia.com> -* Dominik Richter <dominik.richter@gmail.com> -* Doug McInnes <doug@dougmcinnes.com> -* Eugene Howe <eugene@xtreme-computers.net> -* Evan Phoenix <evan@fallingsnow.net> -* Fabian Wiesel <fabian.wiesel@sap.com> -* Federico Ravasio <ravasio.federico@gmail.com> -* Glenn Pratt <glennpratt@gmail.com> -* Graeme Nelson <graeme.nelson@gmail.com> -* Guillaume Balaine <igosuki@gmail.com> -* Hakan Ensari <hakan.ensari@papercavalier.com> -* Ian Neubert <ian@ianneubert.com> -* Jacob Atzen <jacob@incremental.dk> -* James Cox <james@imaj.es> -* James Watling <watling.james@gmail.com> -* Jean Mertz <jean@mertz.fm> -* Jeremy Hinegardner <jeremy@copiousfreetime.org> -* Jesse Kempf <jesse.kempf@opower.com> -* Joe Rafaniello <jrafanie@redhat.com> -* John Keiser <jkeiser@opscode.com> -* John Leach <john@brightbox.co.uk> -* Jonas Pfenniger <jonas@pfenniger.name> -* Jonathan Dance <github@wuputah.com> -* Jonathan Dance <jd@wuputah.com> -* Jonathan Roes <jroes@jroes.net> -* Joshua B. Smith <jbsmith@us.ibm.com> -* Joshua Gross <joshua@surfeasy.com> -* Joshua Mckinney <joshmckin@gmail.com> -* Joshua Napoli <jnapoli@swipely-napoli.home> -* Joshua Napoli <jnapoli@swipely-napoli.local> -* Kelly Mahan <kmahan@kmahan.com> -* Kensuke Nagae <kyanny@gmail.com> -* Konstantin Shabanov <etehtsea@gmail.com> -* Kyle Rames <kyle.rames@rackspace.com> -* Lewis Marshall <lewis@lmars.net> -* Lincoln Stoll <me@lstoll.net> -* Louis Sobel <sobel@mit.edu> -* Mahemoff <michael@mahemoff.com> -* Mathias Meyer <meyer@paperplanes.de> -* Matt Gauger <matt.gauger@gmail.com> -* Matt Sanders <matt@modal.org> -* Matt Sanders <matt@polycot.com> -* Matt Snyder <snyder2112@me.com> -* Matt Todd <chiology@gmail.com> -* Max Lincoln <max@devopsy.com> -* Michael Brodhead <mkb@engineyard.com> -* Michael Hale <mike@hales.ws> -* Michael Rowe <mrowe@mojain.com> -* Michael Rykov <mrykov@gmail.com> -* Mike Heffner <mikeh@fesnel.com> -* Myron Marston <myron.marston@gmail.com> -* Nathan Long <nathan.long@tma1.com> -* Nathan Sutton <nate@zencoder.com> -* Nick Osborn <nick.osborn@digital.cabinet-office.gov.uk> -* Nicolas Sanguinetti <contacto@nicolassanguinetti.info> -* Paul Gideon Dann <pdgiddie@gmail.com> -* Pavel <pavel.evst@gmail.com> -* Peter Meier <peter.meier@immerda.ch> -* Peter Weldon <peter.weldon@null.net> -* Peter Weldon <peter@lautus.net> -* Phil Ross <phil.ross@gmail.com> -* Richard Ramsden <richard@rramsden.ca> -* Ruslan Korolev <rs3@fastmail.com> -* Ruslan Korolev <rs41@gmx.com> -* Ruslan Kyrychuk <ruslan.kyrychuk@gmail.com> -* Ryan Bigg <radarlistener@fastmail.fm> -* Ryan Mohr <ryan.mohr@gmail.com> -* Sam Withrow <sam.withrow@curiousnation.org> -* Scott Gonyea <me@aitrus.org> -* Scott Gonyea <me@sgonyea.com> -* Scott Walkinshaw <scott.walkinshaw@gmail.com> -* Sean Cribbs <seancribbs@gmail.com> -* Sergio Rubio <rubiojr@frameos.org> -* Shai Rosenfeld <shaiguitar@gmail.com> -* Stefan Merettig <stefan-merettig@nuriaproject.org> -* Stephen Chu <github@stephenchu.com> -* Swanand Pagnis <swanandp@users.noreply.github.com> -* Terry Howe <terrylhowe@gmail.com> -* Thom Mahoney & Josh Lane <tmahoney@engineyard.com> -* Thom May <thom@digital-science.com> -* Tim Carey-Smith <tim@spork.in> -* Todd Lunter <tlunter@gmail.com> -* Tom Maher <tmaher@heroku.com> -* Tom Maher <tmaher@tursom.org> -* Trym Skaar <trym@tryms.no> -* Tuomas Silen <tuomas.silen@nodeta.fi> -* Victor Costan <costan@gmail.com> -* Viven <vivien.schilis@gmail.com> -* Wesley Beary <geemus+github@gmail.com> -* Wesley Beary <geemus@engineyard.com> -* Wesley Beary <geemus@gmail.com> -* Wesley Beary <wbeary@engineyard.com> -* Wesley Beary <wesley@heroku.com> -* Zach Anker <zanker@squareup.com> -* chrisrhoden <carhoden@gmail.com> -* dickeyxxx <jeff@dickeyxxx.com> -* geemus (Wesley Beary) <wbeary@engineyard.com> -* geemus <geemus@gmail.com> -* ggoodale <ggoodale@gmail.com> -* marios <marios@redhat.com> -* mkb <mkb@black-ice.org> -* phiggins <pete@peterhiggins.org> -* rin_ne <rinrin.ne@gmail.com> -* rinrinne <rinrin.ne@gmail.com> -* rkyrychuk <ruslan.kyrychuk@gmail.com> -* sshaw <skye.shaw@gmail.com> -* starbelly <starbelly@pobox.com> -* twrodriguez <tw.rodriguez@gmail.com> -* zimbatm <zimbatm@zimbatm.com> \ No newline at end of file +* Aaron Stone +* Adam Avilla +* Adam Esterline +* Alexander Sandström +* Alexandr Burov +* Andrew Katz +* Andrew Metcalf +* Andrew Sullivan Cant +* André Diego Piske +* Andy Delcambre +* Anshul Khandelwal +* Anton Chuchkalov +* Antonio Terceiro +* Ash Wilson +* Atul Bhosale +* Bart de Water +* Ben Burkert +* Benedikt Böhm +* Bill Mill +* Bo Jeanes +* Brandur +* Brian D. Burns +* Brian Hartsock +* Bryan Paxton +* Caio Chassot +* Caius Durling +* Carl Hörberg +* Carl Hörberg +* Carlos Sanchez +* Casper Thomsen +* Chris Hanks +* Christoph Rieß +* Christophe Taton +* Claudio Poli +* Craig Shannon +* Damien Mathieu +* Dan Hensgen +* Dan Peterson +* Dan Prince +* Dane Harrigan +* Daniel Berger +* Dave Myron +* Dave Newton +* Dave Vasilevsky +* David Biehl +* David Taylor +* Dimitrij Denissenko +* Dominik Richter +* Doug McInnes +* Esteban Pastorino +* Eugene Howe +* Evan Phoenix +* Fabian Wiesel +* Federico Ravasio +* Felix Wolfsteller +* Glenn Pratt +* Graeme Nelson +* Grey Baker
View file
_service:tar_scm:excon-0.62.0.gem/data/LICENSE.md -> _service:tar_scm:excon-0.104.0.gem/data/LICENSE.md
Changed
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2009-2015 CONTRIBUTORS.md(https://github.com/excon/excon/blob/master/CONTRIBUTORS.md) +Copyright (c) 2009-2019 CONTRIBUTORS.md(https://github.com/excon/excon/blob/master/CONTRIBUTORS.md) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
View file
_service:tar_scm:excon-0.62.0.gem/data/README.md -> _service:tar_scm:excon-0.104.0.gem/data/README.md
Changed
@@ -4,27 +4,25 @@ Excon was designed to be simple, fast and performant. It works great as a general HTTP(s) client and is particularly well suited to usage in API clients. -!Build Status(https://travis-ci.org/excon/excon.svg?branch=master)(https://travis-ci.org/excon/excon) -!Dependency Status(https://gemnasium.com/excon/excon.svg)(https://gemnasium.com/excon/excon) +!Build Status(https://github.com/excon/excon/actions/workflows/ruby.yml/badge.svg)(https://github.com/excon/excon/actions/workflows/ruby.yml) !Gem Version(https://badge.fury.io/rb/excon.svg)(https://badge.fury.io/rb/excon) -!Gittip(https://img.shields.io/gittip/geemus.svg)(https://www.gittip.com/geemus/) - -* Getting Started(#getting-started) -* Options(#options) -* Chunked Requests(#chunked-requests) -* Pipelining Requests(#pipelining-requests) -* Streaming Responses(#streaming-responses) -* Proxy Support(#proxy-support) -* Reusable ports(#reusable-ports) -* Unix Socket Support(#unix-socket-support) -* Stubs(#stubs) -* Instrumentation(#instrumentation) -* HTTPS client certificate(#https-client-certificate) -* HTTPS/SSL Issues(#httpsssl-issues) -* Getting Help(#getting-help) -* Contributing(#contributing) -* Plugins and Middlewares(#plugins-and-middlewares) -* License(#license) + +- Getting Started(#getting-started) +- Options(#options) +- Chunked Requests(#chunked-requests) +- Pipelining Requests(#pipelining-requests) +- Streaming Responses(#streaming-responses) +- Proxy Support(#proxy-support) +- Reusable ports(#reusable-ports) +- Unix Socket Support(#unix-socket-support) +- Stubs(#stubs) +- Instrumentation(#instrumentation) +- HTTPS client certificate(#https-client-certificate) +- HTTPS/SSL Issues(#httpsssl-issues) +- Getting Help(#getting-help) +- Contributing(#contributing) +- Plugins and Middlewares(#plugins-and-middlewares) +- License(#license) ## Getting Started @@ -94,7 +92,6 @@ Note that sending a request with `:persistent => false` to close the socket will also send `Connection: close` to inform the server the connection is no longer needed. `Connection#reset` will simply close our end of the socket. - ## Options Both one-off and persistent connections support many other options. The final options for a request are built up by starting with `Excon.defaults`, then merging in options from the connection and finally merging in any request options. In this way you have plenty of options on where and how to set options and can easily setup connections or defaults to match common options for a particular endpoint. @@ -103,7 +100,7 @@ ```ruby # Output debug info, similar to ENV'EXCON_DEBUG' -connection = Excon.new('http://geemus.com/', :debug_request => true, :debug_response => true) +connection = Excon.new('http://geemus.com/', :debug => true) # Custom headers Excon.get('http://geemus.com', :headers => {'Authorization' => 'Basic 0123456789ABCDEF'}) @@ -130,7 +127,39 @@ # expect one or more status codes, or raise an error connection.request(:expects => 200, 201, :method => :get) -# this request can be repeated safely, so retry on errors up to 3 times +# use basic authentication by supplying credentials in the URL or as parameters +connection = Excon.new('http://username:password@secure.geemus.com') +# Note: username & password is unescaped for request, so you should provide escaped values here +# i. e. instead of `password: 'pa%%word'` you should use `password: Excon::Utils.escape_uri('pa%%word')`, +# which return `pa%25%25word` +connection = Excon.new('http://secure.geemus.com', + :user => 'username', :password => 'password') + +# use custom uri parser +require 'addressable/uri' +connection = Excon.new('http://geemus.com/', uri_parser: Addressable::URI) +``` + +Compared to web browsers and other http client libraries, e.g. curl, Excon is a bit more low-level and doesn't assume much by default. If you are seeing different results compared to other clients, the following options might help: + +```ruby +# opt-in to omitting port from http:80 and https:443 +connection = Excon.new('http://geemus.com/', :omit_default_port => true) + +# accept gzip encoding +connection = Excon.new('http://geemus.com/', :headers => { "Accept-Encoding" => "gzip" }) + +# turn off peer verification (less secure) +Excon.defaults:ssl_verify_peer = false +connection = Excon.new('https://...') +``` + +## Timeouts and Retries + +You can modify timeouts and define whether and how many (blocking) retries Excon should attempt if errors occur. + +```ruby +# this request can be repeated safely, so retry on errors up to 4 times connection.request(:idempotent => true) # this request can be repeated safely, retry up to 6 times @@ -140,6 +169,10 @@ # in between each retry connection.request(:idempotent => true, :retry_limit => 6, :retry_interval => 5) +# specify the errors on which to retry (default Timeout, Socket, HTTPStatus) +# only retry on timeouts +connection.request(:idempotent => true, :retry_limit => 6, :retry_interval => 5, :retry_errors => Excon::Error::Timeout ) + # set longer read_timeout (default is 60 seconds) connection.request(:read_timeout => 360) @@ -159,28 +192,20 @@ # opt-out of nonblocking operations for performance and/or as a workaround connection = Excon.new('http://geemus.com/', :nonblock => false) -# use basic authentication by supplying credentials in the URL or as parameters -connection = Excon.new('http://username:password@secure.geemus.com') -connection = Excon.new('http://secure.geemus.com', - :user => 'username', :password => 'password') - -# use custom uri parser -require 'addressable/uri' -connection = Excon.new('http://geemus.com/', uri_parser: Addressable::URI) -``` - -Compared to web browsers and other http client libraries, e.g. curl, Excon is a bit more low-level and doesn't assume much by default. If you are seeing different results compared to other clients, the following options might help: +# DEPRECATED in favour of `resolv_resolver` (see below) +# set up desired dns_timeouts for resolving addresses (default is set by Resolv) +# it accepts an integer or an array of integers for retrying with different timeouts +# see Resolv::DNS#timeouts for more details (https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D) +connection = Excon.new('http://geemus.com/', :dns_timeouts => 3) -```ruby -# opt-in to omitting port from http:80 and https:443 -connection = Excon.new('http://geemus.com/', :omit_default_port => true) - -# accept gzip encoding -connection = Excon.new('http://geemus.com/', :headers => { "Accept-Encoding" => "gzip" }) - -# turn off peer verification (less secure) -Excon.defaults:ssl_verify_peer = false -connection = Excon.new('https://...') +# set a custom resolver for Resolv +# you can use custom nameservers and timeouts +# `timeouts` accepts an integer or an array of integers for retrying with different timeouts +# see Resolv::DNS#timeouts for more details (https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D) +dns_resolver = Resolv::DNS.new(nameserver: '127.0.0.1') +dns_resolver.timeouts = 3 +resolver = Resolv.new(Resolv::Hosts.new, dns_resolver) +connection = Excon.new('http://geemus.com', :resolv_resolver => resolver) ``` ## Chunked Requests @@ -252,7 +277,7 @@ Proxy support must be set when establishing a connection object and cannot be overridden in individual requests. -NOTE: Excon will use the environment variables `http_proxy` and `https_proxy` if they are present. If these variables are set they will take precedence over a :proxy option specified in code. If "https_proxy" is not set, the value of "http_proxy" will be used for both HTTP and HTTPS connections. +NOTE: Excon will use `HTTP_PROXY` and `HTTPS_PROXY` environment variables. If set they will take precedence over any :proxy option specified in code. If "HTTPS_PROXY" is not set, "HTTP_PROXY" will be used for both HTTP and HTTPS connections. To disable this behavior, set the `NO_PROXY` environment variable and other environment variable proxy settings will be disregarded. ## Reusable ports @@ -276,7 +301,7 @@ ## Unix Socket Support -The Unix socket will work for one-off requests and multiuse connections. A Unix socket path must be provided separate from the resource path. +The Unix socket will work for one-off requests and multiuse connections. A Unix socket path must be provided separate from the resource path. ```ruby connection = Excon.new('unix:///', :socket => '/tmp/unicorn.sock') @@ -308,7 +333,19 @@ Excon.stub({}, lambda {|request_params| {:body => request_params:body, :status => 200}}) ``` -Omitted attributes are assumed to match, so this stub will match *any* request and return an Excon::Response with a body of 'body' and status of 200. You can add whatever stubs you might like this way and they will be checked against in the order they were added, if none of them match then excon will raise an `Excon::Errors::StubNotFound` error to let you know. +Omitted attributes are assumed to match, so this stub will match _any_ request and return an Excon::Response with a body of 'body' and status of 200. + +```ruby +Excon.stub({ :scheme => 'https', :host => 'example.com', :path => /\/examples\/\d+/, :port => 443 }, { body: 'body', status: 200 }) +``` + +The above code will stub this: + +```ruby +Excon.get('https://example.com/examples/123', mock: true) +``` + +You can add whatever stubs you might like this way and they will be checked against in the order they were added, if none of them match then excon will raise an `Excon::Errors::StubNotFound` error to let you know. If you want to allow unstubbed requests without raising `StubNotFound`, set the `allow_unstubbed_requests` option either globally or per request. @@ -355,7 +392,7 @@ ) ```
View file
_service:tar_scm:excon-0.62.0.gem/data/data/cacert.pem -> _service:tar_scm:excon-0.104.0.gem/data/data/cacert.pem
Changed
@@ -1,7 +1,7 @@ ## ## Bundle of CA Root Certificates ## -## Certificate data from Mozilla as of: Wed Jun 7 03:12:05 2017 GMT +## Certificate data from Mozilla as of: Tue Aug 22 03:12:04 2023 GMT ## ## This is a bundle of X.509 certificates of public Certificate Authorities ## (CA). These were automatically extracted from Mozilla's root certificates @@ -13,8 +13,8 @@ ## an Apache+mod_ssl webserver for SSL client authentication. ## Just configure this file as the SSLCACertificateFile. ## -## Conversion done with mk-ca-bundle.pl version 1.27. -## SHA256: 93753268e1c596aee21893fb1c6975338389132f15c942ed65fc394a904371d7 +## Conversion done with mk-ca-bundle.pl version 1.29. +## SHA256: 0ff137babc6a5561a9cfbe9f29558972e5b528202681b7d3803d03a3e82922bd ## @@ -39,52 +39,6 @@ X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== -----END CERTIFICATE----- -GlobalSign Root CA - R2 -======================= ------BEGIN CERTIFICATE----- -MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv -YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh -bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT -aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln -bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6 -ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp -s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN -S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL -TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C -ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E -FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i -YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN -BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp -9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu -01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7 -9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 -TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== ------END CERTIFICATE----- - -Verisign Class 3 Public Primary Certification Authority - G3 -============================================================ ------BEGIN CERTIFICATE----- -MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV -UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv -cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl -IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw -CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy -dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv -cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg -Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC -ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1 -EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc -cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw -EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj -055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA -ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f -j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC -/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0 -xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa -t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== ------END CERTIFICATE----- - Entrust.net Premium 2048 Secure Server CA ========================================= -----BEGIN CERTIFICATE----- @@ -130,102 +84,6 @@ RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp -----END CERTIFICATE----- -AddTrust Low-Value Services Root -================================ ------BEGIN CERTIFICATE----- -MIIEGDCCAwCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJTRTEUMBIGA1UEChML -QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEwHwYDVQQDExhBZGRU -cnVzdCBDbGFzcyAxIENBIFJvb3QwHhcNMDAwNTMwMTAzODMxWhcNMjAwNTMwMTAzODMxWjBlMQsw -CQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBO -ZXR3b3JrMSEwHwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQCWltQhSWDia+hBBwzexODcEyPNwTXH+9ZOEQpnXvUGW2ulCDtbKRY6 -54eyNAbFvAWlA3yCyykQruGIgb3WntP+LVbBFc7jJp0VLhD7Bo8wBN6ntGO0/7Gcrjyvd7ZWxbWr -oulpOj0OM3kyP3CCkplhbY0wCI9xP6ZIVxn4JdxLZlyldI+Yrsj5wAYi56xz36Uu+1LcsRVlIPo1 -Zmne3yzxbrww2ywkEtvrNTVokMsAsJchPXQhI2U0K7t4WaPW4XY5mqRJjox0r26kmqPZm9I4XJui -GMx1I4S+6+JNM3GOGvDC+Mcdoq0Dlyz4zyXG9rgkMbFjXZJ/Y/AlyVMuH79NAgMBAAGjgdIwgc8w -HQYDVR0OBBYEFJWxtPCUtr3H2tERCSG+wa9J/RB7MAsGA1UdDwQEAwIBBjAPBgNVHRMBAf8EBTAD -AQH/MIGPBgNVHSMEgYcwgYSAFJWxtPCUtr3H2tERCSG+wa9J/RB7oWmkZzBlMQswCQYDVQQGEwJT -RTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSEw -HwYDVQQDExhBZGRUcnVzdCBDbGFzcyAxIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBACxt -ZBsfzQ3duQH6lmM0MkhHma6X7f1yFqZzR1r0693p9db7RcwpiURdv0Y5PejuvE1Uhh4dbOMXJ0Ph -iVYrqW9yTkkz43J8KiOavD7/KCrto/8cI7pDVwlnTUtiBi34/2ydYB7YHEt9tTEv2dB8Xfjea4MY -eDdXL+gzB2ffHsdrKpV2ro9Xo/D0UrSpUwjP4E/TelOL/bscVjby/rK25Xa71SJlpz/+0WatC7xr -mYbvP33zGDLKe8bjq2RGlfgmadlVg3sslgf/WSxEo8bl6ancoWOAWiFeIc9TVPC6b4nbqKqVz4vj -ccweGyBECMB6tkD9xOQ14R0WHNC8K47Wcdk= ------END CERTIFICATE----- - -AddTrust External Root -====================== ------BEGIN CERTIFICATE----- -MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEUMBIGA1UEChML -QWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYD -VQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEw -NDgzOFowbzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRU -cnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0Eg -Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvtH7xsD821 -+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9uMq/NzgtHj6RQa1wVsfw -Tz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzXmk6vBbOmcZSccbNQYArHE504B4YCqOmo -aSYYkKtMsE8jqzpPhNjfzp/haW+710LXa0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy -2xSoRcRdKn23tNbE7qzNE0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv7 -7+ldU9U0WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYDVR0P -BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0Jvf6xCZU7wO94CTL -VBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRk -VHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB -IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZl -j7DYd7usQWxHYINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 -6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvCNr4TDea9Y355 -e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEXc4g/VhsxOBi0cQ+azcgOno4u -G+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5amnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= ------END CERTIFICATE----- - -AddTrust Public Services Root -============================= ------BEGIN CERTIFICATE----- -MIIEFTCCAv2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJTRTEUMBIGA1UEChML -QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSAwHgYDVQQDExdBZGRU -cnVzdCBQdWJsaWMgQ0EgUm9vdDAeFw0wMDA1MzAxMDQxNTBaFw0yMDA1MzAxMDQxNTBaMGQxCzAJ -BgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5l -dHdvcmsxIDAeBgNVBAMTF0FkZFRydXN0IFB1YmxpYyBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEF -AAOCAQ8AMIIBCgKCAQEA6Rowj4OIFMEg2Dybjxt+A3S72mnTRqX4jsIMEZBRpS9mVEBV6tsfSlbu -nyNu9DnLoblv8n75XYcmYZ4c+OLspoH4IcUkzBEMP9smcnrHAZcHF/nXGCwwfQ56HmIexkvA/X1i -d9NEHif2P0tEs7c42TkfYNVRknMDtABp4/MUTu7R3AnPdzRGULD4EfL+OHn3Bzn+UZKXC1sIXzSG -Aa2Il+tmzV7R/9x98oTaunet3IAIx6eH1lWfl2royBFkuucZKT8Rs3iQhCBSWxHveNCD9tVIkNAw -HM+A+WD+eeSI8t0A65RF62WUaUC6wNW0uLp9BBGo6zEFlpROWCGOn9Bg/QIDAQABo4HRMIHOMB0G -A1UdDgQWBBSBPjfYkrAfd59ctKtzquf2NGAv+jALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB -/zCBjgYDVR0jBIGGMIGDgBSBPjfYkrAfd59ctKtzquf2NGAv+qFopGYwZDELMAkGA1UEBhMCU0Ux -FDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29yazEgMB4G -A1UEAxMXQWRkVHJ1c3QgUHVibGljIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBAAP3FUr4 -JNojVhaTdt02KLmuG7jD8WS6IBh4lSknVwW8fCr0uVFV2ocC3g8WFzH4qnkuCRO7r7IgGRLlk/lL -+YPoRNWyQSW/iHVv/xD8SlTQX/D67zZzfRs2RcYhbbQVuE7PnFylPVoAjgbjPGsye/Kf8Lb93/Ao -GEjwxrzQvzSAlsJKsW2Ox5BF3i9nrEUEo3rcVZLJR2bYGozH7ZxOmuASu7VqTITh4SINhwBk/ox9 -Yjllpu9CtoAlEmEBqCQTcAARJl/6NVDFSMwGR+gn2HCNX2TmoUQmXiLsks3/QppEIW1cxeMiHV9H -EufOX1362KqxMy3ZdvJOOjMMK7MtkAY= ------END CERTIFICATE----- - -AddTrust Qualified Certificates Root -==================================== ------BEGIN CERTIFICATE----- -MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEUMBIGA1UEChML -QWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3b3JrMSMwIQYDVQQDExpBZGRU -cnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcx -CzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQ -IE5ldHdvcmsxIzAhBgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwqxBb/4Oxx -64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G87B4pfYOQnrjfxvM0PC3 -KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i2O+tCBGaKZnhqkRFmhJePp1tUvznoD1o -L/BLcHwTOK28FSXx1s6rosAx1i+f4P8UWfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GR -wVY18BTcZTYJbqukB8c10cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HU -MIHRMB0GA1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0TAQH/ -BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6FrpGkwZzELMAkGA1UE -BhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQLExRBZGRUcnVzdCBUVFAgTmV0d29y -azEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlmaWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQAD -ggEBABmrder4i2VhlRO6aQTvhsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxG -GuoYQ992zPlmhpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X -dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3P6CxB9bpT9ze -RXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9YiQBCYz95OdBEsIJuQRno3eDB -iFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5noxqE= ------END CERTIFICATE----- - Entrust Root Certification Authority ==================================== -----BEGIN CERTIFICATE----- @@ -252,149 +110,6 @@ tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8 -----END CERTIFICATE----- -GeoTrust Global CA -================== ------BEGIN CERTIFICATE----- -MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK -Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw -MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j -LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo -BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet -8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc -T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU -vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD -AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk -DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q -zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4 -d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2 -mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p -XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm -Mw== ------END CERTIFICATE-----
View file
_service:tar_scm:excon-0.62.0.gem/data/excon.gemspec -> _service:tar_scm:excon-0.104.0.gem/data/excon.gemspec
Changed
@@ -1,4 +1,5 @@ -require File.join(File.dirname(__FILE__), 'lib', 'excon', 'version') +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib') +require 'excon/version' Gem::Specification.new do |s| s.name = 'excon' @@ -11,8 +12,13 @@ s.license = 'MIT' s.rdoc_options = "--charset=UTF-8" s.extra_rdoc_files = %wREADME.md CONTRIBUTORS.md CONTRIBUTING.md - s.files = `git ls-files -z`.split("\x0") - s.test_files = s.files.select { |path| path =~ /^spec|tests\/.*_spec|tests\.rb/ } + s.files = `git ls-files -- data/* lib/*`.split("\n") + + "CONTRIBUTING.md", + "CONTRIBUTORS.md", + "LICENSE.md", + "README.md", + "excon.gemspec" + s.add_development_dependency('rspec', '>= 3.5.0') s.add_development_dependency('activesupport') @@ -20,10 +26,19 @@ s.add_development_dependency('eventmachine', '>= 1.0.4') s.add_development_dependency('open4') s.add_development_dependency('rake') - s.add_development_dependency('rdoc') s.add_development_dependency('shindo') s.add_development_dependency('sinatra') s.add_development_dependency('sinatra-contrib') s.add_development_dependency('json', '>= 1.8.5') s.add_development_dependency('puma') + s.add_development_dependency('webrick') + + s.metadata = { + 'homepage_uri' => 'https://github.com/excon/excon', + 'bug_tracker_uri' => 'https://github.com/excon/excon/issues', + 'changelog_uri' => 'https://github.com/excon/excon/blob/master/changelog.txt', + 'documentation_uri' => 'https://github.com/excon/excon/blob/master/README.md', + 'source_code_uri' => 'https://github.com/excon/excon', + 'wiki_uri' => 'https://github.com/excon/excon/wiki' + } end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon.rb
Changed
@@ -23,11 +23,11 @@ require 'excon/middlewares/mock' require 'excon/middlewares/response_parser' +require 'excon/error' require 'excon/constants' require 'excon/utils' require 'excon/connection' -require 'excon/error' require 'excon/headers' require 'excon/response' require 'excon/middlewares/decompress' @@ -61,6 +61,14 @@ if $VERBOSE || ENV'EXCON_DEBUG' $stderr.puts "exconWARNING #{warning}\n#{ caller.join("\n") }" end + + if @raise_on_warnings + raise Error::Warning.new(warning) + end + end + + def set_raise_on_warnings!(should_raise) + @raise_on_warnings = should_raise end # Status of mocking @@ -105,9 +113,9 @@ # @see Connection#initialize # Initializes a new keep-alive session for a given remote host - # @param String url The destination URL - # @param Hash<Symbol, > params One or more option params to set on the Connection instance - # @return Connection A new Excon::Connection instance + # @param String url The destination URL + # @param Hash<Symbol, > params One or more option params to set on the Connection instance + # @return Connection A new Excon::Connection instance def new(url, params = {}) uri_parser = params:uri_parser || defaults:uri_parser uri = uri_parser.parse(url) @@ -135,13 +143,13 @@ end # push an additional stub onto the list to check for mock requests - # @param Hash<Symbol, > request params to match against, omitted params match all - # @param Hash<Symbol, > response params to return from matched request or block to call with params - def stub(request_params = {}, response_params = nil) - if method = request_params.delete(:method) + # @param request_params Hash<Symbol, > request params to match against, omitted params match all + # @param response_params Hash<Symbol, > response params to return from matched request or block to call with params + def stub(request_params = {}, response_params = nil, &block) + if (method = request_params.delete(:method)) request_params:method = method.to_s.downcase.to_sym end - if url = request_params.delete(:url) + if (url = request_params.delete(:url)) uri = URI.parse(url) request_params = { :host => uri.host, @@ -167,7 +175,7 @@ if response_params raise(ArgumentError.new("stub requires either response_params OR a block")) else - stub = request_params, Proc.new + stub = request_params, block end elsif response_params stub = request_params, response_params @@ -179,10 +187,10 @@ end # get a stub matching params or nil - # @param Hash<Symbol, > request params to match against, omitted params match all - # @return Hash<Symbol, > response params to return from matched request or block to call with params + # @param request_params Hash<Symbol, > request params to match against, omitted params match all + # @return Hash<Symbol, > response params to return from matched request or block to call with params def stub_for(request_params={}) - if method = request_params.delete(:method) + if (method = request_params.delete(:method)) request_params:method = method.to_s.downcase.to_sym end Excon.stubs.each do |stub, response_params| @@ -190,8 +198,13 @@ headers_match = !stub.has_key?(:headers) || stub:headers.keys.all? do |key| case value = stub:headerskey when Regexp - if match = value.match(request_params:headerskey) - captures:headerskey = match.captures + case request_params:headerskey + when String + if (match = value.match(request_params:headerskey)) + captures:headerskey = match.captures + end + when Regexp # for unstub on regex params + match = (value == request_params:headerskey) end match else @@ -201,8 +214,13 @@ non_headers_match = (stub.keys - :headers).all? do |key| case value = stubkey when Regexp - if match = value.match(request_paramskey) - captureskey = match.captures + case request_paramskey + when String + if (match = value.match(request_paramskey)) + captureskey = match.captures + end + when Regexp # for unstub on regex params + match = (value == request_paramskey) end match else @@ -227,12 +245,13 @@ end end - # remove first/oldest stub matching request_params - # @param Hash<Symbol, > request params to match against, omitted params match all - # @return Hash<Symbol, > response params from deleted stub + # remove first/oldest stub matching request_params or nil if none match + # @param request_params Hash<Symbol, > request params to match against, omitted params match all + # @return Hash<Symbol, > response params from deleted stub def unstub(request_params = {}) - stub = stub_for(request_params) - Excon.stubs.delete_at(Excon.stubs.index(stub)) + if (stub = stub_for(request_params)) + Excon.stubs.delete_at(Excon.stubs.index(stub)) + end end # Generic non-persistent HTTP methods
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/connection.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/connection.rb
Changed
@@ -1,4 +1,6 @@ # frozen_string_literal: true +require 'ipaddr' + module Excon class Connection include Utils @@ -38,28 +40,29 @@ end end def logger=(logger) - Excon::LoggingInstrumentor.logger = logger @data:instrumentor = Excon::LoggingInstrumentor + @data:logger = logger end # Initializes a new Connection instance - # @param Hash<Symbol, > params One or more optional params - # @option params String :body Default text to be sent over a socket. Only used if :body absent in Connection#request params - # @option params Hash<Symbol, String> :headers The default headers to supply in a request. Only used if params:headers is not supplied to Connection#request - # @option params String :host The destination host's reachable DNS name or IP, in the form of a String. IPv6 addresses must be wrapped (e.g. ::1). See URI#host. - # @option params String :hostname Same as host, but usable for socket connections. IPv6 addresses must not be wrapped (e.g. ::1). See URI#hostname. - # @option params String :path Default path; appears after 'scheme://host:port/'. Only used if params:path is not supplied to Connection#request - # @option params Fixnum :port The port on which to connect, to the destination host - # @option params Hash :query Default query; appended to the 'scheme://host:port/path/' in the form of '?key=value'. Will only be used if params:query is not supplied to Connection#request - # @option params String :scheme The protocol; 'https' causes OpenSSL to be used - # @option params String :socket The path to the unix socket (required for 'unix://' connections) - # @option params String :ciphers Only use the specified SSL/TLS cipher suites; use OpenSSL cipher spec format e.g. 'HIGH:!aNULL:!3DES' or 'AES256-SHA:DES-CBC3-SHA' - # @option params String :proxy Proxy server; e.g. 'http://myproxy.com:8888' - # @option params Fixnum :retry_limit Set how many times we'll retry a failed request. (Default 4) - # @option params Fixnum :retry_interval Set how long to wait between retries. (Default 0) - # @option params Class :instrumentor Responds to #instrument as in ActiveSupport::Notifications - # @option params String :instrumentor_name Name prefix for #instrument events. Defaults to 'excon' + # @param Hash<Symbol, > params One or more optional params + # @option params String :body Default text to be sent over a socket. Only used if :body absent in Connection#request params + # @option params Hash<Symbol, String> :headers The default headers to supply in a request. Only used if params:headers is not supplied to Connection#request + # @option params String :host The destination host's reachable DNS name or IP, in the form of a String. IPv6 addresses must be wrapped (e.g. ::1). See URI#host. + # @option params String :hostname Same as host, but usable for socket connections. IPv6 addresses must not be wrapped (e.g. ::1). See URI#hostname. + # @option params String :path Default path; appears after 'scheme://host:port/'. Only used if params:path is not supplied to Connection#request + # @option params Fixnum :port The port on which to connect, to the destination host + # @option params Hash :query Default query; appended to the 'scheme://host:port/path/' in the form of '?key=value'. Will only be used if params:query is not supplied to Connection#request + # @option params String :scheme The protocol; 'https' causes OpenSSL to be used + # @option params String :socket The path to the unix socket (required for 'unix://' connections) + # @option params String :ciphers Only use the specified SSL/TLS cipher suites; use OpenSSL cipher spec format e.g. 'HIGH:!aNULL:!3DES' or 'AES256-SHA:DES-CBC3-SHA' + # @option params String :proxy Proxy server; e.g. 'http://myproxy.com:8888' + # @option params Fixnum :retry_limit Set how many times we'll retry a failed request. (Default 4) + # @option params Fixnum :retry_interval Set how long to wait between retries. (Default 0) + # @option params Class :instrumentor Responds to #instrument as in ActiveSupport::Notifications + # @option params String :instrumentor_name Name prefix for #instrument events. Defaults to 'excon' def initialize(params = {}) + @pid = Process.pid @data = Excon.defaults.dup # merge does not deep-dup, so make sure headers is not the original @data:headers = @data:headers.dup @@ -67,12 +70,17 @@ # the same goes for :middlewares @data:middlewares = @data:middlewares.dup - params = validate_params(:connection, params) @data.merge!(params) + validate_params(:connection, @data, @data:middlewares) + + if @data.key?(:host) && !@data.key?(:hostname) + Excon.display_warning('hostname is missing! For IPv6 support, provide both host and hostname: Excon::Connection#new(:host => uri.host, :hostname => uri.hostname, ...).') + @data:hostname = @data:host + end setup_proxy - if ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR') + if ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR') @data:instrumentor = Excon::StandardInstrumentor end @@ -82,7 +90,9 @@ end if @data:scheme == UNIX - if @data:host + # 'uri' >= v0.12.0 returns an empty string instead of nil for no host. + # So treat the parameter as present if and only if it is both non-nill and non-empty. + if @data:host && !@data:host.empty? raise ArgumentError, "The `:host` parameter should not be set for `unix://` connections.\n" + "When supplying a `unix://` URI, it should start with `unix:/` or `unix:///`." elsif !@data:socket @@ -108,7 +118,7 @@ # we already have data from a middleware, so bail return datum else - socket.data = datum + socket(datum).data = datum # start with "METHOD /path" request = datum:method.to_s.upcase + ' ' if datum:proxy && datum:scheme != HTTPS @@ -137,31 +147,25 @@ end # add headers to request - datum:headers.each do |key, values| - values.flatten.each do |value| - request << key.to_s << ': ' << value.to_s << CR_NL - end - end + request << Utils.headers_hash_to_s(datum:headers) # add additional "\r\n" to indicate end of headers request << CR_NL if datum.has_key?(:request_block) - socket.write(request) # write out request + headers + socket(datum).write(request) # write out request + headers while true # write out body with chunked encoding chunk = datum:request_block.call - if FORCE_ENC - chunk.force_encoding('BINARY') - end + chunk = binary_encode(chunk) if chunk.length > 0 - socket.write(chunk.length.to_s(16) << CR_NL << chunk << CR_NL) + socket(datum).write(chunk.length.to_s(16) << CR_NL << chunk << CR_NL) else - socket.write(String.new("0#{CR_NL}#{CR_NL}")) + socket(datum).write(String.new("0#{CR_NL}#{CR_NL}")) break end end elsif body.nil? - socket.write(request) # write out request + headers + socket(datum).write(request) # write out request + headers else # write out body if body.respond_to?(:binmode) && !body.is_a?(StringIO) body.binmode @@ -171,28 +175,29 @@ end # if request + headers is less than chunk size, fill with body - if FORCE_ENC - request.force_encoding('BINARY') - end + request = binary_encode(request) chunk = body.read(datum:chunk_size - request.length, 0.max) if chunk - if FORCE_ENC - chunk.force_encoding('BINARY') - end - socket.write(request << chunk) + chunk = binary_encode(chunk) + socket(datum).write(request << chunk) else - socket.write(request) # write out request + headers + socket(datum).write(request) # write out request + headers end - while chunk = body.read(datum:chunk_size) - socket.write(chunk) + while (chunk = body.read(datum:chunk_size)) + socket(datum).write(chunk) end end end rescue => error case error - when Excon::Errors::StubNotFound, Excon::Errors::Timeout + when Excon::Errors::InvalidHeaderKey, Excon::Errors::InvalidHeaderValue, Excon::Errors::StubNotFound, Excon::Errors::Timeout raise(error) + when Errno::EPIPE + # Read whatever remains in the pipe to aid in debugging + response = socket.read + error = Excon::Error.new(response + error.message) + raise_socket_error(error) else raise_socket_error(error) end @@ -216,29 +221,46 @@ end # Sends the supplied request to the destination host. - # @yield chunk @see Response#self.parse - # @param Hash<Symbol, > params One or more optional params, override defaults set in Connection.new - # @option params String :body text to be sent over a socket - # @option params Hash<Symbol, String> :headers The default headers to supply in a request - # @option params String :path appears after 'scheme://host:port/' - # @option params Hash :query appended to the 'scheme://host:port/path/' in the form of '?key=value' + # @yield chunk @see Response#self.parse + # @param Hash<Symbol, > params One or more optional params, override defaults set in Connection.new + # @option params String :body text to be sent over a socket + # @option params Hash<Symbol, String> :headers The default headers to supply in a request + # @option params String :path appears after 'scheme://host:port/' + # @option params Hash :query appended to the 'scheme://host:port/path/' in the form of '?key=value' def request(params={}, &block) - params = validate_params(:request, params) # @data has defaults, merge in new params to override datum = @data.merge(params) datum:headers = @data:headers.merge(datum:headers || {}) + validate_params(:request, params, datum:middlewares) + # If the user passed in new middleware, we want to validate that the original connection parameters + # are still valid with the provided middleware. + if params:middlewares + validate_params(:connection, @data, datum:middlewares)
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/constants.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/constants.rb
Changed
@@ -12,8 +12,16 @@ CHUNK_SIZE = DEFAULT_CHUNK_SIZE end + DEFAULT_REDIRECT_LIMIT = 10 + DEFAULT_RETRY_LIMIT = 4 + DEFAULT_RETRY_ERRORS = + Excon::Error::Timeout, + Excon::Error::Socket, + Excon::Error::HTTPStatus + + FORCE_ENC = CR_NL.respond_to?(:force_encoding) HTTP_1_1 = " HTTP/1.1\r\n" @@ -33,29 +41,28 @@ VERSIONS = "#{USER_AGENT} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}" VALID_REQUEST_KEYS = + :allow_unstubbed_requests, :body, - :captures, :chunk_size, :debug_request, :debug_response, - :expects, + :dns_timeouts, :headers, - :idempotent, - :instrumentor, - :instrumentor_name, + :instrumentor, # Used for setting logging within Connection + :logger, :method, :middlewares, - :mock, + :password, :path, :persistent, :pipeline, :query, :read_timeout, :request_block, + :resolv_resolver, :response_block, - :retries_remaining, # used internally - :retry_limit, - :retry_interval, + :stubs, + :user, :versions, :write_timeout @@ -67,6 +74,8 @@ :client_key_pass, :client_cert, :client_cert_data, + :client_chain, + :client_chain_data, :certificate, :certificate_path, :disable_proxy, @@ -74,12 +83,12 @@ :private_key_path, :connect_timeout, :family, + :keepalive, :host, :hostname, :omit_default_port, :nonblock, :reuseaddr, - :password, :port, :proxy, :scheme, @@ -90,13 +99,30 @@ :ssl_verify_callback, :ssl_verify_peer, :ssl_verify_peer_host, + :ssl_verify_hostname, :ssl_version, + :ssl_min_version, + :ssl_max_version, + :ssl_security_level, + :ssl_proxy_headers, + :ssl_uri_schemes, :tcp_nodelay, :thread_safe_sockets, :uri_parser, - :user + DEPRECATED_VALID_REQUEST_KEYS = { + :captures => 'Mock', + :expects => 'Expects', + :idempotent => 'Idempotent', + :instrumentor_name => 'Instrumentor', + :mock => 'Mock', + :retries_remaining => 'Idempotent', # referenced in Instrumentor, but only relevant with Idempotent + :retry_errors => 'Idempotent', + :retry_interval => 'Idempotent', + :retry_limit => 'Idempotent' # referenced in Instrumentor, but only relevant with Idempotent + } + unless ::IO.const_defined?(:WaitReadable) class ::IO module WaitReadable; end @@ -110,38 +136,44 @@ end # these come last as they rely on the above DEFAULTS = { - :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE, + :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE, # see https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29 - :ciphers => 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS', - :connect_timeout => 60, - :debug_request => false, - :debug_response => false, - :headers => { - 'User-Agent' => USER_AGENT + # list provided then had DES related things sorted to the end + :ciphers => 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS', + :connect_timeout => 60, + :debug_request => false, + :debug_response => false, + :dns_timeouts => nil, + # nil allows Resolv::DNS to set its default timeouts value (see https://ruby-doc.org/3.2.2/stdlibs/resolv/Resolv/DNS.html#method-i-timeouts-3D) + :headers => { + 'User-Agent' => USER_AGENT, + 'Accept' => '*/*' }, - :idempotent => false, - :instrumentor_name => 'excon', - :middlewares => + :idempotent => false, + :instrumentor_name => 'excon', + :middlewares => Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock , - :mock => false, - :nonblock => true, - :omit_default_port => false, - :persistent => false, - :read_timeout => 60, - :retry_limit => DEFAULT_RETRY_LIMIT, - :ssl_verify_peer => true, - :ssl_uri_schemes => HTTPS, - :stubs => :global, - :tcp_nodelay => false, - :thread_safe_sockets => true, - :uri_parser => URI, - :versions => VERSIONS, - :write_timeout => 60 + :mock => false, + :nonblock => true, + :omit_default_port => false, + :persistent => false, + :read_timeout => 60, + :resolv_resolver => nil, + :retry_errors => DEFAULT_RETRY_ERRORS, + :retry_limit => DEFAULT_RETRY_LIMIT, + :ssl_verify_peer => true, + :ssl_uri_schemes => HTTPS, + :stubs => :global, + :tcp_nodelay => false, + :thread_safe_sockets => true, + :uri_parser => URI, + :versions => VERSIONS, + :write_timeout => 60 } end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/error.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/error.rb
Changed
@@ -6,6 +6,7 @@ class StubNotFound < Error; end class InvalidStub < Error; end + class Warning < Error; end # Socket related errors class Socket < Error @@ -45,9 +46,23 @@ end end + class InvalidHeaderKey < Error; end + class InvalidHeaderValue < Error; end class Timeout < Error; end class ResponseParse < Error; end + + class ProxyConnectionError < Error + attr_reader :request, :response + + def initialize(msg, request = nil, response = nil) + super(msg) + @request = request + @response = response + end + end + class ProxyParse < Error; end + class TooManyRedirects < Error; end # Base class for HTTP Error classes class HTTPStatus < Error
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/headers.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/headers.rb
Changed
@@ -22,6 +22,7 @@ alias_method :raw_values_at, :values_at def initialize + super @downcased = {} end @@ -29,11 +30,11 @@ @downcasedkey.to_s.downcase end - alias_method :=, :store def =(key, value) raw_writer(key, value) @downcasedkey.to_s.downcase = value end + alias_method :store, := if SENTINEL.respond_to? :assoc def assoc(obj) @@ -54,11 +55,11 @@ end end - alias_method :has_key?, :key? - alias_method :has_key?, :member? def has_key?(key) raw_key?(key) || @downcased.has_key?(key.to_s.downcase) end + alias_method :key?, :has_key? + alias_method :member?, :has_key? def merge(other_hash) self.dup.merge!(other_hash)
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/instrumentors/logging_instrumentor.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/instrumentors/logging_instrumentor.rb
Changed
@@ -2,23 +2,12 @@ module Excon class LoggingInstrumentor - # Returns the Logger object for the LoggingInstrumentor. If one doesn't - # already exist, then one will be created using $stderr as the output - # stream. - # - def self.logger - @logger ||= Logger.new($stderr) - end - - # Sets the logger object for the LoggingInstrumentor. - # - def self.logger=(logger) - @logger = logger - end - def self.instrument(name, params = {}, &block) + def self.instrument(name, params = {}) params = params.dup + logger = params:logger || Logger.new($stderr) + # reduce duplication/noise of output params.delete(:connection) params.delete(:stack) @@ -39,7 +28,7 @@ info << "?" if params:query.is_a?(Hash) - info << params.to_a.map{ |key,value| "#{key}=#{value}" }.join('&') + info << params:query.to_a.map { |key,value| "#{key}=#{value}" }.join('&') else info << params:query end @@ -51,7 +40,7 @@ end end - self.logger.log(logger.level, info) if info + logger.info(info) if info yield if block_given? end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/instrumentors/standard_instrumentor.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/instrumentors/standard_instrumentor.rb
Changed
@@ -1,21 +1,14 @@ # frozen_string_literal: true module Excon class StandardInstrumentor - def self.instrument(name, params = {}, &block) + def self.instrument(name, params = {}) params = params.dup # reduce duplication/noise of output params.delete(:connection) params.delete(:stack) - if params.has_key?(:headers) && params:headers.has_key?('Authorization') - params:headers = params:headers.dup - params:headers'Authorization' = REDACTED - end - - if params.has_key?(:password) - params:password = REDACTED - end + params = Utils.redact(params) $stderr.puts(name) Excon::PrettyPrinter.pp($stderr, params)
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/base.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/base.rb
Changed
@@ -2,6 +2,12 @@ module Excon module Middleware class Base + # Returns the list of parameters that this middleware uses that are valid + # as arguments to `Connection#request` or `Connection#new`. + def self.valid_parameter_keys + + end + def initialize(stack) @stack = stack end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/capture_cookies.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/capture_cookies.rb
Changed
@@ -8,7 +8,7 @@ end def get_header(datum, header) - _, header_value = datum:response:headers.detect do |key, value| + _, header_value = datum:response:headers.detect do |key, _| key.casecmp(header) == 0 end header_value
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/decompress.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/decompress.rb
Changed
@@ -2,6 +2,10 @@ module Excon module Middleware class Decompress < Excon::Middleware::Base + + INFLATE_ZLIB_OR_GZIP = 47 # Zlib::MAX_WBITS + 32 + INFLATE_RAW = -15 # Zlib::MAX_WBITS * -1 + def request_call(datum) unless datum.has_key?(:response_block) key = datum:headers.keys.detect {|k| k.to_s.casecmp('Accept-Encoding') == 0 } || 'Accept-Encoding' @@ -15,12 +19,15 @@ def response_call(datum) body = datum:response:body unless datum.has_key?(:response_block) || body.nil? || body.empty? - if key = datum:response:headers.keys.detect {|k| k.casecmp('Content-Encoding') == 0 } + if (key = datum:response:headers.keys.detect {|k| k.casecmp('Content-Encoding') == 0 }) encodings = Utils.split_header_value(datum:response:headerskey) - if encoding = encodings.last + if (encoding = encodings.last) if encoding.casecmp('deflate') == 0 - # assume inflate omits header - datum:response:body = Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(body) + datum:response:body = begin + Zlib::Inflate.new(INFLATE_ZLIB_OR_GZIP).inflate(body) + rescue Zlib::DataError # fallback to raw on error + Zlib::Inflate.new(INFLATE_RAW).inflate(body) + end encodings.pop elsif encoding.casecmp('gzip') == 0 || encoding.casecmp('x-gzip') == 0 datum:response:body = Zlib::GzipReader.new(StringIO.new(body)).read
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/expects.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/expects.rb
Changed
@@ -2,11 +2,17 @@ module Excon module Middleware class Expects < Excon::Middleware::Base + def self.valid_parameter_keys + + :expects + + end + def response_call(datum) if datum.has_key?(:expects) && !*datum:expects.include?(datum:response:status) raise( Excon::Errors.status_error( - datum.reject {|key,value| key == :response}, + datum.reject {|key,_| key == :response}, Excon::Response.new(datum:response) ) )
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/idempotent.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/idempotent.rb
Changed
@@ -1,7 +1,24 @@ # frozen_string_literal: true +require 'set' + module Excon module Middleware class Idempotent < Excon::Middleware::Base + def self.valid_parameter_keys + + :idempotent, + :retries_remaining, + :retry_errors, + :retry_interval, + :retry_limit + + end + + def request_call(datum) + datum:retries_remaining ||= datum:retry_limit + @stack.request_call(datum) + end + def error_call(datum) if datum:idempotent if datum.has_key?(:request_block) @@ -21,15 +38,15 @@ end end - if datum:idempotent && Excon::Errors::Timeout, Excon::Errors::SocketError, - Excon::Errors::HTTPStatusError.any? {|ex| datum:error.kind_of?(ex) } && datum:retries_remaining > 1 + if datum:idempotent && datum:retry_errors.any? {|ex| datum:error.kind_of?(ex) } && datum:retries_remaining > 1 sleep(datum:retry_interval) if datum:retry_interval # reduces remaining retries, reset connection, and restart request_call datum:retries_remaining -= 1 connection = datum.delete(:connection) - datum.reject! {|key, _| !Excon::VALID_REQUEST_KEYS.include?(key) } + valid_keys = Set.new(connection.valid_request_keys(datum:middlewares)) + datum.select! {|key, _| valid_keys.include?(key) } connection.request(datum) else @stack.error_call(datum)
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/instrumentor.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/instrumentor.rb
Changed
@@ -2,6 +2,14 @@ module Excon module Middleware class Instrumentor < Excon::Middleware::Base + def self.valid_parameter_keys + + :logger, + :instrumentor, + :instrumentor_name + + end + def error_call(datum) if datum.has_key?(:instrumentor) datum:instrumentor.instrument("#{datum:instrumentor_name}.error", :error => datum:error) do
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/mock.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/mock.rb
Changed
@@ -2,6 +2,14 @@ module Excon module Middleware class Mock < Excon::Middleware::Base + def self.valid_parameter_keys + + :allow_unstubbed_requests, + :captures, + :mock + + end + def request_call(datum) if datum:mock # convert File/Tempfile body to string before matching: @@ -17,12 +25,13 @@ raise Excon::Errors::InvalidStub.new("Request body should be a string or an IO object. #{datum:body.class} provided") end - if stub = Excon.stub_for(datum) + if (stub = Excon.stub_for(datum)) + datum:remote_ip ||= '127.0.0.1' datum:response = { :body => '', :headers => {}, :status => 200, - :remote_ip => '127.0.0.1' + :remote_ip => datum:remote_ip } stub_datum = case stub.last @@ -32,7 +41,7 @@ stub.last end - datum:response.merge!(stub_datum.reject {|key,value| key == :headers}) + datum:response.merge!(stub_datum.reject {|key,_| key == :headers}) if stub_datum.has_key?(:headers) datum:response:headers.merge!(stub_datum:headers) end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/redirect_follower.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/redirect_follower.rb
Changed
@@ -2,9 +2,21 @@ module Excon module Middleware class RedirectFollower < Excon::Middleware::Base + def self.valid_parameter_keys + + :redirects_remaining, + :redirect_limit + + end + + def request_call(datum) + datum:redirects_remaining ||= datum:redirect_limit || + Excon::DEFAULT_REDIRECT_LIMIT + @stack.request_call(datum) + end def get_header(datum, header) - _, header_value = datum:response:headers.detect do |key, value| + _, header_value = datum:response:headers.detect do |key, _| key.casecmp(header) == 0 end header_value @@ -14,14 +26,21 @@ if datum.has_key?(:response) case datum:response:status when 301, 302, 303, 307, 308 + if datum:redirects_remaining <= 0 + raise Excon::Errors::TooManyRedirects + end + + datum:redirects_remaining -= 1 + uri_parser = datum:uri_parser || Excon.defaults:uri_parser location = get_header(datum, 'Location') base_uri = Excon::Utils.request_uri(datum) uri = uri_parser.join(base_uri, location) - # delete old/redirect response + # delete old/redirect response and remote_ip response = datum.delete(:response) + datum.delete(:remote_ip) params = datum.dup params.delete(:connection) @@ -52,7 +71,10 @@ params.merge!(:password => Utils.unescape_uri(uri.password)) if uri.password response = Excon::Connection.new(params).request - datum.merge!({:response => response.data}) + datum.merge!({ + :remote_ip => response.remote_ip, + :response => response.data + }) else @stack.response_call(datum) end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/middlewares/response_parser.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/middlewares/response_parser.rb
Changed
@@ -6,6 +6,9 @@ unless datum.has_key?(:response) datum = Excon::Response.parse(datum:connection.send(:socket), datum) end + if datum.has_key?(:logger) + datum:response:logger = datum:logger + end @stack.response_call(datum) end end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/pretty_printer.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/pretty_printer.rb
Changed
@@ -9,14 +9,7 @@ datum.delete(:connection) datum.delete(:stack) - if datum.has_key?(:headers) && datum:headers.has_key?('Authorization') - datum:headers = datum:headers.dup - datum:headers'Authorization' = REDACTED - end - - if datum.has_key?(:password) - datum:password = REDACTED - end + datum = Utils.redact(datum) end indent += 2
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/response.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/response.rb
Changed
@@ -20,15 +20,24 @@ def host @data:host end + def scheme + @data:scheme + end def local_address @data:local_address end def local_port @data:local_port end + def http_method # can't be named "method" + @data:method + end def path @data:path end + def query + @data:query + end def port @data:port end @@ -59,19 +68,26 @@ def self.parse(socket, datum) # this will discard any trailing lines from the previous response if any. - begin + line = nil + loop do line = socket.readline - end until status = line9, 3.to_i + break if line9,3.to_i != 0 + end + status = line9, 3.to_i reason_phrase = line13..-3 # -3 strips the trailing "\r\n" datum:response = { :body => String.new, :cookies => , :host => datum:host, + :scheme => datum:scheme, + :method => datum:method, :headers => Excon::Headers.new, :path => datum:path, + :query => datum:query, :port => datum:port, + :omit_default_port => datum:omit_default_port, :status => status, :status_line => line, :reason_phrase => reason_phrase @@ -90,7 +106,7 @@ unless ('HEAD', 'CONNECT'.include?(datum:method.to_s.upcase)) || NO_ENTITY.include?(datum:response:status) - if key = datum:response:headers.keys.detect {|k| k.casecmp('Transfer-Encoding') == 0 } + if (key = datum:response:headers.keys.detect {|k| k.casecmp('Transfer-Encoding') == 0 }) encodings = Utils.split_header_value(datum:response:headerskey) if (encoding = encodings.last) && encoding.casecmp('chunked') == 0 transfer_encoding_chunked = true @@ -103,7 +119,7 @@ end # use :response_block unless :expects would fail - if response_block = datum:response_block + if (response_block = datum:response_block) if datum:middlewares.include?(Excon::Middleware::Expects) && datum:expects && !Array(datum:expects).include?(datum:response:status) response_block = nil @@ -140,11 +156,11 @@ end parse_headers(socket, datum) # merge trailers into headers else - if key = datum:response:headers.keys.detect {|k| k.casecmp('Content-Length') == 0 } + if (key = datum:response:headers.keys.detect {|k| k.casecmp('Content-Length') == 0 }) content_length = datum:response:headerskey.to_i end - if remaining = content_length + if (remaining = content_length) if response_block while remaining > 0 chunk = socket.read(datum:chunk_size, remaining.min) || raise(EOFError) @@ -160,11 +176,11 @@ end else if response_block - while chunk = socket.read(datum:chunk_size) + while (chunk = socket.read(datum:chunk_size)) response_block.call(chunk, nil, nil) end else - while chunk = socket.read(datum:chunk_size) + while (chunk = socket.read(datum:chunk_size)) datum:response:body << chunk end end @@ -222,7 +238,7 @@ end # Retrieve a specific header value. Header names are treated case-insensitively. - # @param String name Header name + # @param String name Header name def get_header(name) headersname end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/socket.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/socket.rb
Changed
@@ -1,4 +1,6 @@ # frozen_string_literal: true +require 'resolv' + module Excon class Socket include Utils @@ -7,6 +9,23 @@ attr_accessor :data + # read/write drawn from https://github.com/ruby-amqp/bunny/commit/75d9dd79551b31a5dd3d1254c537bad471f108cf + CONNECT_RETRY_EXCEPTION_CLASSES = if defined?(IO::EINPROGRESSWaitWritable) # Ruby >= 2.1 + Errno::EINPROGRESS, IO::EINPROGRESSWaitWritable + else # Ruby <= 2.0 + Errno::EINPROGRESS + end + READ_RETRY_EXCEPTION_CLASSES = if defined?(IO::EAGAINWaitReadable) # Ruby >= 2.1 + Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable, IO::EAGAINWaitReadable, IO::EWOULDBLOCKWaitReadable + else # Ruby <= 2.0 + Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable + end + WRITE_RETRY_EXCEPTION_CLASSES = if defined?(IO::EAGAINWaitWritable) # Ruby >= 2.1 + Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable, IO::EAGAINWaitWritable, IO::EWOULDBLOCKWaitWritable + else # Ruby <= 2.0 + Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable + end + def params Excon.display_warning('Excon::Socket#params is deprecated use Excon::Socket#data instead.') @data @@ -21,12 +40,14 @@ def_delegators(:@socket, :close) + def initialize(data = {}) @data = data @nonblock = data:nonblock @port ||= @data:port || 80 @read_buffer = String.new @eof = false + @backend_eof = false connect end @@ -41,29 +62,31 @@ end def readline - return legacy_readline if RUBY_VERSION.to_f <= 1.8_7 - buffer = String.new - begin - buffer << @socket.read_nonblock(1) while buffer-1 != "\n" - buffer - rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable - select_with_timeout(@socket, :read) && retry - rescue OpenSSL::SSL::SSLError => error - if error.message == 'read would block' - select_with_timeout(@socket, :read) && retry - else - raise(error) + if @nonblock + result = String.new + block = @read_buffer + @read_buffer = String.new + + loop do + idx = block.index("\n") + if idx.nil? + result << block + else + result << block.slice!(0, idx+1) + add_to_read_buffer(block) + break + end + block = read_nonblock(@data:chunk_size) || raise(EOFError) end - end - end - - def legacy_readline - begin - Timeout.timeout(@data:read_timeout) do - @socket.readline + result + else # nonblock/legacy + begin + Timeout.timeout(@data:read_timeout) do + @socket.readline + end + rescue Timeout::Error + raise Excon::Errors::Timeout.new('read timeout reached') end - rescue Timeout::Error - raise Excon::Errors::Timeout.new('read timeout reached') end end @@ -88,32 +111,40 @@ def connect @socket = nil exception = nil + hostname = @data:hostname + port = @port + family = @data:family if @data:proxy - family = @data:proxy:family || ::Socket::Constants::AF_UNSPEC - args = @data:proxy:hostname, @data:proxy:port, family, ::Socket::Constants::SOCK_STREAM - else - family = @data:family || ::Socket::Constants::AF_UNSPEC - args = @data:hostname, @port, family, ::Socket::Constants::SOCK_STREAM + hostname = @data:proxy:hostname + port = @data:proxy:port + family = @data:proxy:family end - if RUBY_VERSION >= '1.9.2' && defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' - args << nil << nil << false # no reverse lookup + + resolver = @data:resolv_resolver || Resolv.new + + # Deprecated + if @data:dns_timeouts + Excon.display_warning('dns_timeouts is deprecated, use resolv_resolver instead.') + dns_resolver = Resolv::DNS.new + dns_resolver.timeouts = @data:dns_timeouts + resolver = Resolv.new(Resolv::Hosts.new, dns_resolver) end - addrinfo = ::Socket.getaddrinfo(*args) - addrinfo.each do |_, port, _, ip, a_family, s_type| + resolver.each_address(hostname) do |ip| # already succeeded on previous addrinfo if @socket break end - + @remote_ip = ip + @data:remote_ip = ip # nonblocking connect begin sockaddr = ::Socket.sockaddr_in(port, ip) - - socket = ::Socket.new(a_family, s_type, 0) + addrinfo = Addrinfo.getaddrinfo(ip, port, family, :STREAM).first + socket = ::Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol) if @data:reuseaddr socket.setsockopt(::Socket::Constants::SOL_SOCKET, ::Socket::Constants::SO_REUSEADDR, true) @@ -128,7 +159,7 @@ socket.connect(sockaddr) end @socket = socket - rescue Errno::EINPROGRESS + rescue *CONNECT_RETRY_EXCEPTION_CLASSES select_with_timeout(socket, :connect_write) begin socket.connect_nonblock(sockaddr) @@ -143,6 +174,8 @@ end end + exception ||= Resolv::ResolvError.new("no address for #{hostname}") + # this will be our last encountered exception fail exception unless @socket @@ -151,35 +184,53 @@ ::Socket::TCP_NODELAY, true) end + + if @data:keepalive + if :SOL_SOCKET, :SO_KEEPALIVE, :SOL_TCP, :TCP_KEEPIDLE, :TCP_KEEPINTVL, :TCP_KEEPCNT.all?{|c| ::Socket.const_defined? c} + @socket.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_KEEPALIVE, true) + @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPIDLE, @data:keepalive:time) + @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPINTVL, @data:keepalive:intvl) + @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPCNT, @data:keepalive:probes) + else + Excon.display_warning('Excon::Socket keepalive was set, but is not supported by Ruby version.') + end + end + end + + def add_to_read_buffer(str) + @read_buffer << str + @eof = false end def read_nonblock(max_length) begin if max_length - until @read_buffer.length >= max_length + until @backend_eof || @read_buffer.length >= max_length @read_buffer << @socket.read_nonblock(max_length - @read_buffer.length) end else
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/ssl_socket.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/ssl_socket.rb
Changed
@@ -12,6 +12,11 @@ # create ssl context ssl_context = OpenSSL::SSL::SSLContext.new + # set the security level before setting other parameters affected by it + if @data:ssl_security_level + ssl_context.security_level = @data:ssl_security_level + end + # disable less secure options, when supported ssl_context_options = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS:options if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS) @@ -27,26 +32,35 @@ if @data:ssl_version ssl_context.ssl_version = @data:ssl_version end + if @data:ssl_min_version + ssl_context.min_version = @data:ssl_min_version + end + if @data:ssl_max_version + ssl_context.max_version = @data:ssl_max_version + end + if @data:ssl_verify_peer # turn verification on ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER - if ca_file = @data:ssl_ca_file || ENV'SSL_CERT_FILE' + if (ca_file = @data:ssl_ca_file || ENV'SSL_CERT_FILE') ssl_context.ca_file = ca_file end - if ca_path = @data:ssl_ca_path || ENV'SSL_CERT_DIR' + if (ca_path = @data:ssl_ca_path || ENV'SSL_CERT_DIR') ssl_context.ca_path = ca_path end - if cert_store = @data:ssl_cert_store + if (cert_store = @data:ssl_cert_store) ssl_context.cert_store = cert_store end - # no defaults, fallback to bundled - unless ca_file || ca_path || cert_store + if cert_store.nil? ssl_context.cert_store = OpenSSL::X509::Store.new ssl_context.cert_store.set_default_paths + end + # no defaults, fallback to bundled + unless ca_file || ca_path || cert_store # workaround issue #257 (JRUBY-6970) ca_file = DEFAULT_CA_FILE ca_file = ca_file.gsub(/^jar:/, '') if ca_file =~ /^jar:file:\// @@ -58,7 +72,7 @@ end end - if verify_callback = @data:ssl_verify_callback + if (verify_callback = @data:ssl_verify_callback) ssl_context.verify_callback = verify_callback end else @@ -66,6 +80,9 @@ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE end + # Verify certificate hostname if supported (ruby >= 2.4.0) + ssl_context.verify_hostname = @data:ssl_verify_hostname if ssl_context.respond_to?(:verify_hostname=) + if client_cert_data && client_key_data ssl_context.cert = OpenSSL::X509::Certificate.new client_cert_data if OpenSSL::PKey.respond_to? :read @@ -73,6 +90,14 @@ else ssl_context.key = OpenSSL::PKey::RSA.new(client_key_data, client_key_pass) end + if client_chain_data && OpenSSL::X509::Certificate.respond_to?(:load) + ssl_context.extra_chain_cert = OpenSSL::X509::Certificate.load(client_chain_data) + elsif client_chain_data + certs = client_chain_data.scan(/-----BEGIN CERTIFICATE-----(?:.|\n)+?-----END CERTIFICATE-----/) + ssl_context.extra_chain_cert = certs.map do |cert| + OpenSSL::X509::Certificate.new(cert) + end + end elsif @data.key?(:certificate) && @data.key?(:private_key) ssl_context.cert = OpenSSL::X509::Certificate.new(@data:certificate) if OpenSSL::PKey.respond_to? :read @@ -94,13 +119,20 @@ request += "Proxy-Connection: Keep-Alive#{Excon::CR_NL}" + if @data:ssl_proxy_headers + request << Utils.headers_hash_to_s(@data:ssl_proxy_headers) + end + request += Excon::CR_NL # write out the proxy setup request @socket.write(request) # eat the proxy's connection response - Excon::Response.parse(self, :expects => 200, :method => 'CONNECT') + response = Excon::Response.parse(self, :expects => 200, :method => 'CONNECT') + if response:response:status != 200 + raise(Excon::Errors::ProxyConnectionError.new("proxy connection could not be established", request, response)) + end end # convert Socket to OpenSSL::SSL::SSLSocket @@ -109,7 +141,7 @@ # Server Name Indication (SNI) RFC 3546 if @socket.respond_to?(:hostname=) - @socket.hostname = @data:host + @socket.hostname = @data:ssl_verify_peer_host || @data:host end begin @@ -132,23 +164,29 @@ if @data:ssl_verify_peer @socket.post_connection_check(@data:ssl_verify_peer_host || @data:host) end - - @socket end private def client_cert_data - @client_cert_data ||= if ccd = @data:client_cert_data + @client_cert_data ||= if (ccd = @data:client_cert_data) ccd - elsif path = @data:client_cert + elsif (path = @data:client_cert) File.read path - elsif path = @data:certificate_path + elsif (path = @data:certificate_path) warn ":certificate_path is no longer supported and will be deprecated. Please use :client_cert or :client_cert_data" File.read path end end + def client_chain_data + @client_chain_data ||= if (ccd = @data:client_chain_data) + ccd + elsif (path = @data:client_chain) + File.read path + end + end + def connect # backwards compatability for things lacking nonblock @nonblock = HAVE_NONBLOCK && @nonblock @@ -156,11 +194,11 @@ end def client_key_data - @client_key_data ||= if ckd = @data:client_key_data + @client_key_data ||= if (ckd = @data:client_key_data) ckd - elsif path = @data:client_key + elsif (path = @data:client_key) File.read path - elsif path = @data:private_key_path + elsif (path = @data:private_key_path) warn ":private_key_path is no longer supported and will be deprecated. Please use :client_key or :client_key_data" File.read path end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/test/plugin/server/exec.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/test/plugin/server/exec.rb
Changed
@@ -4,13 +4,16 @@ module Server module Exec def start(app_str = app) + open_process(app_str) + process_stderr = "" line = '' - open_process(app) until line =~ /\Aready\Z/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout if fatal_time - msg = "executable #{app} has taken too long to start" + msg = "executable #{app_str} has taken too long to start" raise msg end end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/test/plugin/server/puma.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/test/plugin/server/puma.rb
Changed
@@ -4,10 +4,13 @@ module Server module Puma def start(app_str = app, bind_uri = bind) - open_process('puma', '-b', bind_uri.to_s, app_str) + open_process(RbConfig.ruby, '-S', 'puma', '-b', bind_uri.to_s, app_str) + process_stderr = "" line = '' until line =~ /Use Ctrl-C to stop/ line = read.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'puma server has taken too long to start' if fatal_time end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/test/plugin/server/unicorn.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/test/plugin/server/unicorn.rb
Changed
@@ -13,6 +13,8 @@ bind_str = "#{host}:#{bind_uri.port}" end args = + RbConfig.ruby, + '-S', 'unicorn', '--no-default-middleware', '-l', @@ -20,9 +22,12 @@ app_str open_process(*args) + process_stderr = '' line = '' until line =~ /worker\=0 ready/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'unicorn server has taken too long to start' if fatal_time end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/test/plugin/server/webrick.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/test/plugin/server/webrick.rb
Changed
@@ -7,10 +7,13 @@ bind_uri = URI.parse(bind_uri) unless bind_uri.is_a? URI::Generic host = bind_uri.host.gsub(/\\/, '') port = bind_uri.port.to_s - open_process('rackup', '-s', 'webrick', '--host', host, '--port', port, app_str) + open_process(RbConfig.ruby, '-S', 'rackup', '-s', 'webrick', '--host', host, '--port', port, app_str) + process_stderr = "" line = '' until line =~ /HTTPServer#start/ line = error.gets + raise process_stderr if line.nil? + process_stderr << line fatal_time = elapsed_time > timeout raise 'webrick server has taken too long to start' if fatal_time end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/test/server.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/test/server.rb
Changed
@@ -42,7 +42,6 @@ if RUBY_PLATFORM == 'java' @pid, @write, @read, @error = IO.popen4(*args) else - GC.disable if RUBY_VERSION < '1.9' @pid, @write, @read, @error = Open4.popen4(*args) end @started_at = Time.now @@ -57,7 +56,6 @@ Process.kill('USR1', pid) else Process.kill(9, pid) - GC.enable if RUBY_VERSION < '1.9' Process.wait(pid) end @@ -72,7 +70,7 @@ end def dump_errors lines = error.read.split($/) - while line = lines.shift + while (line = lines.shift) case line when /(ERROR|Error)/ unless line =~ /(null cert chain|did not return a certificate|SSL_read:: internal error)/
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/unix_socket.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/unix_socket.rb
Changed
@@ -20,6 +20,7 @@ begin @socket.connect_nonblock(sockaddr) rescue Errno::EISCONN + 0 # same return as connect_nonblock success end end else
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/utils.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/utils.rb
Changed
@@ -10,6 +10,18 @@ UNESCAPED = /(#{ Regexp.escape(CONTROL + ' ' + DELIMS + UNWISE + NONASCII) })/ ESCAPED = /%(0-9a-fA-F{2})/ + def binary_encode(string) + if FORCE_ENC && string.encoding != Encoding::ASCII_8BIT + if string.frozen? + string.dup.force_encoding('BINARY') + else + string.force_encoding('BINARY') + end + else + string + end + end + def connection_uri(datum = @data) unless datum raise ArgumentError, '`datum` must be given unless called on a Connection' @@ -21,6 +33,30 @@ end end + # Redact sensitive info from provided data + def redact(datum) + datum = datum.dup + if datum.has_key?(:headers) + if datum:headers.has_key?('Authorization') || datum:headers.has_key?('Proxy-Authorization') + datum:headers = datum:headers.dup + end + if datum:headers.has_key?('Authorization') + datum:headers'Authorization' = REDACTED + end + if datum:headers.has_key?('Proxy-Authorization') + datum:headers'Proxy-Authorization' = REDACTED + end + end + if datum.has_key?(:password) + datum:password = REDACTED + end + if datum.has_key?(:proxy) && datum:proxy && datum:proxy.has_key?(:password) + datum:proxy = datum:proxy.dup + datum:proxy:password = REDACTED + end + datum + end + def request_uri(datum) connection_uri(datum) + datum:path + query_string(datum) end @@ -59,31 +95,49 @@ def split_header_value(str) return if str.nil? str = str.dup.strip - str.force_encoding('BINARY') if FORCE_ENC - str.scan(%r'\G((?:"(?:\\.|^")+?"|^",+)+) + str = binary_encode(str) + str.scan(%r'\G((?:"(?:\\.|^")+?"|^",)+) (?:,\s*|\Z)'xn).flatten end # Escapes HTTP reserved and unwise characters in +str+ def escape_uri(str) str = str.dup - str.force_encoding('BINARY') if FORCE_ENC + str = binary_encode(str) str.gsub(UNESCAPED) { "%%%02X" % $10.ord } end # Unescapes HTTP reserved and unwise characters in +str+ def unescape_uri(str) str = str.dup - str.force_encoding('BINARY') if FORCE_ENC + str = binary_encode(str) str.gsub(ESCAPED) { $1.hex.chr } end # Unescape form encoded values in +str+ def unescape_form(str) str = str.dup - str.force_encoding('BINARY') if FORCE_ENC + str = binary_encode(str) str.gsub!(/\+/, ' ') str.gsub(ESCAPED) { $1.hex.chr } end + + # Performs validation on the passed header hash and returns a string representation of the headers + def headers_hash_to_s(headers) + headers_str = String.new + headers.each do |key, values| + if key.to_s.match(/\r\n/) + raise Excon::Errors::InvalidHeaderKey.new(key.to_s.inspect + ' contains forbidden "\r" or "\n"') + end + values.flatten.each do |value| + if value.to_s.match(/\r\n/) + # Don't include the potentially sensitive header value (i.e. authorization token) in the message + raise Excon::Errors::InvalidHeaderValue.new(key.to_s + ' header value contains forbidden "\r" or "\n"') + end + headers_str << key.to_s << ': ' << value.to_s << CR_NL + end + end + headers_str + end end end
View file
_service:tar_scm:excon-0.62.0.gem/data/lib/excon/version.rb -> _service:tar_scm:excon-0.104.0.gem/data/lib/excon/version.rb
Changed
@@ -1,4 +1,5 @@ # frozen_string_literal: true + module Excon - VERSION = '0.62.0' + VERSION = '0.104.0' end
View file
_service:tar_scm:excon-0.62.0.gem/metadata.gz -> _service:tar_scm:excon-0.104.0.gem/metadata.gz
Changed
@@ -1,16 +1,16 @@ --- !ruby/object:Gem::Specification name: excon version: !ruby/object:Gem::Version - version: 0.62.0 + version: 0.104.0 platform: ruby authors: - dpiddy (Dan Peterson) - geemus (Wesley Beary) - nextmat (Matt Sanders) -autorequire: +autorequire: bindir: bin cert_chain: -date: 2018-03-27 00:00:00.000000000 Z +date: 2023-09-29 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec @@ -97,7 +97,7 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: rdoc + name: shindo requirement: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -111,7 +111,7 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: shindo + name: sinatra requirement: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -125,7 +125,7 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: sinatra + name: sinatra-contrib requirement: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -139,35 +139,35 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: sinatra-contrib + name: json requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version - version: '0' + version: 1.8.5 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version - version: '0' + version: 1.8.5 - !ruby/object:Gem::Dependency - name: json + name: puma requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version - version: 1.8.5 + version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version - version: 1.8.5 + version: '0' - !ruby/object:Gem::Dependency - name: puma + name: webrick requirement: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -189,35 +189,10 @@ - CONTRIBUTORS.md - CONTRIBUTING.md files: -- ".document" -- ".gitignore" -- ".rspec" -- ".travis.yml" - CONTRIBUTING.md - CONTRIBUTORS.md -- Gemfile - LICENSE.md - README.md -- Rakefile -- benchmarks/class_vs_lambda.rb -- benchmarks/concat_vs_insert.rb -- benchmarks/concat_vs_interpolate.rb -- benchmarks/cr_lf.rb -- benchmarks/downcase-eq-eq_vs_casecmp.rb -- benchmarks/excon.rb -- benchmarks/excon_vs.rb -- benchmarks/for_vs_array_each.rb -- benchmarks/for_vs_hash_each.rb -- benchmarks/has_key-vs-lookup.rb -- benchmarks/headers_case_sensitivity.rb -- benchmarks/headers_split_vs_match.rb -- benchmarks/implicit_block-vs-explicit_block.rb -- benchmarks/merging.rb -- benchmarks/single_vs_double_quotes.rb -- benchmarks/string_ranged_index.rb -- benchmarks/strip_newline.rb -- benchmarks/vs_stdlib.rb -- changelog.txt - data/cacert.pem - excon.gemspec - lib/excon.rb @@ -250,76 +225,17 @@ - lib/excon/unix_socket.rb - lib/excon/utils.rb - lib/excon/version.rb -- spec/excon/error_spec.rb -- spec/excon/test/server_spec.rb -- spec/excon_spec.rb -- spec/helpers/file_path_helpers.rb -- spec/requests/basic_spec.rb -- spec/requests/eof_requests_spec.rb -- spec/requests/unix_socket_spec.rb -- spec/spec_helper.rb -- spec/support/shared_contexts/test_server_context.rb -- spec/support/shared_examples/shared_example_for_clients.rb -- spec/support/shared_examples/shared_example_for_streaming_clients.rb -- spec/support/shared_examples/shared_example_for_test_servers.rb -- tests/authorization_header_tests.rb -- tests/bad_tests.rb -- tests/basic_tests.rb -- tests/batch_requests.rb -- tests/complete_responses.rb -- tests/data/127.0.0.1.cert.crt -- tests/data/127.0.0.1.cert.key -- tests/data/excon.cert.crt -- tests/data/excon.cert.key -- tests/data/xs -- tests/error_tests.rb -- tests/header_tests.rb -- tests/middlewares/canned_response_tests.rb -- tests/middlewares/capture_cookies_tests.rb -- tests/middlewares/decompress_tests.rb -- tests/middlewares/escape_path_tests.rb -- tests/middlewares/idempotent_tests.rb -- tests/middlewares/instrumentation_tests.rb -- tests/middlewares/mock_tests.rb -- tests/middlewares/redirect_follower_tests.rb -- tests/pipeline_tests.rb -- tests/proxy_tests.rb -- tests/query_string_tests.rb -- tests/rackups/basic.rb -- tests/rackups/basic.ru -- tests/rackups/basic_auth.ru -- tests/rackups/deflater.ru -- tests/rackups/proxy.ru -- tests/rackups/query_string.ru -- tests/rackups/redirecting.ru -- tests/rackups/redirecting_with_cookie.ru -- tests/rackups/request_headers.ru -- tests/rackups/request_methods.ru -- tests/rackups/response_header.ru -- tests/rackups/ssl.ru -- tests/rackups/ssl_mismatched_cn.ru -- tests/rackups/ssl_verify_peer.ru -- tests/rackups/streaming.ru -- tests/rackups/thread_safety.ru -- tests/rackups/timeout.ru -- tests/rackups/webrick_patch.rb -- tests/request_headers_tests.rb -- tests/request_method_tests.rb -- tests/request_tests.rb -- tests/response_tests.rb -- tests/servers/bad.rb -- tests/servers/eof.rb -- tests/servers/error.rb -- tests/servers/good.rb -- tests/test_helper.rb -- tests/thread_safety_tests.rb -- tests/timeout_tests.rb -- tests/utils_tests.rb homepage: https://github.com/excon/excon licenses: - MIT -metadata: {} -post_install_message:
View file
_service:tar_scm:excon-0.62.0.gem/data/.document
Deleted
@@ -1,5 +0,0 @@ -README.rdoc -lib/**/*.rb -bin/* -features/**/*.feature -LICENSE
View file
_service:tar_scm:excon-0.62.0.gem/data/.gitignore
Deleted
@@ -1,13 +0,0 @@ -*.rbc -*.sw? -.bundle -.DS_Store -.yardoc -.rvmrc -.ruby-version -.ruby-gemset -coverage -doc -rdoc -pkg -Gemfile.lock
View file
_service:tar_scm:excon-0.62.0.gem/data/.rspec
Deleted
@@ -1,3 +0,0 @@ ---color ---require spec_helper ---format d
View file
_service:tar_scm:excon-0.62.0.gem/data/.travis.yml
Deleted
@@ -1,29 +0,0 @@ -before_install: - - gem install bundler -language: ruby -matrix: - allow_failures: - - rvm: 1.8.7 - - rvm: 1.9.2 - - rvm: jruby - - rvm: rbx-3.2 - - rvm: ree - fast_finish: true -rvm: - - 1.8.7 - - 1.9.2 - - 1.9.3 - - 2.0 - - 2.1 - - 2.2 - - 2.3 - - 2.4 - - 2.5 - - jruby - - rbx-3.2 - - ree -script: - - "bundle exec shindont" - - "bundle exec rake specprogress" - -sudo: false
View file
_service:tar_scm:excon-0.62.0.gem/data/Gemfile
Deleted
@@ -1,19 +0,0 @@ -source "https://rubygems.org" - -gemspec - -gem 'jruby-openssl', '~> 0.9', :platform => :jruby -gem 'unicorn', :platforms => :mri, :rbx, :groups => :development, :test -gem 'rubysl', '~> 2.0', :platform => :rbx -gem 'rack', '~> 1.6' - -# group :benchmark do -# gem 'em-http-request' -# gem 'httparty' -# gem 'rest-client' -# gem 'tach' -# gem 'typhoeus' -# gem 'sinatra' -# gem 'streamly_ffi' -# gem 'curb' -# end
View file
_service:tar_scm:excon-0.62.0.gem/data/Rakefile
Deleted
@@ -1,41 +0,0 @@ -require 'shindo/rake' -require 'rspec/core/rake_task' -require 'bundler/gem_tasks' -require 'rdoc/task' - -Shindo::Rake.new - -RSpec::Core::RakeTask.new(:spec, :format) do |t, args| - format = args:format || 'doc' - t.rspec_opts = "-c", "-f #{format}", "-r ./spec/spec_helper.rb" - t.pattern = 'spec/**/*_spec.rb' -end - -task :default => :tests, :test -task :test => :spec - -desc "update bundled certs" -task :update_certs do - # update curl bundle for end-users - require File.join(File.dirname(__FILE__), 'lib', 'excon') - File.open(File.join(File.dirname(__FILE__), 'data', 'cacert.pem'), 'w') do |file| - data = Excon.get("https://curl.haxx.se/ca/cacert.pem").body - file.write(data) - end - - # update self-signed certs for tests - sh "openssl req -subj '/CN=excon/O=excon' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout tests/data/excon.cert.key -out tests/data/excon.cert.crt" - sh "openssl req -subj '/CN=127.0.0.1/O=excon' -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout tests/data/127.0.0.1.cert.key -out tests/data/127.0.0.1.cert.crt" -end - -desc "Open an irb session preloaded with this library" -task :console do - sh "irb -rubygems -r ./lib/#{name}.rb" -end - -desc "check ssl settings" -task :hows_my_ssl do - require File.join(File.dirname(__FILE__), 'lib', 'excon') - data = Excon.get("https://www.howsmyssl.com/a/check").body - puts data -end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/class_vs_lambda.rb
Deleted
@@ -1,50 +0,0 @@ -require 'rubygems' -require 'tach' - -class Concatenator - def initialize(string) - @string = string - end - - def call(data) - @string << data - end -end - -string = "0123456789ABCDEF" - -Tach.meter(100_000) do - tach('class') do - s = "" - obj = Concatenator.new(s) - 10.times { obj.call(string) } - end - - tach('lambda') do - s = "" - obj = lambda {|data| s << data } - 10.times { obj.call(string) } - end -end - -# ruby 1.9.2p136 (2010-12-25 revision 30365) x86_64-linux -# -# +--------+----------+ -# | tach | total | -# +--------+----------+ -# | class | 1.450284 | -# +--------+----------+ -# | lambda | 2.506496 | -# +--------+----------+ - -# ruby 1.8.7 (2010-12-23 patchlevel 330) x86_64-linux -# -# +--------+----------+ -# | tach | total | -# +--------+----------+ -# | class | 1.373917 | -# +--------+----------+ -# | lambda | 2.589384 | -# +--------+----------+ - -
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/concat_vs_insert.rb
Deleted
@@ -1,21 +0,0 @@ -require 'rubygems' -require 'tach' - -Tach.meter(1_000_000) do - tach('concat') do - path = 'path' - path = '/' << path - end - tach('insert') do - path = 'path' - path.insert(0, '/') - end -end - -# +--------+----------+ -# | tach | total | -# +--------+----------+ -# | insert | 0.974036 | -# +--------+----------+ -# | concat | 0.998904 | -# +--------+----------+ \ No newline at end of file
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/concat_vs_interpolate.rb
Deleted
@@ -1,22 +0,0 @@ -require 'rubygems' -require 'tach' - -key = 'Content-Length' -value = '100' -Tach.meter(1_000) do - tach('concat') do - temp = '' - temp << key << ': ' << value << "\r\n" - end - tach('interpolate') do - "#{key}: #{value}\r\n" - end -end - -# +-------------+----------+ -# | tach | total | -# +-------------+----------+ -# | interpolate | 0.000404 | -# +-------------+----------+ -# | concat | 0.000564 | -# +-------------+----------+
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/cr_lf.rb
Deleted
@@ -1,21 +0,0 @@ -require 'rubygems' -require 'tach' - -CR_LF = "\r\n" - -Tach.meter(1_000_000) do - tach('constant') do - '' << CR_LF - end - tach('string') do - '' << "\r\n" - end -end - -# +----------+----------+ -# | tach | total | -# +----------+----------+ -# | constant | 0.819885 | -# +----------+----------+ -# | string | 0.893602 | -# +----------+----------+ \ No newline at end of file
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/downcase-eq-eq_vs_casecmp.rb
Deleted
@@ -1,169 +0,0 @@ -# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell - -require 'benchmark' - -iters = 1000000 - -comp = "hello" -hello = "HelLo" - -puts 'String#downcase == vs. String#casecmp' -Benchmark.bmbm do |x| - x.report('String#downcase1') do - iters.times.each do - hello.downcase == comp - end - end - - x.report('String#downcase2') do - iters.times.each do - "HelLo".downcase == "hello" - end - end - - x.report('String#downcase3') do - iters.times.each do - var = "HelLo" - var.downcase! - var == "hello" - end - end - - x.report('casecmp1') do - iters.times.each do - hello.casecmp(comp).zero? - end - end - - x.report('casecmp1-1') do - iters.times.each do - hello.casecmp(comp) == 0 - end - end - - x.report('casecmp2') do - iters.times.each do - "HelLo".casecmp(comp).zero? - end - end - - x.report('casecmp2-1') do - iters.times.each do - "HelLo".casecmp(comp) == 0 - end - end -end - -=begin -rvm exec bash -c 'echo && echo $RUBY_VERSION && echo && ruby downcase-eq-eq_vs_casecmp.rb' - -jruby-1.5.6 - -String#downcase == vs. String#casecmp -Rehearsal ---------------------------------------------------- -String#downcase1 0.461000 0.000000 0.461000 ( 0.387000) -String#downcase2 0.269000 0.000000 0.269000 ( 0.269000) -String#downcase3 0.224000 0.000000 0.224000 ( 0.224000) -casecmp1 0.157000 0.000000 0.157000 ( 0.157000) -casecmp1-1 0.153000 0.000000 0.153000 ( 0.153000) -casecmp2 0.163000 0.000000 0.163000 ( 0.163000) -casecmp2-1 0.163000 0.000000 0.163000 ( 0.163000) -------------------------------------------- total: 1.590000sec - - user system total real -String#downcase1 0.190000 0.000000 0.190000 ( 0.191000) -String#downcase2 0.225000 0.000000 0.225000 ( 0.225000) -String#downcase3 0.190000 0.000000 0.190000 ( 0.190000) -casecmp1 0.125000 0.000000 0.125000 ( 0.125000) -casecmp1-1 0.127000 0.000000 0.127000 ( 0.127000) -casecmp2 0.144000 0.000000 0.144000 ( 0.144000) -casecmp2-1 0.147000 0.000000 0.147000 ( 0.147000) - -macruby-0.7.1 - -String#downcase == vs. String#casecmp -Rehearsal ---------------------------------------------------- -String#downcase1 2.340000 0.040000 2.380000 ( 1.765141) -String#downcase2 5.510000 0.100000 5.610000 ( 3.893249) -String#downcase3 4.200000 0.080000 4.280000 ( 3.031621) -casecmp1 0.270000 0.000000 0.270000 ( 0.267613) -casecmp1-1 0.190000 0.000000 0.190000 ( 0.188848) -casecmp2 1.450000 0.020000 1.470000 ( 1.027956) -casecmp2-1 1.380000 0.030000 1.410000 ( 0.951474) ------------------------------------------- total: 15.610000sec - - user system total real -String#downcase1 2.350000 0.040000 2.390000 ( 1.774292) -String#downcase2 5.890000 0.120000 6.010000 ( 4.214038) -String#downcase3 4.530000 0.090000 4.620000 ( 3.286059) -casecmp1 0.270000 0.000000 0.270000 ( 0.271119) -casecmp1-1 0.190000 0.000000 0.190000 ( 0.189462) -casecmp2 1.540000 0.030000 1.570000 ( 1.104751) -casecmp2-1 1.440000 0.030000 1.470000 ( 0.999689) - -rbx-head - -String#downcase == vs. String#casecmp -Rehearsal ---------------------------------------------------- -String#downcase1 0.702746 0.005229 0.707975 ( 0.621969) -String#downcase2 0.701429 0.001617 0.703046 ( 0.691833) -String#downcase3 1.042835 0.002952 1.045787 ( 0.953992) -casecmp1 0.654571 0.002239 0.656810 ( 0.480158) -casecmp1-1 0.484706 0.001105 0.485811 ( 0.398601) -casecmp2 0.564140 0.001579 0.565719 ( 0.545332) -casecmp2-1 0.554889 0.001153 0.556042 ( 0.539569) -------------------------------------------- total: 4.721190sec - - user system total real -String#downcase1 0.491199 0.001081 0.492280 ( 0.493727) -String#downcase2 0.631059 0.001018 0.632077 ( 0.629885) -String#downcase3 0.968867 0.002504 0.971371 ( 0.976734) -casecmp1 0.364496 0.000434 0.364930 ( 0.365262) -casecmp1-1 0.373140 0.000562 0.373702 ( 0.374136) -casecmp2 0.487644 0.001057 0.488701 ( 0.490302) -casecmp2-1 0.469868 0.001178 0.471046 ( 0.472220) - -ruby-1.8.7-p330 - -String#downcase == vs. String#casecmp -Rehearsal ---------------------------------------------------- -String#downcase1 0.780000 0.000000 0.780000 ( 0.783979) -String#downcase2 0.950000 0.000000 0.950000 ( 0.954109) -String#downcase3 0.960000 0.000000 0.960000 ( 0.960554) -casecmp1 0.440000 0.000000 0.440000 ( 0.442546) -casecmp1-1 0.490000 0.000000 0.490000 ( 0.487795) -casecmp2 0.530000 0.000000 0.530000 ( 0.535819) -casecmp2-1 0.570000 0.000000 0.570000 ( 0.574653) -------------------------------------------- total: 4.720000sec - - user system total real -String#downcase1 0.780000 0.000000 0.780000 ( 0.780692) -String#downcase2 0.980000 0.010000 0.990000 ( 0.982925) -String#downcase3 0.960000 0.000000 0.960000 ( 0.961501) -casecmp1 0.440000 0.000000 0.440000 ( 0.444528) -casecmp1-1 0.490000 0.000000 0.490000 ( 0.487437) -casecmp2 0.540000 0.000000 0.540000 ( 0.537686) -casecmp2-1 0.570000 0.000000 0.570000 ( 0.574253) - -ruby-1.9.2-p136 - -String#downcase == vs. String#casecmp -Rehearsal ---------------------------------------------------- -String#downcase1 0.750000 0.000000 0.750000 ( 0.750523) -String#downcase2 1.190000 0.000000 1.190000 ( 1.193346) -String#downcase3 1.030000 0.010000 1.040000 ( 1.036435) -casecmp1 0.640000 0.000000 0.640000 ( 0.640327) -casecmp1-1 0.480000 0.000000 0.480000 ( 0.484709) # With all this crap running, some flukes pop out -casecmp2 0.820000 0.000000 0.820000 ( 0.822223) -casecmp2-1 0.660000 0.000000 0.660000 ( 0.664190) -------------------------------------------- total: 5.580000sec - - user system total real -String#downcase1 0.760000 0.000000 0.760000 ( 0.759816) -String#downcase2 1.150000 0.010000 1.160000 ( 1.150792) -String#downcase3 1.000000 0.000000 1.000000 ( 1.005549) -casecmp1 0.650000 0.000000 0.650000 ( 0.644021) -casecmp1-1 0.490000 0.000000 0.490000 ( 0.494456) -casecmp2 0.820000 0.000000 0.820000 ( 0.817689) -casecmp2-1 0.680000 0.000000 0.680000 ( 0.685121) -=end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/excon.rb
Deleted
@@ -1,69 +0,0 @@ -require 'rubygems' if RUBY_VERSION < '1.9' -require 'bundler' - -Bundler.require(:default) -Bundler.require(:benchmark) - -require 'sinatra/base' - -require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon') - -module Excon - class Server < Sinatra::Base - - def self.run - Rack::Handler::WEBrick.run( - Excon::Server.new, - :Port => 9292, - :AccessLog => , - :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR) - ) - end - - get '/data/:amount' do |amount| - 'x' * amount.to_i - end - - end -end - -def with_server(&block) - pid = Process.fork do - Excon::Server.run - end - loop do - sleep(1) - begin - Excon.get('http://localhost:9292/api/foo') - break - rescue - end - end - yield -ensure - Process.kill(9, pid) -end - -require 'tach' - -size = 10_000 -path = '/data/' << size.to_s -url = 'http://localhost:9292' << path - -times = 1_000 - -with_server do - - Tach.meter(times) do - - tach('Excon') do - Excon.get(url).body - end - - excon = Excon.new(url) - tach('Excon (persistent)') do - excon.request(:method => 'get').body - end - - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/excon_vs.rb
Deleted
@@ -1,165 +0,0 @@ -require 'rubygems' if RUBY_VERSION < '1.9' -require 'bundler' - -Bundler.require(:default) -Bundler.require(:benchmark) - -require 'sinatra/base' - -require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon') - -module Excon - class Server < Sinatra::Base - - def self.run - Rack::Handler::WEBrick.run( - Excon::Server.new, - :Port => 9292, - :AccessLog => , - :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR) - ) - end - - get '/data/:amount' do |amount| - 'x' * amount.to_i - end - - end -end - -def with_server(&block) - pid = Process.fork do - Excon::Server.run - end - loop do - sleep(1) - begin - Excon.get('http://localhost:9292/api/foo') - break - rescue - end - end - yield -ensure - Process.kill(9, pid) -end - -require 'em-http-request' -require 'httparty' -require 'net/http' -require 'open-uri' -require 'rest_client' -require 'tach' -require 'typhoeus' - -size = 10_000 -path = '/data/' << size.to_s -url = 'http://localhost:9292' << path - -times = 1_000 - -with_server do - - Tach.meter(times) do - - tach('curb (persistent)') do |n| - curb = Curl::Easy.new - - n.times do - curb.url = url - curb.http_get - curb.body_str - end - end - - tach('em-http-request') do |n| - EventMachine.run { - count = 0 - - n.times do - http = EventMachine::HttpRequest.new(url).get - - http.callback { - http.response - count += 1 - EM.stop if count == n - } - - http.errback { - http.response - count += 1 - EM.stop if count == n - } - end - } - end - - tach('Excon') do - Excon.get(url).body - end - - excon = Excon.new(url) - tach('Excon (persistent)') do - excon.request(:method => 'get').body - end - - tach('HTTParty') do - HTTParty.get(url).body - end - - tach('Net::HTTP') do - # Net::HTTP.get('localhost', path, 9292) - Net::HTTP.start('localhost', 9292) {|http| http.get(path).body } - end - - Net::HTTP.start('localhost', 9292) do |http| - tach('Net::HTTP (persistent)') do - http.get(path).body - end - end - - tach('open-uri') do - open(url).read - end - - tach('RestClient') do - RestClient.get(url) - end - - streamly = StreamlyFFI::Connection.new - tach('StreamlyFFI (persistent)') do - streamly.get(url) - end - - tach('Typhoeus') do - Typhoeus::Request.get(url).body - end - - end -end - -# +--------------------------+----------+ -# | tach | total | -# +--------------------------+----------+ -# | Excon (persistent) | 1.529095 | -# +--------------------------+----------+ -# | curb (persistent) | 1.740387 | -# +--------------------------+----------+ -# | Typhoeus | 1.876236 | -# +--------------------------+----------+ -# | Excon | 2.001858 | -# +--------------------------+----------+ -# | StreamlyFFI (persistent) | 2.200701 | -# +--------------------------+----------+ -# | Net::HTTP | 2.395704 | -# +--------------------------+----------+ -# | Net::HTTP (persistent) | 2.418099 | -# +--------------------------+----------+ -# | HTTParty | 2.659317 | -# +--------------------------+----------+ -# | RestClient | 2.958159 | -# +--------------------------+----------+ -# | open-uri | 2.987051 | -# +--------------------------+----------+ -# | em-http-request | 4.123798 | -# +--------------------------+----------+
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/for_vs_array_each.rb
Deleted
@@ -1,27 +0,0 @@ -require 'rubygems' -require 'tach' - -data = "some", "var", "goes", "in", :here, 0 -Tach.meter(1_000_000) do - tach('for') do - for element in data - element == nil - end - end - tach('each') do - data.each do |element| - element == nil - end - end -end - -# ruby 1.8.7 (2009-06-12 patchlevel 174) universal-darwin10.0 -# -# +------+----------+ -# | tach | total | -# +------+----------+ -# | for | 2.958672 | -# +------+----------+ -# | each | 2.983550 | -# +------+----------+ -#
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/for_vs_hash_each.rb
Deleted
@@ -1,27 +0,0 @@ -require 'rubygems' -require 'tach' - -data = {"some" => "var", "goes" => "in", :here => 0} -Tach.meter(1_000_000) do - tach('for') do - for key, values in data - key == values - end - end - tach('each') do - data.each do |key, values| - key == values - end - end -end - -# ruby 1.8.7 (2009-06-12 patchlevel 174) universal-darwin10.0 -# -# +------+----------+ -# | tach | total | -# +------+----------+ -# | each | 2.748909 | -# +------+----------+ -# | for | 2.949512 | -# +------+----------+ -#
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/has_key-vs-lookup.rb
Deleted
@@ -1,177 +0,0 @@ -# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell - -require 'benchmark' - -iters = 1000000 -hash = { - 'some_key' => 'some_val', - 'nil_key' => nil -} - -puts 'Hash#has_key vs. Hash#' -Benchmark.bmbm do |x| - x.report('Hash#has_key') do - iters.times.each do - hash.has_key? 'some_key' - end - end - - x.report('Hash#has_key (if statement)') do - iters.times.each do - if hash.has_key?('other_key') - "hooray!" - end - end - end - - x.report('Hash#has_key (non-existant)') do - iters.times.each do - hash.has_key? 'other_key' - end - end - - x.report('Hash#') do - iters.times.each do - hash'some_key' - end - end - - x.report('Hash# (if statement)') do - iters.times.each do - if hash'some_key' - "hooray!" - end - end - end - - x.report('Hash# (non-existant)') do - iters.times.each do - hash'other_key' - end - end - - x.report('Hash#has_key (if statement) explicit nil check') do - iters.times.each do - if hash.has_key?('nil_key') && !hash'nil_key'.nil? - "hooray!" - end - end - end - - - x.report('Hash#has_key (if statement) implicit nil check') do - iters.times.each do - if hash.has_key?('nil_key') && hash'nil_key' - "hooray!" - end - end - end - - x.report('Hash# (if statement with nil)') do - iters.times.each do - if hash'nil_key' - "hooray!" - end - end - end -end - -=begin - -$ rvm exec bash -c 'echo $RUBY_VERSION && ruby has_key-vs-hash\key\.rb' - -jruby-1.5.6 -Hash#has_key vs. Hash# -Rehearsal --------------------------------------------------------------- -Hash#has_key 0.410000 0.000000 0.410000 ( 0.341000) -Hash#has_key (if statement) 0.145000 0.000000 0.145000 ( 0.145000) -Hash#has_key (non-existant) 0.116000 0.000000 0.116000 ( 0.116000) -Hash# 0.189000 0.000000 0.189000 ( 0.189000) -Hash# (if statement) 0.176000 0.000000 0.176000 ( 0.176000) -Hash# (non-existant) 0.302000 0.000000 0.302000 ( 0.302000) ------------------------------------------------------- total: 1.338000sec - - user system total real -Hash#has_key 0.128000 0.000000 0.128000 ( 0.128000) -Hash#has_key (if statement) 0.128000 0.000000 0.128000 ( 0.128000) -Hash#has_key (non-existant) 0.153000 0.000000 0.153000 ( 0.153000) -Hash# 0.206000 0.000000 0.206000 ( 0.206000) -Hash# (if statement) 0.182000 0.000000 0.182000 ( 0.182000) -Hash# (non-existant) 0.252000 0.000000 0.252000 ( 0.252000) - -macruby-0.7.1 -Hash#has_key vs. Hash# -Rehearsal --------------------------------------------------------------- -Hash#has_key 2.530000 0.050000 2.580000 ( 1.917643) -Hash#has_key (if statement) 2.590000 0.050000 2.640000 ( 1.935221) -Hash#has_key (non-existant) 2.580000 0.050000 2.630000 ( 1.964230) -Hash# 2.240000 0.040000 2.280000 ( 1.640999) -Hash# (if statement) 3.620000 0.070000 3.690000 ( 2.530248) -Hash# (non-existant) 2.060000 0.040000 2.100000 ( 1.473487) ------------------------------------------------------ total: 15.920000sec - - user system total real -Hash#has_key 2.230000 0.030000 2.260000 ( 1.661843) -Hash#has_key (if statement) 2.180000 0.040000 2.220000 ( 1.605644) -Hash#has_key (non-existant) 2.160000 0.040000 2.200000 ( 1.582561) -Hash# 2.160000 0.030000 2.190000 ( 1.581448) -Hash# (if statement) 3.440000 0.070000 3.510000 ( 2.393421) -Hash# (non-existant) 2.330000 0.040000 2.370000 ( 1.699338) - -rbx-head -Hash#has_key vs. Hash# -Rehearsal --------------------------------------------------------------- -Hash#has_key 0.660584 0.004932 0.665516 ( 0.508601) -Hash#has_key (if statement) 0.261708 0.000532 0.262240 ( 0.263021) -Hash#has_key (non-existant) 0.265908 0.000827 0.266735 ( 0.259509) -Hash# 0.396607 0.001189 0.397796 ( 0.372997) -Hash# (if statement) 0.553003 0.001589 0.554592 ( 0.543859) -Hash# (non-existant) 0.323748 0.000884 0.324632 ( 0.319055) ------------------------------------------------------- total: 2.471511sec - - user system total real -Hash#has_key 0.332239 0.000819 0.333058 ( 0.333809) -Hash#has_key (if statement) 0.284344 0.000521 0.284865 ( 0.285330) -Hash#has_key (non-existant) 0.339695 0.001301 0.340996 ( 0.324259) -Hash# 0.298555 0.000368 0.298923 ( 0.299557) -Hash# (if statement) 0.392755 0.000773 0.393528 ( 0.395473) -Hash# (non-existant) 0.277721 0.000464 0.278185 ( 0.278540) - -ruby-1.8.7-p330 -Hash#has_key vs. Hash# -Rehearsal --------------------------------------------------------------- -Hash#has_key 0.450000 0.000000 0.450000 ( 0.450143) -Hash#has_key (if statement) 0.440000 0.000000 0.440000 ( 0.448278) -Hash#has_key (non-existant) 0.420000 0.000000 0.420000 ( 0.416959) -Hash# 0.450000 0.000000 0.450000 ( 0.450727) -Hash# (if statement) 0.550000 0.000000 0.550000 ( 0.555043) -Hash# (non-existant) 0.530000 0.000000 0.530000 ( 0.527189) ------------------------------------------------------- total: 2.840000sec - - user system total real -Hash#has_key 0.440000 0.000000 0.440000 ( 0.447746) -Hash#has_key (if statement) 0.450000 0.000000 0.450000 ( 0.450331) -Hash#has_key (non-existant) 0.420000 0.000000 0.420000 ( 0.419157) -Hash# 0.450000 0.000000 0.450000 ( 0.454438) -Hash# (if statement) 0.570000 0.000000 0.570000 ( 0.563948) -Hash# (non-existant) 0.520000 0.000000 0.520000 ( 0.527866) - -ruby-1.9.2-p136 -Hash#has_key vs. Hash# -Rehearsal --------------------------------------------------------------- -Hash#has_key 0.690000 0.000000 0.690000 ( 0.691657) -Hash#has_key (if statement) 0.630000 0.000000 0.630000 ( 0.638418) -Hash#has_key (non-existant) 0.640000 0.000000 0.640000 ( 0.637510) -Hash# 0.580000 0.000000 0.580000 ( 0.584500) -Hash# (if statement) 0.840000 0.010000 0.850000 ( 0.837541) -Hash# (non-existant) 0.810000 0.000000 0.810000 ( 0.811598) ------------------------------------------------------- total: 4.200000sec - - user system total real -Hash#has_key 0.690000 0.000000 0.690000 ( 0.694192) -Hash#has_key (if statement) 0.640000 0.000000 0.640000 ( 0.641729) -Hash#has_key (non-existant) 0.630000 0.000000 0.630000 ( 0.634470) -Hash# 0.580000 0.000000 0.580000 ( 0.587844) -Hash# (if statement) 0.830000 0.000000 0.830000 ( 0.832323) -Hash# (non-existant) 0.790000 0.010000 0.800000 ( 0.791689) -=end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/headers_case_sensitivity.rb
Deleted
@@ -1,83 +0,0 @@ -require 'rubygems' -require 'stringio' -require 'tach' - -def all_match_socket - io = StringIO.new - io << "Connection: close\n" - io << "Content-Length: 000\n" - io << "Content-Type: text/html\n" - io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n" - io << "Server: xxx\n" - io << "Transfer-Encoding: chunked\n" - io << "\n\n" - io.rewind - io -end - -Formatador.display_line('all_match') -Formatador.indent do - Tach.meter(10_000) do - tach('compare on read') do - socket, headers = all_match_socket, {} - until ((data = socket.readline).chop!).empty? - key, value = data.split(': ') - headerskey = value - (key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0) - (key.casecmp('Connection') == 0) && (value.casecmp('close') == 0) - (key.casecmp('Content-Length') == 0) - end - end - - tach('original') do - socket, headers = all_match_socket, {} - until ((data = socket.readline).chop!).empty? - key, value = data.split(': ') - headerskey = value - end - headers.has_key?('Transfer-Encoding') && headers'Transfer-Encoding'.casecmp('chunked') == 0 - headers.has_key?('Connection') && headers'Connection'.casecmp('close') == 0 - headers.has_key?('Content-Length') - end - end -end - -def none_match_socket - io = StringIO.new - io << "Cache-Control: max-age=0\n" - io << "Content-Type: text/html\n" - io << "Date: Xxx, 00 Xxx 0000 00:00:00 GMT\n" - io << "Expires: Xxx, 00 Xxx 0000 00:00:00 GMT\n" - io << "Last-Modified: Xxx, 00 Xxx 0000 00:00:00 GMT\n" - io << "Server: xxx\n" - io << "\n\n" - io.rewind - io -end - -Formatador.display_line('none_match') -Formatador.indent do - Tach.meter(10_000) do - tach('compare on read') do - socket, headers = none_match_socket, {} - until ((data = socket.readline).chop!).empty? - key, value = data.split(': ') - headerskey = value - (key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0) - (key.casecmp('Connection') == 0) && (value.casecmp('close') == 0) - (key.casecmp('Content-Length') == 0) - end - end - - tach('original') do - socket, headers = none_match_socket, {} - until ((data = socket.readline).chop!).empty? - key, value = data.split(': ') - headerskey = value - end - headers.has_key?('Transfer-Encoding') && headers'Transfer-Encoding'.casecmp('chunked') == 0 - headers.has_key?('Connection') && headers'Connection'.casecmp('close') == 0 - headers.has_key?('Content-Length') - end - end -end \ No newline at end of file
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/headers_split_vs_match.rb
Deleted
@@ -1,34 +0,0 @@ -require 'rubygems' -require 'tach' - -data = "Content-Length: 100" -Tach.meter(1_000_000) do - tach('regex') do - data.match(/(.*):\s(.*)/) - header = $1, $2 - end - tach('split') do - header = data.split(': ', 2) - end - tach('split regex') do - header = data.split(/:\s*/, 2) - end -end - -# +-------------+----------+ -# | tach | total | -# +-------------+----------+ -# | split regex | 5.940233 | -# +-------------+----------+ -# | split | 7.327549 | -# +-------------+----------+ -# | regex | 8.736390 | -# +-------------+----------+ - -# +-------+----------+----------+ -# | tach | average | total | -# +-------+----------+----------+ -# | regex | 4.680451 | 4.680451 | -# +-------+----------+----------+ -# | split | 4.393218 | 4.393218 | -# +-------+----------+----------+
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/implicit_block-vs-explicit_block.rb
Deleted
@@ -1,98 +0,0 @@ -# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell - -require 'benchmark' - -iters = 1000000 - -def do_explicit(&block) - var = "hello" - block.call(var) -end - -def do_implicit - var = "hello" - yield(var) -end - -puts 'explicit block vs implicit' -Benchmark.bmbm do |x| - x.report('explicit') do - iters.times.each do - do_explicit {|var| - var << "goodbye" - } - end - end - - x.report('implicit') do - iters.times.each do - do_implicit {|var| - var << "goodbye" - } - end - end -end - -=begin -rvm exec bash -c 'echo && echo $RUBY_VERSION && echo && ruby implicit_block-vs-explicit_block.rb' - -jruby-1.5.6 - -explicit block vs implicit -Rehearsal -------------------------------------------- -explicit 1.163000 0.000000 1.163000 ( 1.106000) -implicit 0.499000 0.000000 0.499000 ( 0.499000) ------------------------------------ total: 1.662000sec - - user system total real -explicit 0.730000 0.000000 0.730000 ( 0.730000) -implicit 0.453000 0.000000 0.453000 ( 0.453000) - -macruby-0.7.1 - -explicit block vs implicit -Rehearsal -------------------------------------------- -explicit 5.070000 0.130000 5.200000 ( 3.546388) -implicit 3.140000 0.050000 3.190000 ( 2.255986) ------------------------------------ total: 8.390000sec - - user system total real -explicit 5.340000 0.140000 5.480000 ( 3.774963) -implicit 3.170000 0.060000 3.230000 ( 2.279951) - -rbx-head - -explicit block vs implicit -Rehearsal -------------------------------------------- -explicit 1.270136 0.006507 1.276643 ( 1.181588) -implicit 0.839831 0.002203 0.842034 ( 0.820849) ------------------------------------ total: 2.118677sec - - user system total real -explicit 0.960593 0.001526 0.962119 ( 0.966404) -implicit 0.700361 0.001126 0.701487 ( 0.703591) - -ruby-1.8.7-p330 - -explicit block vs implicit -Rehearsal -------------------------------------------- -explicit 3.970000 0.000000 3.970000 ( 3.985157) -implicit 1.560000 0.000000 1.560000 ( 1.567599) ------------------------------------ total: 5.530000sec - - user system total real -explicit 3.990000 0.010000 4.000000 ( 4.002637) -implicit 1.560000 0.000000 1.560000 ( 1.560901) - -ruby-1.9.2-p136 - -explicit block vs implicit -Rehearsal -------------------------------------------- -explicit 2.620000 0.010000 2.630000 ( 2.633762) -implicit 1.080000 0.000000 1.080000 ( 1.076809) ------------------------------------ total: 3.710000sec - - user system total real -explicit 2.630000 0.010000 2.640000 ( 2.637658) -implicit 1.070000 0.000000 1.070000 ( 1.073589) -=end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/merging.rb
Deleted
@@ -1,21 +0,0 @@ -require 'rubygems' -require 'tach' - -Tach.meter(10_000) do - - tach('merge') do - default = { :a => 1, :b => 2 } - override = { :b => 3, :c => 4 } - override = default.merge(override) - end - - tach('loop') do - default = { :a => 1, :b => 2 } - override = { :b => 3, :c => 4 } - for key, value in default - overridekey ||= defaultkey - end - override - end - -end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/single_vs_double_quotes.rb
Deleted
@@ -1,21 +0,0 @@ -require 'rubygems' -require 'tach' - -Tach.meter(1_000_000) do - tach('double') do - "path" - end - tach('single') do - 'path' - end -end - -# double, single -# -# +--------+----------+ -# | tach | total | -# +--------+----------+ -# | single | 0.416340 | -# +--------+----------+ -# | double | 0.416570 | -# +--------+----------+
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/string_ranged_index.rb
Deleted
@@ -1,87 +0,0 @@ -# Copied from my benchmark_hell repo: github.com/sgonyea/benchmark_hell - -require 'benchmark' - -iters = 1000000 - -string = "Test String OMG" - -puts 'String ranged index vs. "coordinates"' -Benchmark.bmbm do |x| - x.report('ranged index') do - iters.times.each do - text = string2..9 - end - end - - x.report('coordinates') do - iters.times.each do - text = string2, 9 - end - end -end - -=begin -rvm exec bash -c 'echo && echo $RUBY_VERSION && echo && ruby string_ranged_index.rb' - - -jruby-1.5.6 - -String ranged index vs. "coordinates" -Rehearsal ------------------------------------------------ -ranged index 0.419000 0.000000 0.419000 ( 0.372000) -coordinates 0.167000 0.000000 0.167000 ( 0.167000) ---------------------------------------- total: 0.586000sec - - user system total real -ranged index 0.158000 0.000000 0.158000 ( 0.159000) -coordinates 0.125000 0.000000 0.125000 ( 0.125000) - -macruby-0.7.1 - -String ranged index vs. "coordinates" -Rehearsal ------------------------------------------------ -ranged index 1.490000 0.030000 1.520000 ( 1.061326) -coordinates 1.410000 0.030000 1.440000 ( 0.973640) ---------------------------------------- total: 2.960000sec - - user system total real -ranged index 1.520000 0.030000 1.550000 ( 1.081424) -coordinates 1.480000 0.030000 1.510000 ( 1.029214) - -rbx-head - -String ranged index vs. "coordinates" -Rehearsal ------------------------------------------------ -ranged index 1.333304 0.009398 1.342702 ( 1.229629) -coordinates 0.306087 0.000603 0.306690 ( 0.303538) ---------------------------------------- total: 1.649392sec - - user system total real -ranged index 0.923626 0.001597 0.925223 ( 0.927411) -coordinates 0.298910 0.000533 0.299443 ( 0.300255) - -ruby-1.8.7-p330 - -String ranged index vs. "coordinates" -Rehearsal ------------------------------------------------ -ranged index 0.730000 0.000000 0.730000 ( 0.738612) -coordinates 0.660000 0.000000 0.660000 ( 0.660689) ---------------------------------------- total: 1.390000sec - - user system total real -ranged index 0.750000 0.000000 0.750000 ( 0.746172) -coordinates 0.640000 0.000000 0.640000 ( 0.640687) - -ruby-1.9.2-p136 - -String ranged index vs. "coordinates" -Rehearsal ------------------------------------------------ -ranged index 0.670000 0.000000 0.670000 ( 0.679046) -coordinates 0.620000 0.000000 0.620000 ( 0.622257) ---------------------------------------- total: 1.290000sec - - user system total real -ranged index 0.680000 0.000000 0.680000 ( 0.686510) -coordinates 0.620000 0.000000 0.620000 ( 0.624269) -=end
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/strip_newline.rb
Deleted
@@ -1,115 +0,0 @@ -# require 'benchmark' -# -# COUNT = 1_000_000 -# data = "Content-Length: 100\r\n" -# Benchmark.bmbm(25) do |bench| -# bench.report('chomp') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.chomp -# end -# end -# bench.report('chomp!') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.chomp! -# end -# end -# bench.report('chop') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.chop -# end -# end -# bench.report('chop!') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.chop! -# end -# end -# bench.report('strip') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.strip -# end -# end -# bench.report('strip!') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data.strip! -# end -# end -# bench.report('index') do -# COUNT.times do -# data = "Content-Length: 100\r\n" -# data0..-3 -# end -# end -# end - - - -# Rehearsal ------------------------------------------------------------ -# chomp 0.640000 0.000000 0.640000 ( 0.644043) -# chomp! 0.530000 0.000000 0.530000 ( 0.531415) -# chop 0.620000 0.000000 0.620000 ( 0.624321) -# chop! 0.500000 0.000000 0.500000 ( 0.509146) -# strip 0.640000 0.000000 0.640000 ( 0.638785) -# strip! 0.530000 0.000000 0.530000 ( 0.532196) -# index 0.740000 0.000000 0.740000 ( 0.745742) -# --------------------------------------------------- total: 4.200000sec -# -# user system total real -# chomp 0.640000 0.010000 0.650000 ( 0.647287) -# chomp! 0.530000 0.000000 0.530000 ( 0.532868) -# chop 0.630000 0.000000 0.630000 ( 0.628236) -# chop! 0.520000 0.000000 0.520000 ( 0.522950) -# strip 0.640000 0.000000 0.640000 ( 0.646328) -# strip! 0.520000 0.000000 0.520000 ( 0.532715) -# index 0.740000 0.010000 0.750000 ( 0.771277) - -require 'rubygems' -require 'tach' - -data = "Content-Length: 100\r\n" -Tach.meter(1_000_000) do - tach('chomp') do - data.dup.chomp - end - tach('chomp!') do - data.dup.chomp! - end - tach('chop') do - data.dup.chop - end - tach('chop!') do - data.dup.chop! - end - tach('strip') do - data.dup.strip - end - tach('strip!') do - data.dup.strip! - end - tach('index') do - data.dup0..-3 - end -end - -# +--------+----------+----------+ -# | tach | average | total | -# +--------+----------+----------+ -# | chomp | 1.444547 | 1.444547 | -# +--------+----------+----------+ -# | chomp! | 1.276813 | 1.276813 | -# +--------+----------+----------+ -# | chop | 1.422744 | 1.422744 | -# +--------+----------+----------+ -# | chop! | 1.240941 | 1.240941 | -# +--------+----------+----------+ -# | strip | 1.444776 | 1.444776 | -# +--------+----------+----------+ -# | strip! | 1.266459 | 1.266459 | -# +--------+----------+----------+ -# | index | 1.557975 | 1.557975 | -# +--------+----------+----------+ \ No newline at end of file
View file
_service:tar_scm:excon-0.62.0.gem/data/benchmarks/vs_stdlib.rb
Deleted
@@ -1,82 +0,0 @@ -require 'rubygems' if RUBY_VERSION < '1.9' - -require 'sinatra/base' -require 'tach' - -require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'excon') - -module Excon - class Server < Sinatra::Base - - def self.run - Rack::Handler::WEBrick.run( - Excon::Server.new, - :Port => 9292, - :AccessLog => , - :Logger => WEBrick::Log.new(nil, WEBrick::Log::ERROR) - ) - end - - get '/data/:amount' do |amount| - 'x' * amount.to_i - end - - end -end - -def with_server(&block) - pid = Process.fork do - Excon::Server.run - end - loop do - sleep(1) - begin - Excon.get('http://localhost:9292/api/foo') - break - rescue - end - end - yield -ensure - Process.kill(9, pid) -end - -require 'net/http' -require 'open-uri' - -url = 'http://localhost:9292/data/1000' - -with_server do - - Tach.meter(100) do - - tach('Excon') do - Excon.get(url).body - end - -# tach('Excon (persistent)') do |times| -# excon = Excon.new(url) -# times.times do -# excon.request(:method => 'get').body -# end -# end - - tach('Net::HTTP') do - # Net::HTTP.get('localhost', '/data/1000', 9292) - Net::HTTP.start('localhost', 9292) {|http| http.get('/data/1000').body } - end - -# tach('Net::HTTP (persistent)') do |times| -# Net::HTTP.start('localhost', 9292) do |http| -# times.times do -# http.get('/data/1000').body -# end -# end -# end - -# tach('open-uri') do -# open(url).read -# end - - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/changelog.txt
Deleted
@@ -1,1083 +0,0 @@ -0.62.0 2018-03-27 -================= - -remove binmode call for StringIO objects - -0.61.0 2018-03-16 -================= - -use default ports for sockets if none specified -add ruby 2.4 and 2.5 to ci testing -follow relative location redirects - -0.60.0 2017-12-15 -================= - -add requests_in_batches -cleanup rakefile, gemfile, etc -add logger/logger= and logging instrumentor -rewind response_block in idempotent instrumentor - - -0.59.0 2017-09-05 -================= - -fix backtick vs quote in error message -fix socket pooling to be per-connection instead of per thread -fix tests to ignore proxy env settings - -0.58.0 08/01/2017 -================= - -remove unused error -add retry_interval and related settings for backoff - -0.57.1 06/30/2017 -================= - -fix remote-ip setting to prevent off-by-one issue - -0.57.0 06/14/2017 -================= - -add client_key_data and client_cert_data to valid keys -allow passing explicit host to unix sockets - -0.56.0 05/31/2017 -================= - -fix proxy parse errors -fix url-escaped proxy creds for ssl - -0.55.0 02/07/2017 -================= - -fix minor readme error -update bundled certs -update self-signed certs -update to test with ruby 2.3.3 -fix unitialized ResponseParseError error -add missing 'spec_helper' require in tests -add missing 'time' require in tests -use unescape_uri for user/pass in Authorization header -use secure rubygems source uri -update gemnasium badge -update fury badge -update travis badge -update gittip badge - -0.54.0 10/17/2016 -================= - -add howsmyssl rake task for sanity checking -update default ciphers to mozilla intermediate list -fix typo in changelog - -0.53.0 09/27/2016 -================= - -add ability to pass ssl options as strings -progress towards rspec -update bundled certs - -0.52.0 08/22/2016 -================= - -freeze string literals -move toward interpolation, over concatenation (frozen string related) -start conversion toward rspec -move user/pass authorization header setting to request level - -0.51.0 07/08/2016 -================= - -tweak new errors to be an alias rather than inherit - -0.50.1 06/28/2016 -================= - -re-add some missing errors from refactoring - -0.50.0 06/28/2016 -================= - -expand readme -refactor errors for consistancy -optionally allow unstubbed requests -parse/verify path as well as host for connection - -0.49.0 03/28/2016 -================= - -fix nonblock ssl socket connect timeout handling -fix README debug example -make unique class for certificate errors -connection logic cleanup -change stubs back to global (with local option via defaults) -specific handling for set-cookie header exceptions - -0.48.0 03/07/2016 -================= - -optimize by writing part of body with headers when it fits in a chunk - -0.47.0 02/29/2016 -================= - -fix bundled certs -fix instrumentors to allow recording timings - -0.46.0 02/26/2016 -================= - -empty host header for unix sockets -raise EOFError on unexpectedly read nil -add host/path/port to response -keep cookies through redirects -fix to skip decompressing empty bodies -fix escaping for query string -README improvements -fix SocketError initializer -fix incorrect error class usage - -0.45.4 07/13/2015 -================= - -fix undefined errors in error handling -ignore empty proxy values - -0.45.3 04/21/2015 -================= - -guard warning about openssl versions in case constant undefined -ensure rackup listens properly, fixes local tests - -0.45.2 04/16/2015 -================= - -add raw_status reader -improved tests around response/status -rescue IO::WaitWritable for SSL sockets also -indentation fixes -tighten rescue in ssl socket connect to better report non-timeouts -rescue EAGAIN and EWOULDBLOCK for non-blocking connects - -0.45.1 03/27/2015 -================= - -fix scope for readline buffer, fixes dropped initial characters - -0.45.0 03/26/2015 -================= - -prefer default SSL config to ENV, when available -document instrumentor deviation from rails format -better error/warning around openssl 1.0.2 bug -fix nonblocking ssl connect to not have tight loop -also remove user/pass when following redirects - -0.44.4 03/04/2015 -================= - -update bundled certs -loosen travis versions, to get ~> type follow-the-leader behavior -fix syntax issue in ruby 2.2.1 - -0.44.3 02/24/2015 -================= - -don't pass body when following GET redirects -fix error rescue case to properly reference error object - -0.44.2 02/11/2015 -================= - -simplify data:debug logic -catch nonblock errors around readline - - -0.44.1 02/01/2015
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/excon/error_spec.rb
Deleted
@@ -1,139 +0,0 @@ -require 'spec_helper' - -describe Excon::Error do - # Regression against e300458f2d9330cb265baeb8973120d08c665d9 - describe '#status_errors' do - describe '.keys ' do - expected = - 100, - 101, - (200..206).to_a, - (300..307).to_a, - (400..417).to_a, - 422, - 429, - (500..504).to_a - .flatten - - it('returns the pertinent HTTP error numbers') do - expected.flatten == Excon::Error.status_errors.keys - end - end - end - - describe '#new' do - it('returns an Excon::Error') do - expect(Excon::Error.new('bar').class == Excon::Error).to be true - end - it('raises errors for bad URIs') do - expect { Excon.new('foo') }.to raise_error(ArgumentError) - end - - it('raises errors for bad paths') do - expect { Excon.new('http://localhost', path: "foo\r\nbar: baz") }.to raise_error(URI::InvalidURIError) - end - end - - context 'when remaining backwards compatible' do - describe '#new' do - it 'should raise standard error and catch standard error' do - expect { raise Excon::Error::Client, 'foo' }.to raise_error(Excon::Error) - end - - it 'should raise legacy errors and catch legacy errors' do - expect do - raise Excon::Errors::Error, 'bar' - end.to raise_error(Excon::Errors::Error) - end - - it 'should raise standard error and catch legacy errors' do - expect do - raise Excon::Error::NotFound, 'bar' - end.to raise_error(Excon::Errors::Error) - end - end - - describe '#status_error' do - it 'should raise with status_error() and catch with standard error' do - expect do - raise Excon::Error.status_error({ expects: 200 }, status: 400) - end.to raise_error(Excon::Error) - end - - it 'should raise with status_error() and catch with legacy error' do - expect do - raise Excon::Error.status_error({ expects: 200 }, status: 400) - end.to raise_error(Excon::Errors::BadRequest) - end - - it 'should raise with legacy status_error() and catch with standard' do - expect do - raise Excon::Errors.status_error({ expects: 200 }, status: 400) - end.to raise_error(Excon::Error) - end - end - end - - context 'when exceptions are rescued' do - include_context("test server", :exec, 'error.rb', :before => :start, :after => :stop ) - - context 'when :debug_request and :debug_response are switched off' do - it('exception message does not include response or response info') do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', expects: 200) - rescue Excon::Errors::HTTPStatusError => err - truth = - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - !err.message.include?('excon.error.request') && - !err.message.include?('excon.error.response') - expect(truth).to be true - end - end - end - - context 'when :debug_request and :debug_response are switched on' do - it 'exception message includes request and response info' do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', expects: 200, - debug_request: true, debug_response: true) - rescue Excon::Errors::HTTPStatusError => err - truth = - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - err.message.include?('excon.error.request') && - err.message.include?('excon.error.response') - expect(truth).to be true - end - end - end - - context 'when only :debug_request is turned on' do - it('exception message includes only request info') do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', expects: 200, - debug_request: true) - rescue Excon::Errors::HTTPStatusError => err - truth = - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - err.message.include?('excon.error.request') && - !err.message.include?('excon.error.response') - expect(truth).to be true - end - end - end - - context 'when only :debug_response is turned on ' do - it('exception message includes only response info') do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', expects: 200, - debug_response: true) - rescue Excon::Errors::HTTPStatusError => err - truth = - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - !err.message.include?('excon.error.request') && - err.message.include?('excon.error.response') - expect(truth).to be true - end - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/excon/test/server_spec.rb
Deleted
@@ -1,28 +0,0 @@ -require 'spec_helper' - -describe Excon::Test::Server do - - context 'when the web server is webrick' do - it_should_behave_like "a excon test server", :webrick, 'basic.ru' - end - - - context 'when the web server is unicorn' do - context 'bound to a tcp socket' do - it_should_behave_like "a excon test server", :unicorn, 'streaming.ru' - end - - context "bound to a unix socket" do - socket_uri = 'unix:///tmp/unicorn.socket' - it_should_behave_like "a excon test server", :unicorn, 'streaming.ru', socket_uri - end - end - - context 'when the web server is puma' do - it_should_behave_like "a excon test server", :puma, 'streaming.ru' - end - - context 'when the web server is a executable' do - it_should_behave_like "a excon test server", :exec, 'good.rb' - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/excon_spec.rb
Deleted
@@ -1,7 +0,0 @@ -require 'spec_helper' - -describe Excon do - it 'has a version number' do - expect(Excon::VERSION).not_to be nil - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/helpers/file_path_helpers.rb
Deleted
@@ -1,22 +0,0 @@ -# Todo: s/tests/specs when migration is complete -def get_abs_path(*parts) - File.join(File.expand_path('../../..', __FILE__), 'tests', *parts) -end - -def data_path(*parts) - get_abs_path('data', *parts) -end - -def rackup_path(*parts) - get_abs_path('rackups', *parts) -end - -def webrick_path(*parts) rackup_path(*parts); end - -def unicorn_path(*parts) rackup_path(*parts); end - -def puma_path(*parts) rackup_path(*parts); end - -def exec_path(*parts) - get_abs_path('servers', *parts) -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/requests/basic_spec.rb
Deleted
@@ -1,40 +0,0 @@ -require 'spec_helper' - -describe Excon::Connection do - include_context('test server', :webrick, 'basic.ru', before: :start, after: :stop) - context 'when an explicit uri is passed' do - let(:conn) do - Excon::Connection.new(host: '127.0.0.1', - hostname: '127.0.0.1', - nonblock: false, - port: 9292, - scheme: 'http', - ssl_verify_peer: false) - end - - describe '.new' do - it 'returns an instance' do - expect(conn).to be_instance_of Excon::Connection - end - end - - context "when :method is :get and :path is /content-length/100" do - describe "#request" do - let(:response) do - response = conn.request(method: :get, path: '/content-length/100') - end - it 'returns an Excon::Response' do - expect(response).to be_instance_of Excon::Response - end - describe Excon::Response do - describe '#status' do - it 'returns 200' do - expect(response.status).to eq 200 - end - end - end - end - end - include_examples 'a basic client' - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/requests/eof_requests_spec.rb
Deleted
@@ -1,36 +0,0 @@ -require 'spec_helper' - -describe Excon do - context "when dispatching requests" do - context('to a server that does not supply response headers') do - include_context("test server", :exec, 'bad.rb', :before => :start, :after => :stop ) - before(:all) do - @conn = Excon.new('http://127.0.0.1:9292') - end - - context('when no block is given') do - it 'should rescue from an EOFError and return response' do - body = @conn.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking').body - expect(body).to eq 'hello' - end - end - - context('when a block is given') do - it 'should rescue from EOFError and return response' do - body = "" - response_block = lambda {|chunk, remaining, total| body << chunk } - @conn.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking', :response_block => response_block) - expect(body).to eq 'hello' - end - end - end - - context('to a server that prematurely aborts the request with no response') do - include_context("test server", :exec, 'eof.rb', :before => :start, :after => :stop ) - - it 'should raise an EOFError' do - expect { Excon.get('http://127.0.0.1:9292/eof') }.to raise_error(Excon::Errors::SocketError) - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/requests/unix_socket_spec.rb
Deleted
@@ -1,46 +0,0 @@ -require "spec_helper" - -describe Excon::Connection do - context "when speaking to a UNIX socket" do - context "Host header handling" do - before do - responder = ->(req) do - { - body: req:headers.to_json, - status: 200, - } - end - - @original_mock = Excon.defaults:mock - Excon.defaults:mock = true - Excon.stub({}, responder) - end - - after do - Excon.defaults:mock = @original_mock - end - - it "sends an empty Host= by default" do - conn = Excon::Connection.new( - scheme: "unix", - socket: "/tmp/x.sock", - ) - - headers = JSON.parse(conn.get(path: "/path").body) - - expect(headers"Host").to eq("") - end - - it "doesn't overwrite an explicit Host header" do - conn = Excon::Connection.new( - scheme: "unix", - socket: "/tmp/x.sock", - ) - - headers = JSON.parse(conn.get(path: "/path", headers: { "Host" => "localhost" }).body) - - expect(headers"Host").to eq("localhost") - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/spec_helper.rb
Deleted
@@ -1,24 +0,0 @@ -require 'excon' -require 'excon/test/server' -require 'json' - -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - config.expect_with :rspec do |expectations| - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - config.mock_with :rspec do |mocks| - mocks.verify_partial_doubles = true - end - - if config.files_to_run.one? - config.default_formatter = 'doc' - end -end - -# Load helpers -Dir"./spec/helpers/**/*.rb".sort.each { |f| require f} - -# Load shared examples and contexts -Dir"./spec/support/**/*.rb".sort.each { |f| require f}
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/support/shared_contexts/test_server_context.rb
Deleted
@@ -1,83 +0,0 @@ -# TODO: Clean up this doc and dry up the conditionals -# -# Required params: -# plugin (e.g., webrick, unicorn, etc) -# file (e.g. a rackup ) -# -# Optional params: -# optional paramters may given as a hash -# opts may contain a bind argument -# opts may also contain before and after options -# -# In its simplest form: -# { :before => :start, :after => :stop } -# -# With lambdas, which recieve @server as an argument -# { before: lambda {|s| s.start }, after: lambda { |s| s.stop} } -# -# In both the cases above, before defaults to before(:all) -# This can be circumvented with a Hash -# { before: { :context => :start }, after: { :context => :stop } } -# or -# { before: { context: lambda { |s| s.start } }, after: { context: lambda { |s| s.stop } } } - -shared_context "test server" do |plugin, file, opts = {}| - plugin = plugin.to_sym unless plugin.is_a? Symbol - if plugin == :unicorn && RUBY_PLATFORM == "java" - before { skip("until unicorn supports jruby") } - end - abs_file = Object.send("#{plugin}_path", file) - args = { plugin => abs_file} - args:bind = opts:bind if opts.key? :bind - - - before_hook = opts.key?(:before) && (opts:before.is_a?(Symbol) || opts:before.is_a?(Proc) || opts:before.is_a?(Hash)) - - if before_hook && opts:before.is_a?(Hash) - event = opts:before.keys.first - before(event) { - @server = Excon::Test::Server.new(args) - if opts:beforeevent.is_a? Symbol - @server.send(opts:beforeevent) - else - opts:beforeevent.call(@server) - end - } - elsif - before(:all) { - @server = Excon::Test::Server.new(args) - before_hook = opts.key?(:before) && (opts:before.is_a?(Symbol) || opts:before.is_a?(Proc) || opts:before.is_a?(Hash)) - - if before_hook - if opts:before.is_a? Symbol - @server.send(opts:before) - else - opts:before.call(@server) - end - end - } - end - - after_hook = opts.key?(:after) && (opts:after.is_a?(Symbol) || opts:after.is_a?(Proc) || opts:after.is_a?(Hash)) - - if after_hook && opts:after.is_a?(Hash) - event = opts:after.keys.first - after(event) { - if opts:afterevent.is_a? Symbol - @server.send(opts:afterevent) - else - opts:afterevent.call(@server) - end - } - elsif after_hook - after(:all) { - if opts:after.is_a? Symbol - @server.send(opts:after) - elsif opts:after.is_a? Hash - - else - opts:after.call(@server) - end - } - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/support/shared_examples/shared_example_for_clients.rb
Deleted
@@ -1,218 +0,0 @@ -require 'time' - -shared_examples_for 'a basic client' do |url = 'http://127.0.0.1:9292', opts = {}| - # TODO: Ditch iterator and manually write a context for each set of options - (true, false * 2).combination(2).to_a.uniq.each do |nonblock, persistent| - context "when nonblock is #{nonblock} and persistent is #{persistent}" do - opts = opts.merge(ssl_verify_peer: false, nonblock: nonblock, persistent: persistent) - - let(:conn) { Excon.new(url, opts) } - - context 'when :method is get and :path is /content-length/100' do - describe '#request' do - let(:response) do - conn.request(method: :get, path: '/content-length/100') - end - - it 'returns an Excon::Response' do - expect(response).to be_instance_of Excon::Response - end - describe Excon::Response do - describe '#status' do - it 'returns 200' do - expect(response.status).to eq 200 - end - - it '#status returns 200' do - expect(response:status).to eq 200 - end - end - describe '#headers' do - it '"Content-Length" returns 100' do - expect(response.headers'Content-Length').to eq '100' - end - it '"Content-Type" returns "text/html;charset=utf-8"' do - expect(response.headers'Content-Type').to eq 'text/html;charset=utf-8' - end - - it "'Date' returns a valid date" do - if RUBY_PLATFORM == 'java' && conn.data:scheme == Excon::UNIX - skip('until puma responds with a date header') - else - time = Time.parse(response.headers'Date') - expect(time.is_a?(Time)).to be true - end - end - - it "'Server' matches /^WEBrick/" do - pending('until unix_socket response has server header') if conn.data:scheme == Excon::UNIX - expect(!!(response.headers'Server' =~ /^WEBrick/)).to be true - end - - it "'Custom' returns Foo: bar" do - expect(response.headers'Custom').to eq 'Foo: bar' - end - end - describe '#remote_ip' do - it 'returns 127.0.0.1' do - pending('until pigs can fly') if conn.data:scheme == Excon::UNIX - expect(response.remote_ip).to eq '127.0.0.1' - end - end - end - - context('when tcp_nodelay is true') do - describe '#request' do - response = nil - options = opts.merge(ssl_verify_peer: false, nonblock: nonblock, tcp_nodelay: true) - connection = Excon.new(url, options) - - it 'returns an Excon::Response' do - expect do - response = connection.request(method: :get, path: '/content-length/100') - end.to_not raise_error - end - - describe Excon::Response do - describe '#body' do - describe '.status' do - it '#returns 200' do - expect(response.status).to eq 200 - end - end - end - end - end - end - end - - context 'when utilizing deprecated block usage' do - describe '#request' do - data = - it 'yields with a chunk, remaining length, and total length' do - expect do - conn.request(method: :get, path: '/content-length/100') do |chunk, remaining_length, total_length| - data = chunk, remaining_length, total_length - end - end.to_not raise_error - end - it 'completes with expected data' do - expect(data).to eq 'x' * 100, 0, 100 - end - end - end - - context 'when utilizing response_block usage' do - describe '#request' do - data = - it 'yields a chunk, remaining length, and total_length' do - response_block = lambda do |chunk, remaining_length, total_length| - data = chunk, remaining_length, total_length - end - expect do - conn.request(method: :get, path: '/content-length/100', response_block: response_block) - end.to_not raise_error - end - it 'completes with expected data' do - expect(data).to eq 'x' * 100, 0, 100 - end - end - end - context 'when method is :post' do - context 'when :path is /body-sink' do - context 'when a body parameter is supplied' do - response = nil - it 'returns an Excon::Response' do - response = conn.request(method: :post, path: '/body-sink', headers: { 'Content-Type' => 'text/plain' }, body: 'x' * 5_000_000) - expect(response).to be_instance_of Excon::Response - end - describe Excon::Response do - describe '#body' do - it 'equals "5000000"' do - expect(response.body).to eq '5000000' - end - end - end - end - context 'when the body parameter is an empty string' do - response = nil - - it 'returns an Excon::Response' do - response = conn.request(method: :post, path: '/body-sink', headers: { 'Content-Type' => 'text/plain' }, body: '') - expect(response).to be_instance_of Excon::Response - end - describe Excon::Response do - describe '#body' do - it 'equals "0"' do - expect(response.body).to eq '0' - end - end - end - end - end - - context 'when :path is /echo' do - context('when a file handle is the body paramter') do - describe Excon::Response do - it '#body equals "x" * 100 + "\n"' do - file_path = data_path('xs') - response = conn.request(method: :post, path: '/echo', body: File.open(file_path)) - expect(response.body).to eq 'x' * 100 + "\n" - end - end - end - - context 'when a string is the body paramter' do - it 'does not change the econding of the body' do - skip unless RUBY_VERSION >= '1.9' - - string_body = '¥£€' - expect do - conn.request(method: :post, path: '/echo', body: string_body) - end.to_not change { string_body.encoding } - end - - context 'without request_block' do - describe Excon::Response do - it "#body equals 'x' * 100)" do - response = conn.request(method: :post, path: '/echo', body: 'x' * 100) - expect(response.body).to eq 'x' * 100 - end - end - end - - context 'when a request_block paramter is supplied' do - describe Excon::Response do - it "#body equals'x' * 100" do - data = 'x' * 100 - request_block = lambda do - data.shift.to_s - end - response = conn.request(method: :post, path: '/echo', request_block: request_block) - expect(response.body).to eq 'x' * 100 - end - end - end - - context('when a multi-byte string is the body paramter') do - body = "\xC3\xBC" * 100 - headers = { 'Custom' => body.dup }
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/support/shared_examples/shared_example_for_streaming_clients.rb
Deleted
@@ -1,20 +0,0 @@ -shared_examples_for 'a streaming client' do |endpoint, timeout| - ret = - timing = 'response times ok' - start = Time.now - block = lambda do |c,r,t| - # add the response - ret.push(c) - # check if the timing is ok - # each response arrives after timeout and before timeout + 1 - cur_time = Time.now - start - if cur_time < ret.length * timeout or cur_time > (ret.length+1) * timeout - timing = 'response time not ok!' - end - end - it "gets a response in less than or equal to #{(timeout*3).round(2)} seconds" do - Excon.get(endpoint, :response_block => block) - # validate the final timing - expect((Time.now - start <= timeout*3) == true && timing == 'response times not ok!').to be false - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/spec/support/shared_examples/shared_example_for_test_servers.rb
Deleted
@@ -1,16 +0,0 @@ -shared_examples_for "a excon test server" do |plugin, file| - - include_context("test server", plugin, file) - - it "returns an instance" do - expect(@server).to be_instance_of Excon::Test::Server - end - - it 'starts the server' do - expect(@server.start).to be true - end - - it 'stops the server' do - expect(@server.stop).to be true - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/authorization_header_tests.rb
Deleted
@@ -1,29 +0,0 @@ -Shindo.tests('Excon basics (Authorization data redacted)') do - with_rackup('basic_auth.ru') do - cases = - 'user & pass', 'http://user1:pass1@foo.com/', 'Basic dXNlcjE6cGFzczE=', - 'email & pass', 'http://foo%40bar.com:pass1@foo.com/', 'Basic Zm9vQGJhci5jb206cGFzczE=', - 'user no pass', 'http://three_user@foo.com/', 'Basic dGhyZWVfdXNlcjo=', - 'pass no user', 'http://:derppass@foo.com/', 'Basic OmRlcnBwYXNz' - - cases.each do |desc,url,auth_header| - conn = nil - - test("authorization header concealed for #{desc}") do - conn = Excon.new(url) - !conn.inspect.include?(auth_header) - end - - if conn.data:password - test("password param concealed for #{desc}") do - !conn.inspect.include?(conn.data:password) - end - end - - test("password param remains correct for #{desc}") do - conn.data:password == URI.parse(url).password - end - - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/bad_tests.rb
Deleted
@@ -1,47 +0,0 @@ -Shindo.tests('Excon bad server interaction') do - - with_server('bad') do - - tests('bad server: causes EOFError') do - - tests('with no content length and no chunking') do - tests('without a block') do - tests('response.body').returns('hello') do - connection = Excon.new('http://127.0.0.1:9292') - - connection.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking').body - end - end - - tests('with a block') do - tests('body from chunks').returns('hello') do - connection = Excon.new('http://127.0.0.1:9292') - - body = "" - response_block = lambda {|chunk, remaining, total| body << chunk } - - connection.request(:method => :get, :path => '/eof/no_content_length_and_no_chunking', :response_block => response_block) - - body - end - end - - end - - end - - end - - with_server('eof') do - - tests('eof server: causes EOFError') do - - tests('request').raises(Excon::Errors::SocketError) do - Excon.get('http://127.0.0.1:9292/eof') - end - - end - - end - -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/basic_tests.rb
Deleted
@@ -1,351 +0,0 @@ -require 'json' - -Shindo.tests('Excon basics') do - env_init - - with_rackup('basic.ru') do - basic_tests - - tests('explicit uri passed to connection') do - tests('GET /content-length/100').returns(200) do - connection = Excon::Connection.new({ - :host => '127.0.0.1', - :hostname => '127.0.0.1', - :nonblock => false, - :port => 9292, - :scheme => 'http', - :ssl_verify_peer => false - }) - response = connection.request(:method => :get, :path => '/content-length/100') - response:status - end - end - end -end - -Shindo.tests('Excon streaming basics') do - pending if RUBY_PLATFORM == 'java' # need to find suitable server for jruby - with_unicorn('streaming.ru') do - # expected values: the response, in pieces, and a timeout after each piece - res = %w{Hello streamy world} - timeout = 0.1 - - # expect the full response as a string - # and expect it to take a (timeout * pieces) seconds - tests('simple blocking request on streaming endpoint').returns(res.join(''),'response time ok') do - start = Time.now - ret = Excon.get('http://127.0.0.1:9292/streamed/simple').body - - if Time.now - start <= timeout*3 - ret, 'streaming response came too quickly' - else - ret, 'response time ok' - end - end - - # expect the full response as a string and expect it to - # take a (timeout * pieces) seconds (with fixed Content-Length header) - tests('simple blocking request on streaming endpoint with fixed length').returns(res.join(''),'response time ok') do - start = Time.now - ret = Excon.get('http://127.0.0.1:9292/streamed/fixed_length').body - - if Time.now - start <= timeout*3 - ret, 'streaming response came too quickly' - else - ret, 'response time ok' - end - end - - # expect each response piece to arrive to the body right away - # and wait for timeout until next one arrives - def timed_streaming_test(endpoint, timeout) - ret = - timing = 'response times ok' - start = Time.now - Excon.get(endpoint, :response_block => lambda do |c,r,t| - # add the response - ret.push(c) - # check if the timing is ok - # each response arrives after timeout and before timeout + 1 - cur_time = Time.now - start - if cur_time < ret.length * timeout or cur_time > (ret.length+1) * timeout - timing = 'response time not ok!' - end - end) - # validate the final timing - if Time.now - start <= timeout*3 - timing = 'final timing was not ok!' - end - ret, timing - end - - tests('simple request with response_block on streaming endpoint').returns(res,'response times ok') do - timed_streaming_test('http://127.0.0.1:9292/streamed/simple', timeout) - end - - tests('simple request with response_block on streaming endpoint with fixed length').returns(res,'response times ok') do - timed_streaming_test('http://127.0.0.1:9292/streamed/fixed_length', timeout) - end - - end -end - -Shindo.tests('Excon basics (Basic Auth Pass)') do - with_rackup('basic_auth.ru') do - basic_tests('http://test_user:test_password@127.0.0.1:9292') - user, pass, uri = 'test_user', 'test_password', 'http://127.0.0.1:9292'.map(&:freeze) - - tests('with frozen args').returns(200) do - connection = Excon.new(uri, :method => :get, :password => pass, :path => '/content-length/100', :user => user) - response = connection.request - response.status - end - - tests('with user/pass on request').returns(200) do - connection = Excon.new(uri, :method => :get, :path => '/content-length/100') - response = connection.request(:user => user, :password => pass) - response.status - end - - tests('with user/pass on connection and request').returns(200) do - connection = Excon.new(uri, :method => :get, :password => 'incorrect_password', :path => '/content-length/100', :user => 'incorrect_user') - response = connection.request(user: user, password: pass) - response.status - end - end -end - -Shindo.tests('Excon basics (Basic Auth Fail)') do - with_rackup('basic_auth.ru') do - cases = - 'correct user, no password', 'http://test_user@127.0.0.1:9292', - 'correct user, wrong password', 'http://test_user:fake_password@127.0.0.1:9292', - 'wrong user, correct password', 'http://fake_user:test_password@127.0.0.1:9292' - - cases.each do |desc,url| - tests("response.status for #{desc}").returns(401) do - connection = Excon.new(url) - response = connection.request(:method => :get, :path => '/content-length/100') - response.status - end - end - end -end - -Shindo.tests('Excon basics (ssl)') do - with_rackup('ssl.ru') do - basic_tests('https://127.0.0.1:9443') - end -end - -Shindo.tests('Excon ssl verify peer (ssl)') do - with_rackup('ssl.ru') do - connection = nil - test do - ssl_ca_file = File.join(File.dirname(__FILE__), 'data', '127.0.0.1.cert.crt') - connection = Excon.new('https://127.0.0.1:9443', :ssl_verify_peer => true, :ssl_ca_file => ssl_ca_file ) - true - end - - tests('response.status').returns(200) do - response = connection.request(:method => :get, :path => '/content-length/100') - - response.status - end - end - - with_rackup('ssl_mismatched_cn.ru') do - connection = nil - test do - ssl_ca_file = File.join(File.dirname(__FILE__), 'data', 'excon.cert.crt') - connection = Excon.new('https://127.0.0.1:9443', :ssl_verify_peer => true, :ssl_ca_file => ssl_ca_file, :ssl_verify_peer_host => 'excon' ) - true - end - - tests('response.status').returns(200) do - response = connection.request(:method => :get, :path => '/content-length/100') - - response.status - end - end -end - -Shindo.tests('Excon ssl verify peer (ssl cert store)') do - with_rackup('ssl.ru') do - connection = nil - test do - ssl_ca_cert = File.read(File.join(File.dirname(__FILE__), 'data', '127.0.0.1.cert.crt')) - ssl_cert_store = OpenSSL::X509::Store.new - ssl_cert_store.add_cert OpenSSL::X509::Certificate.new ssl_ca_cert - connection = Excon.new('https://127.0.0.1:9443', :ssl_verify_peer => true, :ssl_cert_store => ssl_cert_store ) - true - end - - tests('response.status').returns(200) do - response = connection.request(:method => :get, :path => '/content-length/100') - - response.status - end - end -end - -Shindo.tests('Excon basics (ssl file)','focus') do - with_rackup('ssl_verify_peer.ru') do - - tests('GET /content-length/100').raises(Excon::Errors::SocketError) do - connection = Excon::Connection.new({ - :host => '127.0.0.1', - :hostname => '127.0.0.1', - :nonblock => false,
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/batch_requests.rb
Deleted
@@ -1,133 +0,0 @@ -require 'shindo' - -Shindo.tests('Batch Requests') do - with_server('good') do - tests('with batch request size 2') do - returns(%w{ 1 2 1 2 }, 'batch request size 2') do - connection = Excon.new('http://127.0.0.1:9292') - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 2).map(&:body) - - ret.flatten - end - end - - tests('peristent with batch request size 2') do - returns(%w{ 1 2 3 4 }, 'persistent batch request size 2') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => true) - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 2).map(&:body) - - ret.flatten - end - end - - tests('with batch request size 3') do - returns(%w{ 1 2 3 1 }, 'batch request size 3') do - connection = Excon.new('http://127.0.0.1:9292') - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 3).map(&:body) - - ret.flatten - end - end - - tests('persistent with batch request size 3') do - returns(%w{ 1 2 3 4 }, 'persistent batch request size 3') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => true) - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 3).map(&:body) - - ret.flatten - end - end - - tests('with batch request size 4') do - returns(%w{ 1 2 3 4 }, 'batch request size 4') do - connection = Excon.new('http://127.0.0.1:9292') - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 4).map(&:body) - - ret.flatten - end - end - - tests('persistent with batch request size 4') do - returns(%w{ 1 2 3 4 }, 'persistent batch request size 4') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => true) - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 4).map(&:body) - - ret.flatten - end - end - - tests('with batch request size 8') do - returns(%w{ 1 2 3 4 }, 'batch request size 8') do - connection = Excon.new('http://127.0.0.1:9292') - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 8).map(&:body) - - ret.flatten - end - end - - tests('persistent with batch request size 8') do - returns(%w{ 1 2 3 4 }, 'persistent batch request size 8') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => true) - - ret = - ret << connection.batch_requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - , 8).map(&:body) - - ret.flatten - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/complete_responses.rb
Deleted
@@ -1,31 +0,0 @@ -Shindo.tests('Excon Response Validation') do - env_init - - with_server('good') do - tests('good responses with complete headers') do - 100.times do - res = Excon.get('http://127.0.0.1:9292/chunked/simple') - returns(true) { res.body == "hello world" } - returns(true) { res.status_line == "HTTP/1.1 200 OK\r\n" } - returns(true) { res.status == 200} - returns(true) { res.reason_phrase == "OK" } - returns(true) { res.remote_ip == "127.0.0.1" } - end - end - end - - with_server('error') do - tests('error responses with complete headers') do - 100.times do - res = Excon.get('http://127.0.0.1:9292/error/not_found') - returns(true) { res.body == "server says not found" } - returns(true) { res.status_line == "HTTP/1.1 404 Not Found\r\n" } - returns(true) { res.status == 404} - returns(true) { res.reason_phrase == "Not Found" } - returns(true) { res.remote_ip == "127.0.0.1" } - end - end - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/data/127.0.0.1.cert.crt
Deleted
@@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDUjCCAjqgAwIBAgIJAMw/PAoBSqk8MA0GCSqGSIb3DQEBCwUAMCQxEjAQBgNV -BAMTCTEyNy4wLjAuMTEOMAwGA1UEChMFZXhjb24wHhcNMTcwOTA1MTk0MzMwWhcN -MTgwOTA1MTk0MzMwWjAkMRIwEAYDVQQDEwkxMjcuMC4wLjExDjAMBgNVBAoTBWV4 -Y29uMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/PbsbAxwowMioOR4 -UGR/tDF4ul6TZSKtiYxYqe+xEhlgLzS7/9mQibkJAz2EKNNd+DR8XnkvB84WNWyL -DNeq1de3vZCgmN9W1oddoxbhNGKLSN6KmBxANaJzpbYHBHKJhErqGYeBoBf135UF -2hVh7oU9n4P5ozdnjpx3IlNh6coDwNmuGkpfGftL2UbOZOBuXM7E0mtOlTUTg3OF -tvITBcXf1iFNcLI9KrtEkvVsC3iHEis83y0V4sPSPxl+UYJI44XowjIQ9hxs2616 -GvITep2m/ydTnjwu/wn5OSnyNNRV+jEYzDfCSQ7MZxoLDm05RVRZJY1hJwizaP7N -a2pNuQIDAQABo4GGMIGDMB0GA1UdDgQWBBRdlYAjIjj58kiqr2bDwUxdsIPgMzBU -BgNVHSMETTBLgBRdlYAjIjj58kiqr2bDwUxdsIPgM6EopCYwJDESMBAGA1UEAxMJ -MTI3LjAuMC4xMQ4wDAYDVQQKEwVleGNvboIJAMw/PAoBSqk8MAwGA1UdEwQFMAMB -Af8wDQYJKoZIhvcNAQELBQADggEBAIN1e6jRgMI/PD/F5nMgZJZ5Zv9hPu8ID1v3 -Efy7hkNS7KXWLXLRbw9HVBscrNGDmX2l0oqx6WSjn6n8yFFMlI+zWAUZjuF+8PjC -fa/eFa3UPq8nPqhO6sQrB2ZlPX6ydW1yD4gNflJLhzmNehgytK2FnZabH0jytot2 -eaZl32yLu/7SmNEpyYNUWurkyB7tk77+7AiBQ9R4HCPWcrfdKic+XN5YNE5cZ+mm -YrHGxdS+5U848N6Qtj3B7fTuDn1K/WfpWKtR/RpP6k71eEZi7rufEuutcjPcUpwr -NzbvNobphr9vjCv9tbZgoAmKyBKOkLfj1gfv3HEPbFKOEYGZyBI= ------END CERTIFICATE-----
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/data/127.0.0.1.cert.key
Deleted
@@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpgIBAAKCAQEA/PbsbAxwowMioOR4UGR/tDF4ul6TZSKtiYxYqe+xEhlgLzS7 -/9mQibkJAz2EKNNd+DR8XnkvB84WNWyLDNeq1de3vZCgmN9W1oddoxbhNGKLSN6K -mBxANaJzpbYHBHKJhErqGYeBoBf135UF2hVh7oU9n4P5ozdnjpx3IlNh6coDwNmu -GkpfGftL2UbOZOBuXM7E0mtOlTUTg3OFtvITBcXf1iFNcLI9KrtEkvVsC3iHEis8 -3y0V4sPSPxl+UYJI44XowjIQ9hxs2616GvITep2m/ydTnjwu/wn5OSnyNNRV+jEY -zDfCSQ7MZxoLDm05RVRZJY1hJwizaP7Na2pNuQIDAQABAoIBAQCFqd+Q1B3sNKrm -gvKD4CaOSxm0uGZ/qQwzQuJSoOFaY+gr6VxxOz+hVhFKEgY0IENl9C3HKZdNM3sO -rZTnq0mMhtiCpNoHDPPwlURH+b3zlSJt1ZE8AKl47abX58/bbL33FjKOXMiElESJ -6E9YRbYid2rxT6XntU3V0B0vGQoConvcGN+6jtTvZInTLU+tuQTfw/GpB7AJcTej -I2/gWx1lQurfv5iGcOqwPOoLN7qMWGsXbFxEFgmD1VN3AiCPV/A+gq8xf2wccws9 -dNwqz1sbphbR1nl0gUwWP3PRQa31RqgOsGLj2EFtBqZio8zzyNN6WLbVSMZfiDUi -NIplFH6BAoGBAP/S5VKYkHCBJ+2QC9v42Bb8Ip6QC1oh+Sdm5geZuB72+xIWa6+1 -7Vw6DW+wDvEEDRICcl38iI60hq+H3TZRa35daDlUXEy66HNWwCxA//l+48Jvcx0x -03qQDeB3PZqewsbey+aL23Tli8Kl2g9njzjUgi7tSbTEwWTlmNdElTnRAoGBAP0j -hguvZNitFd0ScyHUr2VduWEPgsYVHcvzbUZ+UGga0zr2gfYwkVBiF7MZ2BqGWg0/ -ZNzmmlgLyk2sBhqN5B/8qjyJ3uvolstkj6vuwIyXa9Z4tAhy4SBtvwaLT19ZS+Y6 -EGnC1vdsyBypwxoet+uVs5KkFOUt6YD8upSq6udpAoGBAPLKPqYy8PI1QaWuzfKI -qty1kk2WO4/hKkuA1tNjymBo2kOCT9VE/e5HkjTrjGKlC5qKA+y7HQcCwciZUxKY -F0Kod5/hNnAD+1Rrgpr9XXJ2QMZpa4DLpv9s9B6STD8QaZ7AGBfHqBG7QPcM3HU+ -Pakb1imfPhJ3oWuWk4XKKy3hAoGBAOh7YJeIvOiWhhbj4+M1LuS8oA15LlR3fkca -SMjOJ1CFGmvzi0YsMrkNbdCqMqOhskCqcRrDmwqzwVd2XqCyocmSxlIVGSu2EA+6 -SozQF/zG8F4nushroUCkKiV7eikKnL9TolFPhRf1yw8wBiQOBEIT2bkagqo8cVBq -S31QP67JAoGBALWqrYJlU4SPW0uKAjRxHguUIyK1G1ezQjHq6kPaC2pnUkcReABZ -KHKx+ZKkdO+y0itpTcxx1wKq7Uf8NH2rc2QWXNGeJajgt6V10dZbz6K6cVxeP+KV -XqAxKDMfbUjqZqCBsEY+FOKoIMiCTqjvy9NIFDuvXT7Bs24FlQkjQPG8 ------END RSA PRIVATE KEY-----
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/data/excon.cert.crt
Deleted
@@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDRTCCAi2gAwIBAgIJAMaDk10V/YquMA0GCSqGSIb3DQEBCwUAMCAxDjAMBgNV -BAMTBWV4Y29uMQ4wDAYDVQQKEwVleGNvbjAeFw0xNzA5MDUxOTQzMzBaFw0xODA5 -MDUxOTQzMzBaMCAxDjAMBgNVBAMTBWV4Y29uMQ4wDAYDVQQKEwVleGNvbjCCASIw -DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMWedu1HHibgTE5vxcA826vtlgDM -KEYN7NPSkhH+ZjDz/nWZ7Y7DcDcNIsW3Nd53PsUGwva6FnBk0j/2GAwm+QO4bjHo -UzB2O4rkePsrhrAOtGq9uINKmcAS0y9Ptl/ZTv1QsKUi4lKjDoalyHV8mEohpWNl -9uWO0aN+Q2KNd4p0SHmlNGAZk9BiiRvPJJqenZ2D51MbJdH5O3N9FhLnwIK6eVaU -R/a3lf5hdkyGYi39zpGx47VG/6q9is1t+WXBWaaLdU0omDhlH281kq+HaV3akG6k -Kh70xFGXU9Ya7qwR+PA+WkGJO6z88qwESRpGZfSSBklpM0+qIbYOP7Zb9PMCAwEA -AaOBgTB/MB0GA1UdDgQWBBTMRFBCu23CeR4YBGR9+2h2b6xqODBQBgNVHSMESTBH -gBTMRFBCu23CeR4YBGR9+2h2b6xqOKEkpCIwIDEOMAwGA1UEAxMFZXhjb24xDjAM -BgNVBAoTBWV4Y29uggkAxoOTXRX9iq4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B -AQsFAAOCAQEAWU6Q11wZFK6GhYK85IkW90FHug8/13DRJ3Q041ttQEpR48DW1lgj -5861hzKkYfyudJhk97WEnx2pzsZSogbiGv/jMT1otKk8RqQG/sQy/bqoTVZEg7I2 -FyPCMV4fPFCm2dL7NTh51q0xeb9QFkxNFQ7YGtAvPSxs+GM/8gLxs4pSPMLSCNxX -0r6Lvook0ur+WXalGLu8110bCa4k+00SlZg0qZISlfrZyF5ofybylMjyy/qArgUy -8eltHfWbPhJEqf1yDPz2xCYGGCSplJMpvAhvSf4GSM55B27AoPlYlaS5wEaJf8Ft -g72ESuzICOQ617jOTeasIkkkoINIdnW1oA== ------END CERTIFICATE-----
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/data/excon.cert.key
Deleted
@@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAxZ527UceJuBMTm/FwDzbq+2WAMwoRg3s09KSEf5mMPP+dZnt -jsNwNw0ixbc13nc+xQbC9roWcGTSP/YYDCb5A7huMehTMHY7iuR4+yuGsA60ar24 -g0qZwBLTL0+2X9lO/VCwpSLiUqMOhqXIdXyYSiGlY2X25Y7Ro35DYo13inRIeaU0 -YBmT0GKJG88kmp6dnYPnUxsl0fk7c30WEufAgrp5VpRH9reV/mF2TIZiLf3OkbHj -tUb/qr2KzW35ZcFZpot1TSiYOGUfbzWSr4dpXdqQbqQqHvTEUZdT1hrurBH48D5a -QYk7rPzyrARJGkZl9JIGSWkzT6ohtg4/tlv08wIDAQABAoIBABpFHnocYh2442vp -39fWPz1zr+UbPp9RapIeA9zwfJU1WjY36CR6RoiK7nxqBnc0UtvOMkyqICGAxZJL -HJdA9wlPkxZ/U8+1Z+Tmyk5ZUuZEjidCYSzS1e16kyhO6GeFc8Ko31KUeJGTq3Kq -xyMXFQeFwX6dJ10Mx0F8n2iSdbmpz6Sfz+L8RwUjlbi3m1iveeMqTk0V8ChTDluC -RWLoUUAqOaV3YpaV4pHmpRJ9uMLbyC72t6JnbLdi5d/EY5vGmMDgsKg/pqW8omFO -8kWo5riLncUyvEwSPoUyY12WWc3CnroacEJ7GoibuZYZwntwot+cWOkIZmnCbj+H -OiBcDoECgYEA8ZgQmdlxQ5Fwe9sadDA3SYi2V/6bQNQkw54xkfsWd/PijIunVJI8 -cj/hVnbZL487DnJAXsLLygw048fSGwFZXmNbQUiXZaEIpa4t9DkgouGPvvuBp6TI -uIjUF4aRKA4a3+MT4SNm74qXx8co5YXnE09KIMswZQ1YHjwIzV0ggJsCgYEA0Wce -7poL7Xiyu1G1vr8vEbYtqelqHP28SzXkwrTqyOV8MPlw0/OhMDWmPLdE9mxSDwdD -QAlPvvCWXhHEM/St5tN72mzuyodHjNsVnlPAckj6ADTTAmUO0fixHjivZ/6v+PEo -SbjzmsbEExjyLKdScW8ALq3nfCdC9+Z3aTFShokCgYBbmz9gNtT9u94c+J11RPsR -xObvQrl3wXkXO5qsMbr5TN6wUBvos3J8F8DH2lTL9dF8ztGdnNtNB4feftwqJT7P -zXjCrlXJ0V/IAt2l5yt613B8CD3HZXI+lpNlQD82IvMJxb659YSIe9LFi7z0Guvd -pIkFGkaFaqPpAvaLeC5k1QKBgGTqrZ2P3++yG3DrEAu9V5HRmnAobVtLbVNRxc2Q -IxZugkuX6yg6YZQ6RsM8D6Ay09kqRt61nhkHGXB8X3IqmSSFB0tc9DfmujTH4MNM -2ZI6WUGAM7ETwvCuSa2m4+HafDQdBK2C1OPiptwNSaj7el/wfsYASW8r/Lo795Ba -lMsBAoGBAO8fKeu1cSrgNBG5Bafa5P2uPK1X9GASA1zgG6ay3FGH9m/vt36/DcRq -LQQP1WJUH8AR9/jlUgpS134Ww0AFVVh/ZHZTFnVkS8mn6wzFehxt49uVVcJncRzB -Vnes1S/Zky0RgvfR4rWy9NCYkIkqYAQPacfElxpGItV7V2INKFol ------END RSA PRIVATE KEY-----
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/data/xs
Deleted
@@ -1,1 +0,0 @@ -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/error_tests.rb
Deleted
@@ -1,145 +0,0 @@ - - -Shindo.tests('HTTPStatusError request/response debugging') do - - # Regression against e300458f2d9330cb265baeb8973120d08c665d9 - tests('Excon::Error knows about pertinent errors') do - expected = - 100, - 101, - (200..206).to_a, - (300..307).to_a, - (400..417).to_a, - 422, - 429, - (500..504).to_a - - expected.flatten == Excon::Error.status_errors.keys - end - - tests('new returns an Error').returns(true) do - Excon::Error.new('bar').class == Excon::Error - end - - tests('new raises errors for bad URIs').returns(true) do - begin - Excon.new('foo') - false - rescue => err - err.to_s.include? 'foo' - end - end - - tests('new raises errors for bad paths').returns(true) do - begin - Excon.new('http://localhost', path: "foo\r\nbar: baz") - false - rescue => err - err.to_s.include? "foo\r\nbar: baz" - end - end - - tests('can raise standard error and catch standard error').returns(true) do - begin - raise Excon::Error::Client.new('foo') - rescue Excon::Error => e - true - end - end - - tests('can raise legacy errors and catch legacy errors').returns(true) do - begin - raise Excon::Errors::Error.new('bar') - rescue Excon::Errors::Error => e - true - end - end - - tests('can raise standard error and catch legacy errors').returns(true) do - begin - raise Excon::Error::NotFound.new('bar') - rescue Excon::Errors::Error => e - true - end - end - - tests('can raise with status_error() and catch with standard error').returns(true) do - begin - raise Excon::Error.status_error({expects: 200}, {status: 400}) - rescue Excon::Error - true - end - end - - - tests('can raise with status_error() and catch with legacy error').returns(true) do - begin - raise Excon::Error.status_error({expects: 200}, {status: 400}) - rescue Excon::Errors::BadRequest - true - end - end - - tests('can raise with legacy status_error() and catch with legacy').returns(true) do - begin - raise Excon::Errors.status_error({expects: 200}, {status: 400}) - rescue Excon::Errors::BadRequest - true - end - end - - - tests('can raise with legacy status_error() and catch with standard').returns(true) do - begin - raise Excon::Errors.status_error({expects: 200}, {status: 400}) - rescue Excon::Error - true - end - end - - with_server('error') do - - tests('message does not include response or response info').returns(true) do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200) - rescue Excon::Errors::HTTPStatusError => err - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - !err.message.include?('excon.error.request') && - !err.message.include?('excon.error.response') - end - end - - tests('message includes only request info').returns(true) do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200, - :debug_request => true) - rescue Excon::Errors::HTTPStatusError => err - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - err.message.include?('excon.error.request') && - !err.message.include?('excon.error.response') - end - end - - tests('message includes only response info').returns(true) do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200, - :debug_response => true) - rescue Excon::Errors::HTTPStatusError => err - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - !err.message.include?('excon.error.request') && - err.message.include?('excon.error.response') - end - end - - tests('message include request and response info').returns(true) do - begin - Excon.get('http://127.0.0.1:9292/error/not_found', :expects => 200, - :debug_request => true, :debug_response => true) - rescue Excon::Errors::HTTPStatusError => err - err.message.include?('Expected(200) <=> Actual(404 Not Found)') && - err.message.include?('excon.error.request') && - err.message.include?('excon.error.response') - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/header_tests.rb
Deleted
@@ -1,119 +0,0 @@ -Shindo.tests('Excon response header support') do - env_init - - tests('Excon::Headers storage') do - headers = Excon::Headers.new - headers'Exact-Case' = 'expected' - headers'Another-Fixture' = 'another' - - tests('stores and retrieves as received').returns('expected') do - headers'Exact-Case' - end - - tests('enumerates keys as received') do - ks = headers.keys - tests('contains Exact-Case').returns(true) { ks.include? 'Exact-Case' } - tests('contains Another-Fixture').returns(true) { ks.include? 'Another-Fixture' } - end - - tests('supports case-insensitive access').returns('expected') do - headers'EXACT-CASE' - end - - tests('but still returns nil for missing keys').returns(nil) do - headers'Missing-Header' - end - - tests('Hash methods that should support case-insensitive access') do - if {}.respond_to? :assoc - tests('#assoc').returns(%w{exact-case expected}) do - headers.assoc('exact-Case') - end - end - - tests('#delete') do - tests('with just a key').returns('yes') do - headers'Extra' = 'yes' - headers.delete('extra') - end - - tests('with a proc').returns('called with notpresent') do - headers.delete('notpresent') { |k| "called with #{k}" } - end - end - - tests('#fetch') do - tests('when present').returns('expected') { headers.fetch('exact-CASE') } - tests('with a default value').returns('default') { headers.fetch('missing', 'default') } - tests('with a default proc').returns('got missing') do - headers.fetch('missing') { |k| "got #{k}" } - end - end - - tests('#has_key?') do - tests('when present').returns(true) { headers.has_key?('EXACT-case') } - tests('when absent').returns(false) { headers.has_key?('missing') } - end - - tests('#values_at') do - tests('all present').returns(%w{expected another}) do - headers.values_at('exACT-cASE', 'anotheR-fixturE') - end - tests('some missing').returns('expected', nil) do - headers.values_at('exact-case', 'missing-header') - end - end - end - end - - with_rackup('response_header.ru') do - - tests('Response#get_header') do - connection = nil - response = nil - - tests('with variable header capitalization') do - - tests('response.get_header("mixedcase-header")').returns('MixedCase') do - connection = Excon.new('http://foo.com:8080', :proxy => 'http://127.0.0.1:9292') - response = connection.request(:method => :get, :path => '/foo') - - response.get_header("mixedcase-header") - end - - tests('response.get_header("uppercase-header")').returns('UPPERCASE') do - response.get_header("uppercase-header") - end - - tests('response.get_header("lowercase-header")').returns('lowercase') do - response.get_header("lowercase-header") - end - - end - - tests('when provided key capitalization varies') do - - tests('response.get_header("MIXEDCASE-HEADER")').returns('MixedCase') do - response.get_header("MIXEDCASE-HEADER") - end - - tests('response.get_header("MiXeDcAsE-hEaDeR")').returns('MixedCase') do - response.get_header("MiXeDcAsE-hEaDeR") - end - - end - - tests('when header is unavailable') do - - tests('response.get_header("missing")').returns(nil) do - response.get_header("missing") - end - - end - - end - - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/canned_response_tests.rb
Deleted
@@ -1,34 +0,0 @@ -Shindo.tests("Excon support for middlewares that return canned responses") do - the_body = "canned" - - canned_response_middleware = Class.new(Excon::Middleware::Base) do - define_method :request_call do |params| - params:response = { - :body => the_body, - :headers => {}, - :status => 200 - } - super(params) - end - end - - tests('does not mutate the canned response body').returns(the_body) do - Excon.get( - 'http://some-host.com/some-path', - :middlewares => canned_response_middleware + Excon.defaults:middlewares - ).body - end - - tests('yields non-mutated body to response_block').returns(the_body) do - body = '' - response_block = lambda { |chunk, _, _| body << chunk } - Excon.get( - 'http://some-host.com/some-path', - :middlewares => canned_response_middleware + Excon.defaults:middlewares, - :response_block => response_block - ) - body - end - -end -
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/capture_cookies_tests.rb
Deleted
@@ -1,34 +0,0 @@ -Shindo.tests("Excon redirecting with cookie preserved") do - env_init - - with_rackup('redirecting_with_cookie.ru') do - tests('second request will send cookies set by the first').returns('ok') do - Excon.get( - 'http://127.0.0.1:9292', - :path => '/sets_cookie', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower - ).body - end - - tests('second request will send multiple cookies set by the first').returns('ok') do - Excon.get( - 'http://127.0.0.1:9292', - :path => '/sets_multi_cookie', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower - ).body - end - end - - with_rackup('redirecting.ru') do - tests("runs normally when there are no cookies set").returns('ok') do - Excon.post( - 'http://127.0.0.1:9292', - :path => '/first', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower, - :body => "a=Some_content" - ).body - end - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/decompress_tests.rb
Deleted
@@ -1,157 +0,0 @@ -Shindo.tests('Excon Decompress Middleware') do - env_init - - with_server('good') do - - before do - @connection ||= Excon.new( - 'http://127.0.0.1:9292/echo/content-encoded', - :method => :post, - :body => 'hello world', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::Decompress - ) - end - - tests('gzip') do - resp = nil - - tests('response body decompressed').returns('hello world') do - resp = @connection.request( - :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0' } - ) - resp:body - end - - tests('server sent content-encoding').returns('gzip') do - resp:headers'Content-Encoding-Sent' - end - - tests('removes processed encoding from header').returns('') do - resp:headers'Content-Encoding' - end - - tests('empty response body').returns('') do - resp = @connection.request(:body => '') - resp:body - end - end - - tests('deflate') do - resp = nil - - tests('response body decompressed').returns('hello world') do - resp = @connection.request( - :headers => { 'Accept-Encoding' => 'gzip;q=0, deflate' } - ) - resp:body - end - - tests('server sent content-encoding').returns('deflate') do - resp:headers'Content-Encoding-Sent' - end - - tests('removes processed encoding from header').returns('') do - resp:headers'Content-Encoding' - end - end - - tests('with pre-encoding') do - resp = nil - - tests('server sent content-encoding').returns('other, gzip') do - resp = @connection.request( - :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0', - 'Content-Encoding-Pre' => 'other' } - ) - resp:headers'Content-Encoding-Sent' - end - - tests('processed encoding removed from header').returns('other') do - resp:headers'Content-Encoding' - end - - tests('response body decompressed').returns('hello world') do - resp:body - end - - end - - tests('with post-encoding') do - resp = nil - - tests('server sent content-encoding').returns('gzip, other') do - resp = @connection.request( - :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0', - 'Content-Encoding-Post' => 'other' } - ) - resp:headers'Content-Encoding-Sent' - end - - tests('unprocessed since last applied is unknown').returns('gzip, other') do - resp:headers'Content-Encoding' - end - - tests('response body still compressed').returns('hello world') do - Zlib::GzipReader.new(StringIO.new(resp:body)).read - end - - end - - tests('with a :response_block') do - captures = nil - resp = nil - - tests('server sent content-encoding').returns('gzip') do - captures = capture_response_block do |block| - resp = @connection.request( - :headers => { 'Accept-Encoding' => 'gzip'}, - :response_block => block - ) - end - resp:headers'Content-Encoding-Sent' - end - - tests('unprocessed since :response_block was used').returns('gzip') do - resp:headers'Content-Encoding' - end - - tests(':response_block passed unprocessed data').returns('hello world') do - body = captures.map {|capture| capture0 }.join - Zlib::GzipReader.new(StringIO.new(body)).read - end - - end - - tests('adds Accept-Encoding if needed') do - - tests('without a :response_block').returns('deflate, gzip') do - resp = Excon.post( - 'http://127.0.0.1:9292/echo/request', - :body => 'hello world', - :middlewares => Excon.defaults:middlewares + - Excon::Middleware::Decompress - ) - request = Marshal.load(resp.body) - request:headers'Accept-Encoding' - end - - tests('with a :response_block').returns(nil) do - captures = capture_response_block do |block| - Excon.post( - 'http://127.0.0.1:9292/echo/request', - :body => 'hello world', - :response_block => block, - :middlewares => Excon.defaults:middlewares + - Excon::Middleware::Decompress - ) - end - request = Marshal.load(captures.map {|capture| capture0 }.join) - request:headers'Accept-Encoding' - end - - end - - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/escape_path_tests.rb
Deleted
@@ -1,36 +0,0 @@ -Shindo.tests('Excon Decompress Middleware') do - env_init - with_rackup('basic.ru') do - tests('encoded uri passed to connection') do - tests('GET /echo%20dirty').returns(200) do - connection = Excon::Connection.new({ - :host => '127.0.0.1', - :hostname => '127.0.0.1', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::EscapePath, - :nonblock => false, - :port => 9292, - :scheme => 'http', - :ssl_verify_peer => false - }) - response = connection.request(:method => :get, :path => '/echo%20dirty') - response:status - end - end - - tests('unencoded uri passed to connection') do - tests('GET /echo dirty').returns(200) do - connection = Excon::Connection.new({ - :host => '127.0.0.1', - :hostname => '127.0.0.1', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::EscapePath, - :nonblock => false, - :port => 9292, - :scheme => 'http', - :ssl_verify_peer => false - }) - response = connection.request(:method => :get, :path => '/echo dirty') - response:status - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/idempotent_tests.rb
Deleted
@@ -1,206 +0,0 @@ -Shindo.tests('Excon request idempotencey') do - - before do - @connection = Excon.new('http://127.0.0.1:9292', :mock => true) - end - - after do - # flush any existing stubs after each test - Excon.stubs.clear - end - - tests("Non-idempotent call with an erroring socket").raises(Excon::Errors::SocketError) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 3 # First 3 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - @connection.request(:method => :get, :path => '/some-path') - end - - tests("Idempotent request with socket erroring first 3 times").returns(200) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 3 # First 3 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path') - response.status - end - - tests("Idempotent request with socket erroring first 5 times").raises(Excon::Errors::SocketError) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 5 # First 5 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path') - response.status - end - - tests("Lowered retry limit with socket erroring first time").returns(200) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 1 # First call fails. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2) - response.status - end - - tests("Lowered retry limit with socket erroring first 3 times").raises(Excon::Errors::SocketError) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 3 # First 3 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2) - response.status - end - - tests("Raised retry limit with socket erroring first 5 times").returns(200) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 5 # First 5 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 8) - response.status - end - - tests("Raised retry limit with socket erroring first 9 times").raises(Excon::Errors::SocketError) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 9 # First 9 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 8) - response.status - end - - tests("Retry limit in constructor with socket erroring first 5 times").returns(200) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 5 # First 5 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 6) - response.status - end - - tests("Retry limit and sleep in constructor with socket erroring first 2 times").returns(200) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 2 # First 5 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - - # NOTE: A short :retry_interval will avoid slowing down the tests. - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 3, :retry_interval => 0.1) - response.status - end - - tests("Retry limit and sleep in constructor with socket erroring first 2 times").raises(Excon::Errors::SocketError) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 2 # First 5 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - - # NOTE: A short :retry_interval will avoid slowing down the tests. - response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2, :retry_interval => 0.1) - response.status - end - - class Block - attr_reader :rewound - def initialize - @rewound = false - end - def call(_) - end - def rewind - @rewound = true - end - end - - tests("request_block rewound").returns(true) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 1 # First call fails. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - request_block = Block.new - @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :request_block => request_block, :retry_limit => 2, :retry_interval => 0.1) - request_block.rewound - end - - tests("response_block rewound").returns(true) do - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 1 # First call fails. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/instrumentation_tests.rb
Deleted
@@ -1,315 +0,0 @@ -require 'active_support/notifications' -require 'securerandom' - -class SimpleInstrumentor - class << self - attr_accessor :events, :blocks - - def instrument(name, params = {}, &block) - @events << name - @blocks << name if block_given? - - yield if block_given? - end - - def reset! - @events = - @blocks = - end - end -end - -Shindo.tests('Excon instrumentation') do - - after do - ActiveSupport::Notifications.unsubscribe("excon") - ActiveSupport::Notifications.unsubscribe("excon.request") - ActiveSupport::Notifications.unsubscribe("excon.response") - ActiveSupport::Notifications.unsubscribe("excon.retry") - ActiveSupport::Notifications.unsubscribe("excon.error") - ActiveSupport::Notifications.unsubscribe("gug") - Delorean.back_to_the_present - Excon.stubs.clear - end - - before do - SimpleInstrumentor.reset! - end - - def subscribe(match) - @events = - ActiveSupport::Notifications.subscribe(match) do |*args| - @events << ActiveSupport::Notifications::Event.new(*args) - end - end - - def make_request(idempotent = false, params = {}) - connection = Excon.new( - 'http://127.0.0.1:9292', - :instrumentor => ActiveSupport::Notifications, - :mock => true - ) - if idempotent - params:idempotent = :true - end - connection.get(params) - end - - REQUEST_DELAY_SECONDS = 30 - def stub_success - Excon.stub({:method => :get}) { |params| - Delorean.jump REQUEST_DELAY_SECONDS - {:body => params:body, :headers => params:headers, :status => 200} - } - end - - def stub_retries - run_count = 0 - Excon.stub({:method => :get}) { |params| - run_count += 1 - if run_count <= 3 # First 3 calls fail. - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - else - {:body => params:body, :headers => params:headers, :status => 200} - end - } - end - - def stub_failure - Excon.stub({:method => :get}) { |params| - raise Excon::Errors::SocketError.new(Exception.new "Mock Error") - } - end - - tests('basic notification').returns('excon.request', 'excon.response') do - subscribe(/excon/) - stub_success - make_request - @events.map(&:name) - end - - tests('captures scheme, host, port, and path').returns(:host, :path, :port, :scheme) do - subscribe(/excon/) - stub_success - make_request - :host, :path, :port, :scheme.select {|k| @events.first.payload.has_key? k} - end - - tests('params in request overwrite those in constructor').returns('/cheezburger') do - subscribe(/excon/) - stub_success - make_request(false, :path => '/cheezburger') - @events.first.payload:path - end - - tests('notify on retry').returns(3) do - subscribe(/excon/) - stub_retries - make_request(true) - @events.count{|e| e.name =~ /retry/} - end - - tests('notify on error').returns(true) do - subscribe(/excon/) - stub_failure - raises(Excon::Errors::SocketError) do - make_request - end - - @events.any?{|e| e.name =~ /error/} - end - - tests('filtering').returns('excon.request', 'excon.error') do - subscribe(/excon.request/) - subscribe(/excon.error/) - stub_failure - raises(Excon::Errors::SocketError) do - make_request(true) - end - - @events.map(&:name) - end - - tests('more filtering').returns('excon.retry', 'excon.retry', 'excon.retry') do - subscribe(/excon.retry/) - stub_failure - raises(Excon::Errors::SocketError) do - make_request(true) - end - - @events.map(&:name) - end - - tests('indicates duration').returns(true) do - subscribe(/excon/) - stub_success - make_request - (@events.first.duration/1000 - REQUEST_DELAY_SECONDS).abs < 1 - end - - tests('standard instrumentor') do - - tests('success').returns( - 'excon.request', 'excon.retry', 'excon.retry', 'excon.retry', 'excon.error') do - - begin - original_stderr = $stderr - $stderr = captured_stderr = StringIO.new - stub_failure - connection = Excon.new( - 'http://127.0.0.1:9292', - :instrumentor => Excon::StandardInstrumentor, - :mock => true - ) - raises(Excon::Errors::SocketError) do - connection.get(:idempotent => true) - end - - captured_stderr.string.split("\n").reject {|line| line =~ %r{^ }}.map {|event| event.split(' ').first} - ensure - $stderr = original_stderr - end - end - - tests('authorization header REDACT') do - - @auth_header = 'Basic dXNlcjpwYXNz' - - begin - original_stderr = $stderr - $stderr = @captured_stderr = StringIO.new - stub_failure - raises(Excon::Errors::SocketError) do - @connection = Excon.new( - 'http://user:pass@127.0.0.1:9292', - :headers => { - 'Authorization' => @auth_header - }, - :instrumentor => Excon::StandardInstrumentor, - :mock => true - ) - @connection.get(:idempotent => true) - end - ensure - $stderr = original_stderr - end - - test('does not appear in response') do - !@captured_stderr.string.include?(@auth_header) - end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/mock_tests.rb
Deleted
@@ -1,304 +0,0 @@ -Shindo.tests('Excon stubs') do - env_init - - tests("missing stub").raises(Excon::Errors::StubNotFound) do - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - connection.request(:method => :get, :path => '/content-length/100') - end - - tests("stub({})").raises(ArgumentError) do - Excon.stub({}) - end - - tests("stub({}, {}) {}").raises(ArgumentError) do - Excon.stub({}, {}) {} - end - - tests("stub({:method => :get}, {:body => 'body', :status => 200})") do - connection = nil - response = nil - - tests('response.body').returns('body') do - Excon.stub({:method => :get}, {:body => 'body', :status => 200}) - - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - response = connection.request(:method => :get, :path => '/content-length/100') - - response.body - end - - tests('response.headers').returns({}) do - response.headers - end - - tests('response.status').returns(200) do - response.status - end - - tests('response_block yields body').returns('body') do - body = '' - response_block = lambda do |chunk, remaining_bytes, total_bytes| - body << chunk - end - connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block) - body - end - - tests('response.body empty with response_block').returns('') do - response_block = lambda { |_, _, _| } - connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block).body - end - - Excon.stubs.clear - - end - - tests("stub({:path => %r{/tests/(\S+)}}, {:body => $1, :status => 200})") do - connection = nil - response = nil - - tests('response.body').returns('test') do - Excon.stub({:path => %r{/tests/(\S+)}}) do |params| - { - :body => params:captures:path.first, - :status => 200 - } - end - - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - response = connection.request(:method => :get, :path => '/tests/test') - - response.body - end - - tests('response.headers').returns({}) do - response.headers - end - - tests('response.status').returns(200) do - response.status - end - - Excon.stubs.clear - - end - - tests("stub({:body => 'body', :method => :get}) {|params| {:body => params:body, :headers => params:headers, :status => 200}}") do - connection = nil - response = nil - - tests('response.body').returns('body') do - Excon.stub({:body => 'body', :method => :get}) {|params| {:body => params:body, :headers => params:headers, :status => 200}} - - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - response = connection.request(:body => 'body', :method => :get, :path => '/content-length/100') - - response.body - end - - tests('response.headers').returns({'Host' => '127.0.0.1:9292', 'User-Agent' => "excon/#{Excon::VERSION}"}) do - response.headers - end - - tests('response.status').returns(200) do - response.status - end - - tests('response_block yields body').returns('body') do - body = '' - response_block = lambda do |chunk, remaining_bytes, total_bytes| - body << chunk - end - connection.request(:body => 'body', :method => :get, :path => '/content-length/100', :response_block => response_block) - body - end - - tests('response.body empty with response_block').returns('') do - response_block = lambda { |_, _, _| } - connection.request(:body => 'body', :method => :get, :path => '/content-length/100', :response_block => response_block).body - end - - Excon.stubs.clear - - end - - tests("stub({:body => File.open(...), :method => :get}, { :status => 200 })") do - - tests('response.status').returns(200) do - file_path = File.join(File.dirname(__FILE__), '..', 'data', 'xs') - - Excon.stub( - { :body => File.read(file_path), :method => :get }, - { :status => 200 } - ) - - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - response = connection.request(:body => File.open(file_path), :method => :get, :path => '/') - - response.status - end - - Excon.stubs.clear - - end - - tests("invalid stub response").raises(Excon::Errors::InvalidStub) do - Excon.stub({:body => 42, :method => :get}, {:status => 200}) - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - connection.request(:body => 42, :method => :get, :path => '/').status - end - - tests("mismatched stub").raises(Excon::Errors::StubNotFound) do - Excon.stub({:method => :post}, {:body => 'body'}) - Excon.get('http://127.0.0.1:9292/', :mock => true) - end - - with_server('good') do - tests('allow mismatched stub').returns(200) do - Excon.stub({:path => '/echo/request_count'}, {:body => 'body'}) - Excon.get( - 'http://127.0.0.1:9292/echo/request', - :mock => true, - :allow_unstubbed_requests => true - ).status - end - end - - Excon.stubs.clear - - tests("stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})") do - - test("response_block yields body") do - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - Excon.stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)}) - - chunks = - response_block = lambda do |chunk, remaining_bytes, total_bytes| - chunks << chunk - end - connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block) - chunks == 'x' * Excon::DEFAULT_CHUNK_SIZE, 'x' - end - - tests("response.body empty with response_block").returns('') do - connection = Excon.new('http://127.0.0.1:9292', :mock => true) - Excon.stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)}) - response_block = lambda { |_, _, _| } - connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block).body - end - - end - - Excon.stubs.clear - - tests("stub({:url => 'https://user:pass@foo.bar.com:9999/baz?quux=true'}, {:status => 200})") do - test("get(:expects => 200)") do - Excon.stub({:url => 'https://user:pass@foo.bar.com:9999/baz?quux=true'}, {:status => 200}) - Excon.new("https://user:pass@foo.bar.com:9999/baz?quux=true", :mock => true).get(:expects => 200) - true - end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/middlewares/redirect_follower_tests.rb
Deleted
@@ -1,112 +0,0 @@ -Shindo.tests('Excon redirector support') do - env_init - - tests("request(:method => :get, :path => '/old').body").returns('new') do - Excon.stub( - { :path => '/old' }, - { - :headers => { 'Location' => 'http://127.0.0.1:9292/new' }, - :body => 'old', - :status => 301 - } - ) - - Excon.stub( - { :path => '/new' }, - { - :body => 'new', - :status => 200 - } - ) - - Excon.get( - 'http://127.0.0.1:9292', - :path => '/old', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::RedirectFollower, - :mock => true - ).body - end - - env_restore -end - -Shindo.tests('Excon redirect support for relative Location headers') do - env_init - - tests("request(:method => :get, :path => '/old').body").returns('new') do - Excon.stub( - { :path => '/old' }, - { - :headers => { 'Location' => '/new' }, - :body => 'old', - :status => 301 - } - ) - - Excon.stub( - { :path => '/new' }, - { - :body => 'new', - :status => 200 - } - ) - - Excon.get( - 'http://127.0.0.1:9292', - :path => '/old', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::RedirectFollower, - :mock => true - ).body - end - - env_restore -end - -Shindo.tests('Excon redirect support for relative Location headers with dot segments') do - env_init - - tests("request(:method => :get, :path => '/foo/baz/').body").returns('/foo/bar/') do - Excon.stub( - { :path => '/foo/baz/' }, - { - :headers => { 'Location' => '../bar/' }, - :body => '/foo/baz/', - :status => 301 - } - ) - - Excon.stub( - { :path => '/foo/bar/' }, - { - :body => '/foo/bar/', - :status => 200 - } - ) - - Excon.get( - 'http://127.0.0.1:9292', - :path => '/foo/baz/', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::RedirectFollower, - :mock => true - ).body - end - - env_restore -end - -Shindo.tests("Excon redirecting post request") do - env_init - - with_rackup('redirecting.ru') do - tests("request not have content-length and body").returns('ok') do - Excon.post( - 'http://127.0.0.1:9292', - :path => '/first', - :middlewares => Excon.defaults:middlewares + Excon::Middleware::RedirectFollower, - :body => "a=Some_content" - ).body - end - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/pipeline_tests.rb
Deleted
@@ -1,40 +0,0 @@ -Shindo.tests('Pipelined Requests') do - with_server('good') do - - tests('with default :persistent => true') do - returns(%w{ 1 2 3 4 }, 'connection is persistent') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => true) - - ret = - ret << connection.requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - ).map(&:body) - ret << connection.requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - ).map(&:body) - ret.flatten - end - end - - tests('with default :persistent => false') do - returns(%w{ 1 2 1 2 }, 'connection is persistent per call to #requests') do - connection = Excon.new('http://127.0.0.1:9292', :persistent => false) - - ret = - ret << connection.requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - ).map(&:body) - ret << connection.requests( - {:method => :get, :path => '/echo/request_count'}, - {:method => :get, :path => '/echo/request_count'} - ).map(&:body) - ret.flatten - end - - end - - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/proxy_tests.rb
Deleted
@@ -1,306 +0,0 @@ -Shindo.tests('Excon proxy support') do - env_init - - tests('proxy configuration') do - - tests('no proxy') do - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('http://foo.com') - connection.data:proxy - end - end - - tests('empty proxy') do - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('http://foo.com', :proxy => '') - connection.data:proxy - end - end - - tests('with fully-specified proxy: https://myproxy.net:8080') do - connection = nil - - tests('connection.data:proxy:host').returns('myproxy.net') do - connection = Excon.new('http://foo.com', :proxy => 'https://myproxy.net:8080') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(8080) do - connection.data:proxy:port - end - - tests('connection.data:proxy:scheme').returns('https') do - connection.data:proxy:scheme - end - end - - tests('with fully-specified Unix socket proxy: unix:///') do - connection = nil - - tests('connection.data:proxy:host').returns(nil) do - connection = Excon.new('http://foo.com', :proxy => 'unix:///tmp/myproxy.sock') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(nil) do - connection.data:proxy:port - end - - tests('connection.data:proxy:scheme').returns('unix') do - connection.data:proxy:scheme - end - - tests('connection.data:proxy:path').returns('/tmp/myproxy.sock') do - connection.data:proxy:path - end - end - - def env_proxy_tests(env) - env_init(env) - - tests('an http connection') do - connection = nil - - tests('connection.data:proxy:host').returns('myproxy') do - connection = Excon.new('http://foo.com') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(8080) do - connection.data:proxy:port - end - - tests('connection.data:proxy:scheme').returns('http') do - connection.data:proxy:scheme - end - - tests('with disable_proxy set') do - connection = nil - - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('http://foo.com', :disable_proxy => true) - connection.data:proxy - end - end - end - - tests('an https connection') do - connection = nil - - tests('connection.data:proxy:host').returns('mysecureproxy') do - connection = Excon.new('https://secret.com') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(8081) do - connection.data:proxy:port - end - - tests('connection.data:proxy:scheme').returns('http') do - connection.data:proxy:scheme - end - - tests('with disable_proxy set') do - connection = nil - - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('https://foo.com', :disable_proxy => true) - connection.data:proxy - end - end - end - - tests('http proxy from the environment overrides config') do - connection = nil - - tests('connection.data:proxy:host').returns('myproxy') do - connection = Excon.new('http://foo.com', :proxy => 'http://hard.coded.proxy:6666') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(8080) do - connection.data:proxy:port - end - end - - tests('an http connection in no_proxy') do - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('http://somesubdomain.noproxy') - connection.data:proxy - end - end - - tests('an http connection not completely matching no_proxy') do - tests('connection.data:proxy:host').returns('myproxy') do - connection = Excon.new('http://noproxy2') - connection.data:proxy:host - end - end - - tests('an http connection with subdomain in no_proxy') do - tests('connection.data:proxy').returns(nil) do - connection = Excon.new('http://a.subdomain.noproxy2') - connection.data:proxy - end - end - - env_restore - end - - tests('with complete proxy config from the environment') do - env = { - 'http_proxy' => 'http://myproxy:8080', - 'https_proxy' => 'http://mysecureproxy:8081', - 'no_proxy' => 'noproxy, subdomain.noproxy2' - } - tests('lowercase') { env_proxy_tests(env) } - upperenv = {} - env.each do |k, v| - upperenvk.upcase = v - end - tests('uppercase') { env_proxy_tests(upperenv) } - end - - tests('with only http_proxy config from the environment') do - env_init({'http_proxy' => 'http://myproxy:8080' }) - - tests('an https connection') do - connection = nil - - tests('connection.data:proxy:host').returns('myproxy') do - connection = Excon.new('https://secret.com') - connection.data:proxy:host - end - - tests('connection.data:proxy:port').returns(8080) do - connection.data:proxy:port - end - - tests('connection.data:proxy:scheme').returns('http') do - connection.data:proxy:scheme - end - end - - env_restore - end - - tests('with a unix socket proxy config from the environment') do - env_init({ - 'http_proxy' => 'unix:///tmp/myproxy.sock', - }) - - tests('an https connection') do - connection = nil - - tests('connection.data:proxy:host').returns(nil) do - connection = Excon.new('https://secret.com') - connection.data:proxy:host - end -
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/query_string_tests.rb
Deleted
@@ -1,87 +0,0 @@ -Shindo.tests('Excon query string variants') do - with_rackup('query_string.ru') do - connection = Excon.new('http://127.0.0.1:9292') - - tests(":query => {:foo => 'bar'}") do - response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar'}) - query_string = response.body7..-1 # query string sent - - tests("query string sent").returns('foo=bar') do - query_string - end - end - - tests(":query => {:foo => nil}") do - response = connection.request(:method => :get, :path => '/query', :query => {:foo => nil}) - query_string = response.body7..-1 # query string sent - - tests("query string sent").returns('foo') do - query_string - end - end - - tests(":query => {:foo => 'bar', :me => nil}") do - response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar', :me => nil}) - query_string = response.body7..-1 # query string sent - - test("query string sent includes 'foo=bar'") do - query_string.split('&').include?('foo=bar') - end - - test("query string sent includes 'me'") do - query_string.split('&').include?('me') - end - end - - tests(":query => {:foo => 'bar', :me => 'too'}") do - response = connection.request(:method => :get, :path => '/query', :query => {:foo => 'bar', :me => 'too'}) - query_string = response.body7..-1 # query string sent - - test("query string sent includes 'foo=bar'") do - query_string.split('&').include?('foo=bar') - end - - test("query string sent includes 'me=too'") do - query_string.split('&').include?('me=too') - end - end - - # You can use an atom or a string for the hash keys, what is shown here is emulating - # the Rails and PHP style of serializing a query array with a square brackets suffix. - tests(":query => {'foo' => 'bar', 'baz', :me => 'too'}") do - response = connection.request(:method => :get, :path => '/query', :query => {'foo' => 'bar', 'baz', :me => 'too'}) - query_string = response.body7..-1 # query string sent - - test("query string sent includes 'foo%5B%5D=bar'") do - query_string.split('&').include?('foo%5B%5D=bar') - end - - test("query string sent includes 'foo%5B%5D=baz'") do - query_string.split('&').include?('foo%5B%5D=baz') - end - - test("query string sent includes 'me=too'") do - query_string.split('&').include?('me=too') - end - end - - tests(":query => {'foo%=#' => 'bar%=#'}") do - response = connection.request(:method => :get, :path => '/query', :query => {'foo%=#' => 'bar%=#'}) - query_string = response.body7..-1 # query string sent - - tests("query string sent").returns('foo%25%3D%23=bar%25%3D%23') do - query_string - end - end - - tests(":query => {'foo%=#' => nil}") do - response = connection.request(:method => :get, :path => '/query', :query => {'foo%=#' => nil}) - query_string = response.body7..-1 # query string sent - - tests("query string sent").returns('foo%25%3D%23') do - query_string - end - end - - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/basic.rb
Deleted
@@ -1,41 +0,0 @@ -require 'sinatra' -require 'json' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class Basic < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('/content-length/:value') do |value| - headers("Custom" => "Foo: bar") - 'x' * value.to_i - end - - get('/headers') do - content_type :json - request.env.select{|key, _| key.start_with? 'HTTP_'}.to_json - end - - post('/body-sink') do - request.body.read.size.to_s - end - - post('/echo') do - echo - end - - put('/echo') do - echo - end - - get('/echo dirty') do - echo - end - - private - - def echo - request.body.read - end - -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/basic.ru
Deleted
@@ -1,3 +0,0 @@ -require File.join(File.dirname(__FILE__), 'basic') - -run Basic
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/basic_auth.ru
Deleted
@@ -1,14 +0,0 @@ -require File.join(File.dirname(__FILE__), 'basic') - -class BasicAuth < Basic - before do - auth ||= Rack::Auth::Basic::Request.new(request.env) - user, pass = auth.provided? && auth.basic? && auth.credentials - unless user, pass == "test_user", "test_password" - response'WWW-Authenticate' = %(Basic realm="Restricted Area") - throw(:halt, 401, "Not authorized\n") - end - end -end - -run BasicAuth
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/deflater.ru
Deleted
@@ -1,4 +0,0 @@ -require File.join(File.dirname(__FILE__), 'basic') - -use Rack::Deflater -run Basic
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/proxy.ru
Deleted
@@ -1,18 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('*') do - headers( - "Sent-Request-Uri" => request.env'REQUEST_URI'.to_s, - "Sent-Host" => request.env'HTTP_HOST'.to_s, - "Sent-Proxy-Connection" => request.env'HTTP_PROXY_CONNECTION'.to_s - ) - 'proxied content' - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/query_string.ru
Deleted
@@ -1,13 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('/query') do - "query: " << request.query_string - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/redirecting.ru
Deleted
@@ -1,23 +0,0 @@ -require 'sinatra' -require 'json' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - post('/first') do - redirect "/second" - end - - get('/second') do - post_body = request.body.read - if post_body == "" && request"CONTENT_LENGTH".nil? - "ok" - else - JSON.pretty_generate(request.env) - end - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/redirecting_with_cookie.ru
Deleted
@@ -1,40 +0,0 @@ -require 'sinatra' -require 'sinatra/cookies' -require 'json' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - helpers Sinatra::Cookies - set :environment, :production - enable :dump_errors - - get('/sets_cookie') do - cookies:chocolatechip = "chunky" - redirect "/requires_cookie" - end - - get('/requires_cookie') do - cookie = cookies:chocolatechip - unless cookie.nil? || cookie != "chunky" - "ok" - else - JSON.pretty_generate(headers) - end - end - - get('/sets_multi_cookie') do - cookies:chocolatechip = "chunky" - cookies:thinmints = "minty" - redirect "/requires_cookie" - end - - get('/requires_cookie') do - if cookies:chocolatechip == "chunky" && cookies:thinmints == "minty" - "ok" - else - JSON.pretty_generate(headers) - end - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/request_headers.ru
Deleted
@@ -1,15 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - post '/' do - h = "" - env.each { |k,v| h << "#{$1.downcase}: #{v}\n" if k =~ /http_(.*)/i } - h - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/request_methods.ru
Deleted
@@ -1,21 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get '/' do - 'GET' - end - - post '/' do - 'POST' - end - - delete '/' do - 'DELETE' - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/response_header.ru
Deleted
@@ -1,18 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('/foo') do - headers( - "MixedCase-Header" => 'MixedCase', - "UPPERCASE-HEADER" => 'UPPERCASE', - "lowercase-header" => 'lowercase' - ) - 'primary content' - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/ssl.ru
Deleted
@@ -1,16 +0,0 @@ -require 'openssl' -require 'webrick' -require 'webrick/https' - -require File.join(File.dirname(__FILE__), 'basic') - -key_file = File.join(File.dirname(__FILE__), '..', 'data', '127.0.0.1.cert.key') -cert_file = File.join(File.dirname(__FILE__), '..', 'data', '127.0.0.1.cert.crt') -Rack::Handler::WEBrick.run(Basic, { - :Port => 9443, - :SSLEnable => true, - :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read), - :SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read), - :SSLCACertificateFile => cert_file, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, -})
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/ssl_mismatched_cn.ru
Deleted
@@ -1,15 +0,0 @@ -require 'openssl' -require 'webrick' -require 'webrick/https' - -require File.join(File.dirname(__FILE__), 'basic') -key_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.key') -cert_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.crt') -Rack::Handler::WEBrick.run(Basic, { - :Port => 9443, - :SSLEnable => true, - :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read), - :SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read), - :SSLCACertificateFile => cert_file, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, -})
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/ssl_verify_peer.ru
Deleted
@@ -1,16 +0,0 @@ -require 'openssl' -require 'webrick' -require 'webrick/https' - -require File.join(File.dirname(__FILE__), 'basic') -key_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.key') -cert_file = File.join(File.dirname(__FILE__), '..', 'data', 'excon.cert.crt') -Rack::Handler::WEBrick.run(Basic, { - :Port => 8443, - :SSLCertName => "CN", WEBrick::Utils::getservername, - :SSLEnable => true, - :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(key_file).read), - :SSLCertificate => OpenSSL::X509::Certificate.new(File.open(cert_file).read), - :SSLCACertificateFile => cert_file, - :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, -})
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/streaming.ru
Deleted
@@ -1,30 +0,0 @@ -use Rack::ContentType, "text/plain" - -app = lambda do |env| - # streamed pieces to be sent - pieces = %w{Hello streamy world} - - response_headers = {} - - # set a fixed content length in the header if requested - if env'REQUEST_PATH' == '/streamed/fixed_length' - response_headers'Content-Length' = pieces.join.length.to_s - end - - response_headers"rack.hijack" = lambda do |io| - # Write directly to IO of the response - begin - # return the response in pieces - pieces.each do |x| - sleep(0.1) - io.write(x) - io.flush - end - ensure - io.close - end - end - 200, response_headers, nil -end - -run app
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/thread_safety.ru
Deleted
@@ -1,17 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('/id/:id/wait/:wait') do |id, wait| - sleep(wait.to_i) - id.to_s - end -end - -# get everything autoloaded, mainly for rbx -App.new - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/timeout.ru
Deleted
@@ -1,14 +0,0 @@ -require 'sinatra' -require File.join(File.dirname(__FILE__), 'webrick_patch') - -class App < Sinatra::Base - set :environment, :production - enable :dump_errors - - get('/timeout') do - sleep(2) - '' - end -end - -run App
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/rackups/webrick_patch.rb
Deleted
@@ -1,34 +0,0 @@ -# The ruby 2.0 stdlib includes the following changes -# to avoid "can't add a new key into hash during iteration" errors. -# https://github.com/ruby/ruby/commit/3c491a92f6fbfecc065f7687c51c7d6d52a38883 -# https://github.com/ruby/ruby/commit/7b18633804c606e8bcccfbb44e7d7b795e777ea6 -# However, these changes were not backported to the 1.9.x stdlib. -# These errors are causing intermittent errors in the tests (frequently in jruby), -# so we're applying those changes here. This is loaded by all rackups using WEBrick. -if RUBY_VERSION =~ /^1\.9/ - require 'webrick/utils' - module WEBrick - module Utils - class TimeoutHandler - def initialize - @timeout_info = Hash.new - Thread.start{ - while true - now = Time.now - @timeout_info.keys.each{|thread| - ary = @timeout_infothread - next unless ary - ary.dup.each{|info| - time, exception = *info - interrupt(thread, info.object_id, exception) if time < now - } - } - sleep 0.5 - end - } - end - end - end - end -end -
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/request_headers_tests.rb
Deleted
@@ -1,21 +0,0 @@ -Shindo.tests('Excon request methods') do - - with_rackup('request_headers.ru') do - - tests 'empty headers sent' do - - test('Excon.post') do - headers = { - :one => 1, - :two => nil, - :three => 3, - } - r = Excon.post('http://localhost:9292', :headers => headers).body - !r.match(/two:/).nil? - end - - end - - end - -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/request_method_tests.rb
Deleted
@@ -1,47 +0,0 @@ -Shindo.tests('Excon request methods') do - - with_rackup('request_methods.ru') do - - tests 'one-offs' do - - tests('Excon.get').returns('GET') do - Excon.get('http://localhost:9292').body - end - - tests('Excon.post').returns('POST') do - Excon.post('http://localhost:9292').body - end - - tests('Excon.delete').returns('DELETE') do - Excon.delete('http://localhost:9292').body - end - - end - - tests 'with a connection object' do - connection = nil - - tests('connection.get').returns('GET') do - connection = Excon.new('http://localhost:9292') - connection.get.body - end - - tests('connection.post').returns('POST') do - connection.post.body - end - - tests('connection.delete').returns('DELETE') do - connection.delete.body - end - - tests('not modifies path argument').returns('path') do - path = 'path' - connection.get(:path => path) - path - end - - end - - end - -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/request_tests.rb
Deleted
@@ -1,59 +0,0 @@ -Shindo.tests('Request Tests') do - with_server('good') do - - tests('persistent connections') do - ip_ports = %w(127.0.0.1:9292) - ip_ports << "::1:9293" unless RUBY_PLATFORM == 'java' - ip_ports.each do |ip_port| - - tests("with default :persistent => true, #{ip_port}") do - connection = nil - - returns('1', '2', 'uses a persistent connection') do - connection = Excon.new("http://#{ip_port}", :persistent => true) - 2.times.map do - connection.request(:method => :get, :path => '/echo/request_count').body - end - end - - returns('3', '1', '2', ':persistent => false resets connection') do - ret = - ret << connection.request(:method => :get, - :path => '/echo/request_count', - :persistent => false).body - ret << connection.request(:method => :get, - :path => '/echo/request_count').body - ret << connection.request(:method => :get, - :path => '/echo/request_count').body - end - end - - tests("with default :persistent => false, #{ip_port}") do - connection = nil - - returns('1', '1', 'does not use a persistent connection') do - connection = Excon.new("http://#{ip_port}", :persistent => false) - 2.times.map do - connection.request(:method => :get, :path => '/echo/request_count').body - end - end - - returns('1', '2', '3', '1', ':persistent => true enables persistence') do - ret = - ret << connection.request(:method => :get, - :path => '/echo/request_count', - :persistent => true).body - ret << connection.request(:method => :get, - :path => '/echo/request_count', - :persistent => true).body - ret << connection.request(:method => :get, - :path => '/echo/request_count').body - ret << connection.request(:method => :get, - :path => '/echo/request_count').body - end - end - - end - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/response_tests.rb
Deleted
@@ -1,197 +0,0 @@ -Shindo.tests('Excon Response Parsing') do - env_init - - with_server('good') do - - tests('responses with chunked transfer-encoding') do - - tests('simple response').returns('hello world') do - Excon.get('http://127.0.0.1:9292/chunked/simple').body - end - - tests('with :response_block') do - - tests('simple response'). - returns('hello ', nil, nil, 'world', nil, nil) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/chunked/simple', - :response_block => block, - :chunk_size => 5) # not used - end - end - - tests('simple response has empty body').returns('') do - response_block = lambda { |_, _, _| } - Excon.get('http://127.0.0.1:9292/chunked/simple', :response_block => response_block).body - end - - tests('with expected response status'). - returns('hello ', nil, nil, 'world', nil, nil) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/chunked/simple', - :response_block => block, - :expects => 200) - end - end - - tests('with unexpected response status').returns('hello world') do - begin - Excon.get('http://127.0.0.1:9292/chunked/simple', - :response_block => Proc.new { raise 'test failed' }, - :expects => 500) - rescue Excon::Errors::HTTPStatusError => err - err.response:body - end - end - - end - - tests('merges trailers into headers'). - returns('one, two, three, four, five, six') do - Excon.get('http://127.0.0.1:9292/chunked/trailers').headers'Test-Header' - end - - tests("removes 'chunked' from Transfer-Encoding").returns(nil) do - Excon.get('http://127.0.0.1:9292/chunked/simple').headers'Transfer-Encoding' - end - - end - - tests('responses with content-length') do - - tests('simple response').returns('hello world') do - Excon.get('http://127.0.0.1:9292/content-length/simple').body - end - - tests('with :response_block') do - - tests('simple response'). - returns('hello', 6, 11, ' worl', 1, 11, 'd', 0, 11) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/content-length/simple', - :response_block => block, - :chunk_size => 5) - end - end - - tests('simple response has empty body').returns('') do - response_block = lambda { |_, _, _| } - Excon.get('http://127.0.0.1:9292/content-length/simple', :response_block => response_block).body - end - - tests('with expected response status'). - returns('hello', 6, 11, ' worl', 1, 11, 'd', 0, 11) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/content-length/simple', - :response_block => block, - :chunk_size => 5, - :expects => 200) - end - end - - tests('with unexpected response status').returns('hello world') do - begin - Excon.get('http://127.0.0.1:9292/content-length/simple', - :response_block => Proc.new { raise 'test failed' }, - :chunk_size => 5, - :expects => 500) - rescue Excon::Errors::HTTPStatusError => err - err.response:body - end - end - - end - - end - - tests('responses with unknown length') do - - tests('simple response').returns('hello world') do - Excon.get('http://127.0.0.1:9292/unknown/simple').body - end - - tests('with :response_block') do - - tests('simple response'). - returns('hello', nil, nil, ' worl', nil, nil, 'd', nil, nil) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/unknown/simple', - :response_block => block, - :chunk_size => 5) - end - end - - tests('simple response has empty body').returns('') do - response_block = lambda { |_, _, _| } - Excon.get('http://127.0.0.1:9292/unknown/simple', :response_block => response_block).body - end - - tests('with expected response status'). - returns('hello', nil, nil, ' worl', nil, nil, 'd', nil, nil) do - capture_response_block do |block| - Excon.get('http://127.0.0.1:9292/unknown/simple', - :response_block => block, - :chunk_size => 5, - :expects => 200) - end - end - - tests('with unexpected response status').returns('hello world') do - begin - Excon.get('http://127.0.0.1:9292/unknown/simple', - :response_block => Proc.new { raise 'test failed' }, - :chunk_size => 5, - :expects => 500) - rescue Excon::Errors::HTTPStatusError => err - err.response:body - end - end - - end - - end - - tests('cookies') do - - tests('parses cookies into array').returns('one, two', 'three, four') do - resp = Excon.get('http://127.0.0.1:9292/unknown/cookies') - resp:cookies - end - - end - - tests('header continuation') do - - tests('proper continuation').returns('one, two, three, four, five, six') do - resp = Excon.get('http://127.0.0.1:9292/unknown/header_continuation') - resp.headers'Test-Header' - end - - tests('malformed header').raises(Excon::Errors::SocketError) do - Excon.get('http://127.0.0.1:9292/bad/malformed_header') - end - - tests('malformed header continuation').raises(Excon::Errors::SocketError) do - Excon.get('http://127.0.0.1:9292/bad/malformed_header_continuation') - end - - end - - tests('status line parsing') do - - tests('proper status code').returns(404) do - resp = Excon.get('http://127.0.0.1:9292/not-found') - resp.status - end - - tests('proper reason phrase').returns("Not Found") do - resp = Excon.get('http://127.0.0.1:9292/not-found') - resp.reason_phrase - end - - end - - end - - env_restore -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/servers/bad.rb
Deleted
@@ -1,20 +0,0 @@ -#!/usr/bin/env ruby - -require "eventmachine" - -module BadServer - def receive_data(data) - case data - when %r{^GET /eof/no_content_length_and_no_chunking\s} - send_data "HTTP/1.1 200 OK\r\n" - send_data "\r\n" - send_data "hello" - close_connection(true) - end - end -end - -EM.run do - EM.start_server("127.0.0.1", 9292, BadServer) - $stderr.puts "ready" -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/servers/eof.rb
Deleted
@@ -1,17 +0,0 @@ -#!/usr/bin/env ruby - -require "eventmachine" - -module EOFServer - def receive_data(data) - case data - when %r{^GET /eof\s} - close_connection(true) - end - end -end - -EM.run do - EM.start_server("127.0.0.1", 9292, EOFServer) - $stderr.puts "ready" -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/servers/error.rb
Deleted
@@ -1,20 +0,0 @@ -#!/usr/bin/env ruby - -require "eventmachine" - -module ErrorServer - def receive_data(data) - case data - when %r{^GET /error/not_found\s} - send_data "HTTP/1.1 404 Not Found\r\n" - send_data "\r\n" - send_data "server says not found" - close_connection(true) - end - end -end - -EM.run do - EM.start_server("127.0.0.1", 9292, ErrorServer) - $stderr.puts "ready" -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/servers/good.rb
Deleted
@@ -1,350 +0,0 @@ -#!/usr/bin/env ruby - -require 'eventmachine' -require 'stringio' -require 'uri' -require 'zlib' - -module GoodServer - # This method will be called with each request received. - # - # request = { - # :method => method, - # :uri => URI.parse(uri), - # :headers => {}, - # :body => '' - # } - # - # Each connection to this server is persistent unless the client sends - # "Connection: close" in the request. If a response requires the connection - # to be closed, use `start_response(:persistent => false)`. - def send_response(request) - type, path = request:uri.path.split('/', 3)1, 2 - case type - when 'echo' - case path - when 'request' - data = Marshal.dump(request) - start_response - send_data "Content-Length: #{ data.size }\r\n" - send_data "\r\n" - send_data data - - when 'request_count' - (@request_count ||= '0').next! - start_response - send_data "Content-Length: #{ @request_count.size }\r\n" - send_data "Connection: Keep-Alive\r\n" - send_data "\r\n" - send_data @request_count - - when /(content|transfer)-encoded\/?(.*)/ - if (encoding_type = $1) == 'content' - accept_header = 'Accept-Encoding' - encoding_header = 'Content-Encoding' - else - accept_header = 'TE' - encoding_header = 'Transfer-Encoding' - end - chunked = $2 == 'chunked' - - encodings = parse_encodings(request:headersaccept_header) - while encoding = encodings.pop - break if 'gzip', 'deflate'.include?(encoding) - end - - case encoding - when 'gzip' - body = request:body - if(body.nil? || body.empty?) - body = '' - else - io = (Zlib::GzipWriter.new(StringIO.new) << request:body).finish - io.rewind - body = io.read - end - when 'deflate' - # drops the zlib header - deflator = Zlib::Deflate.new(nil, -Zlib::MAX_WBITS) - body = deflator.deflate(request:body, Zlib::FINISH) - deflator.close - else - body = request:body - end - - # simulate server pre/post content encoding - encodings = - request:headers"#{ encoding_header }-Pre", - encoding, - request:headers"#{ encoding_header }-Post", - - if chunked && encoding_type == 'transfer' - encodings << 'chunked' - end - encodings = encodings.compact.join(', ') - - start_response - # let the test know what the server sent - send_data "#{ encoding_header }-Sent: #{ encodings }\r\n" - send_data "#{ encoding_header }: #{ encodings }\r\n" unless encodings.empty? - if chunked - if encoding_type == 'content' - send_data "Transfer-Encoding: chunked\r\n" - end - send_data "\r\n" - send_data chunks_for(body) - send_data "\r\n" - else - send_data "Content-Length: #{ body.size }\r\n" - send_data "\r\n" - send_data body - end - end - - when 'chunked' - case path - when 'simple' - start_response - send_data "Transfer-Encoding: chunked\r\n" - send_data "\r\n" - # chunk-extension is currently ignored. - # this works because "6; chunk-extension".to_i => "6" - send_data "6; chunk-extension\r\n" - send_data "hello \r\n" - send_data "5; chunk-extension\r\n" - send_data "world\r\n" - send_data "0; chunk-extension\r\n" # last-chunk - send_data "\r\n" - - # merged trailers also support continuations - when 'trailers' - start_response - send_data "Transfer-Encoding: chunked\r\n" - send_data "Test-Header: one, two\r\n" - send_data "\r\n" - send_data chunks_for('hello world') - send_data "Test-Header: three, four,\r\n" - send_data "\tfive, six\r\n" - send_data "\r\n" - end - - when 'content-length' - case path - when 'simple' - start_response - send_data "Content-Length: 11\r\n" - send_data "\r\n" - send_data "hello world" - end - - when 'unknown' - case path - when 'cookies' - start_response(:persistent => false) - send_data "Set-Cookie: one, two\r\n" - send_data "Set-Cookie: three, four\r\n" - send_data "\r\n" - send_data "hello world" - - when 'simple' - start_response(:persistent => false) - send_data "\r\n" - send_data "hello world" - - when 'header_continuation' - start_response(:persistent => false) - send_data "Test-Header: one, two\r\n" - send_data "Test-Header: three, four,\r\n" - send_data " five, six\r\n" - send_data "\r\n" - send_data "hello world" - end - - when 'bad' - # Excon will close these connections due to the errors. - case path - when 'malformed_header' - start_response - send_data "Bad-Header\r\n" # no ':' - send_data "\r\n" - send_data "hello world" - - when 'malformed_header_continuation' - send_data "HTTP/1.1 200 OK\r\n" - send_data " Bad-Header: one, two\r\n" # no previous header - send_data "\r\n" - send_data "hello world" - end - - when 'not-found' - start_response(:status => "404 Not Found") - send_data "Content-Length: 11\r\n" - send_data "\r\n" - send_data "hello world" - end - end - - # Sends response status-line, plus headers common to all responses. - def start_response(opts = {}) - opts = { - :status => '200 OK', - :persistent => @persistent # true unless client sent Connection: close - }.merge!(opts) - - @persistent = opts:persistent - send_data "HTTP/1.1 #{ opts:status }\r\n" - send_data "Connection: close\r\n" unless @persistent - end - - def post_init
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/test_helper.rb
Deleted
@@ -1,306 +0,0 @@ -require 'rubygems' if RUBY_VERSION < '1.9' -require 'bundler/setup' -require 'excon' -require 'delorean' -require 'open4' - -Excon.defaults.merge!( - :connect_timeout => 5, - :read_timeout => 5, - :write_timeout => 5 -) - -def basic_tests(url = 'http://127.0.0.1:9292', options = {}) - (true, false * 2).combination(2).to_a.uniq.each do |nonblock, persistent| - connection = nil - test do - options = options.merge({:ssl_verify_peer => false, :nonblock => nonblock, :persistent => persistent }) - connection = Excon.new(url, options) - true - end - - tests("nonblock => #{nonblock}, persistent => #{persistent}") do - - tests('GET /content-length/100') do - response = nil - - tests('response.status').returns(200) do - response = connection.request(:method => :get, :path => '/content-length/100') - - response.status - end - - tests('response:status').returns(200) do - response:status - end - - tests("response.headers'Content-Length'").returns('100') do - response.headers'Content-Length' - end - - tests("response.headers'Content-Type'").returns('text/html;charset=utf-8') do - response.headers'Content-Type' - end - - test("Time.parse(response.headers'Date').is_a?(Time)") do - pending if connection.data:scheme == Excon::UNIX - Time.parse(response.headers'Date').is_a?(Time) - end - - test("!!(response.headers'Server' =~ /^WEBrick/)") do - pending if connection.data:scheme == Excon::UNIX - !!(response.headers'Server' =~ /^WEBrick/) - end - - tests("response.headers'Custom'").returns("Foo: bar") do - response.headers'Custom' - end - - tests("response.remote_ip").returns("127.0.0.1") do - pending if connection.data:scheme == Excon::UNIX - response.remote_ip - end - - tests("response.body").returns('x' * 100) do - response.body - end - - tests("deprecated block usage").returns('x' * 100, 0, 100) do - data = - silence_warnings do - connection.request(:method => :get, :path => '/content-length/100') do |chunk, remaining_length, total_length| - data = chunk, remaining_length, total_length - end - end - data - end - - tests("response_block usage").returns('x' * 100, 0, 100) do - data = - response_block = lambda do |chunk, remaining_length, total_length| - data = chunk, remaining_length, total_length - end - connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block) - data - end - - end - - tests('POST /body-sink') do - - tests('response.body').returns("5000000") do - response = connection.request(:method => :post, :path => '/body-sink', :headers => { 'Content-Type' => 'text/plain' }, :body => 'x' * 5_000_000) - response.body - end - - tests('empty body').returns('0') do - response = connection.request(:method => :post, :path => '/body-sink', :headers => { 'Content-Type' => 'text/plain' }, :body => '') - response.body - end - - end - - tests('POST /echo') do - - tests('with file').returns('x' * 100 + "\n") do - file_path = File.join(File.dirname(__FILE__), "data", "xs") - response = connection.request(:method => :post, :path => '/echo', :body => File.open(file_path)) - response.body - end - - tests('without request_block').returns('x' * 100) do - response = connection.request(:method => :post, :path => '/echo', :body => 'x' * 100) - response.body - end - - tests('with request_block').returns('x' * 100) do - data = 'x' * 100 - request_block = lambda do - data.shift.to_s - end - response = connection.request(:method => :post, :path => '/echo', :request_block => request_block) - response.body - end - - tests('with multi-byte strings') do - body = "\xC3\xBC" * 100 - headers = { 'Custom' => body.dup } - if RUBY_VERSION >= '1.9' - body.force_encoding('BINARY') - headers'Custom'.force_encoding('UTF-8') - end - - returns(body, 'properly concatenates request+headers and body') do - response = connection.request(:method => :post, :path => '/echo', :headers => headers, :body => body) - response.body - end - end - - end - - tests('PUT /echo') do - - tests('with file').returns('x' * 100 + "\n") do - file_path = File.join(File.dirname(__FILE__), "data", "xs") - response = connection.request(:method => :put, :path => '/echo', :body => File.open(file_path)) - response.body - end - - tests('without request_block').returns('x' * 100) do - response = connection.request(:method => :put, :path => '/echo', :body => 'x' * 100) - response.body - end - - tests('request_block usage').returns('x' * 100) do - data = 'x' * 100 - request_block = lambda do - data.shift.to_s - end - response = connection.request(:method => :put, :path => '/echo', :request_block => request_block) - response.body - end - - tests('with multi-byte strings') do - body = "\xC3\xBC" * 100 - headers = { 'Custom' => body.dup } - if RUBY_VERSION >= '1.9' - body.force_encoding('BINARY') - headers'Custom'.force_encoding('UTF-8') - end - - returns(body, 'properly concatenates request+headers and body') do - response = connection.request(:method => :put, :path => '/echo', :headers => headers, :body => body) - response.body - end - end - - end - - tests('should succeed with tcp_nodelay').returns(200) do - options = options.merge(:ssl_verify_peer => false, :nonblock => nonblock, :tcp_nodelay => true) - connection = Excon.new(url, options) - response = connection.request(:method => :get, :path => '/content-length/100') - response.status - end - - end - end -end - - -PROXY_ENV_VARIABLES = %w{http_proxy https_proxy no_proxy} # All lower-case - -def env_init(env={}) - current = {} - PROXY_ENV_VARIABLES.each do |key| - currentkey = ENV.delete(key) - currentkey.upcase = ENV.delete(key.upcase) - end - env_stack << current
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/thread_safety_tests.rb
Deleted
@@ -1,39 +0,0 @@ -Shindo.tests('Excon thread safety') do - - tests('thread_safe_sockets configuration') do - tests('thread_safe_sockets default').returns(true) do - connection = Excon.new('http://foo.com') - connection.data:thread_safe_sockets - end - - tests('with thread_safe_sockets set false').returns(false) do - connection = Excon.new('http://foo.com', :thread_safe_sockets => false) - connection.data:thread_safe_sockets - end - end - - with_rackup('thread_safety.ru') do - connection = Excon.new('http://127.0.0.1:9292') - - long_thread = Thread.new { - response = connection.request(:method => 'GET', :path => '/id/1/wait/2') - Thread.current:success = response.body == '1' - } - - short_thread = Thread.new { - response = connection.request(:method => 'GET', :path => '/id/2/wait/1') - Thread.current:success = response.body == '2' - } - - test('long_thread') do - long_thread.join - short_thread.join - - long_thread:success - end - - test('short_thread') do - short_thread:success - end - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/timeout_tests.rb
Deleted
@@ -1,12 +0,0 @@ -Shindo.tests('read should timeout') do - with_rackup('timeout.ru') do - - false, true.each do |nonblock| - tests("nonblock => #{nonblock} hits read_timeout").raises(Excon::Errors::Timeout) do - connection = Excon.new('http://127.0.0.1:9292', :nonblock => nonblock) - connection.request(:method => :get, :path => '/timeout', :read_timeout => 1) - end - end - - end -end
View file
_service:tar_scm:excon-0.62.0.gem/data/tests/utils_tests.rb
Deleted
@@ -1,81 +0,0 @@ -Shindo.tests('Excon::Utils') do - - tests('#connection_uri') do - - expected_uri = 'unix:///tmp/some.sock' - tests('using UNIX scheme').returns(expected_uri) do - connection = Excon.new('unix:///some/path', :socket => '/tmp/some.sock') - Excon::Utils.connection_uri(connection.data) - end - - tests('using HTTP scheme') do - - expected_uri = 'http://foo.com:80' - tests('with default port').returns(expected_uri) do - connection = Excon.new('http://foo.com/some/path') - Excon::Utils.connection_uri(connection.data) - end - - expected_uri = 'http://foo.com' - tests('without default port').returns(expected_uri) do - connection = Excon.new('http://foo.com/some/path', :omit_default_port => true) - Excon::Utils.connection_uri(connection.data) - end - - end - - end - - tests('#request_uri') do - - tests('using UNIX scheme') do - - expected_uri = 'unix:///tmp/some.sock/some/path' - tests('without query').returns(expected_uri) do - connection = Excon.new('unix:/', :socket => '/tmp/some.sock') - params = { :path => '/some/path' } - Excon::Utils.request_uri(connection.data.merge(params)) - end - - expected_uri = 'unix:///tmp/some.sock/some/path?bar=that&foo=this' - tests('with query').returns(expected_uri) do - connection = Excon.new('unix:/', :socket => '/tmp/some.sock') - params = { :path => '/some/path', :query => { :foo => 'this', :bar => 'that' } } - Excon::Utils.request_uri(connection.data.merge(params)) - end - - end - - tests('using HTTP scheme') do - - expected_uri = 'http://foo.com:80/some/path' - tests('without query').returns(expected_uri) do - connection = Excon.new('http://foo.com') - params = { :path => '/some/path' } - Excon::Utils.request_uri(connection.data.merge(params)) - end - - expected_uri = 'http://foo.com:80/some/path?bar=that&foo=this' - tests('with query').returns(expected_uri) do - connection = Excon.new('http://foo.com') - params = { :path => '/some/path', :query => { :foo => 'this', :bar => 'that' } } - Excon::Utils.request_uri(connection.data.merge(params)) - end - - end - - end - - tests('#escape_uri').returns('/hello%20excon') do - Excon::Utils.escape_uri('/hello excon') - end - - tests('#unescape_uri').returns('/hello excon') do - Excon::Utils.unescape_uri('/hello%20excon') - end - - tests('#unescape_form').returns('message=We love excon!') do - Excon::Utils.unescape_form('message=We+love+excon!') - end - -end
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2