8000 Prepare 0.13.4 for release by julik · Pull Request #197 · toland/patron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prepare 0.13.4 for release #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3]
ruby-version: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4.1]

name: Specs - Ruby ${{ matrix.ruby-version }}
steps:
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### 0.13.4

* Format README a bit better using code fences
* Depend explicitly on base64 for running tests
* Remove C code used for Ruby support below < 2.4 (GVL unlock etc.) and drop support for these versions
* In tests, close Tempfiles before allowing libcurl to use them (cookie jar)
* Fix incorrect ptr type in uses of `curl_easy_escape` / `_unescape`
* Define methods on `Session` as private instance methods from C instead of privatising them from Ruby
* Speed up the /slow endpoint test
* Remove use of `curl_easy_reset`. This should fix the bug with sessions resetting each other's state during `session_free`

### 0.13.3

* Run Puma test servers in separate processes instead of threads

### 0.13.2

* Eagerly initialize libCURL handle when creating the Session instance instead of initializing it lazily
Expand Down
2 changes: 1 addition & 1 deletion lib/patron/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Patron
VERSION = "1.0.0.alpha.1"
VERSION = "0.13.4"
end
6 changes: 3 additions & 3 deletions patron.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
spec.version = Patron::VERSION
spec.licenses = ["MIT"]
spec.platform = Gem::Platform::RUBY
spec.authors = ["Phillip Toland"]
spec.email = ["phil.toland@gmail.com"]
spec.authors = ["Aeryn Riley Dowling-Toland"]
spec.email = ["aeryn.toland@gmail.com"]
spec.homepage = "https://github.com/toland/patron"
spec.summary = "Patron HTTP Client"
spec.description = "Ruby HTTP client library based on libcurl"
Expand All @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.extensions = ["ext/patron/extconf.rb"]
spec.post_install_message = %q{
Thank you for installing Patron. On OSX, make sure you are using libCURL with OpenSSL.
SecureTransport-based builds might cause crashes in forking environment.
SecureTransport-based builds might cause crashes in forking environments.

For more info see https://github.com/curl/curl/issues/788
}
Expand Down
42 changes: 32 additions & 10 deletions spec/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,46 +96,68 @@ def yaml_load(str)
end

it "should download content with :get and a file path" do
tmpfile = "/tmp/patron_test.ya 8000 ml"
tf = Tempfile.new
tf.close
tmpfile = tf.path

response = @session.get_file "/test", tmpfile
expect(response.body).to be_nil
body = yaml_load(File.open(tmpfile).read)
expect(body.request_method).to be == "GET"
FileUtils.rm tmpfile
end

it "should download correctly(md5 ok) with get_file" do
tmpfile = "/tmp/picture"
tf = Tempfile.new
tf.close
tmpfile = tf.path

response = @session.get_file "/picture", tmpfile
expect(response.body).to be_nil
expect(File.size(File.join(File.dirname(__FILE__),"../pic.png"))).to be == File.size(tmpfile)
FileUtils.rm tmpfile
end

it "should follow a 307 redirect with Range headers" do
tmpfile = "/tmp/picture-fragment"
tf = Tempfile.new
tf.close
tmpfile = tf.path

response = @session.get_file "/redirect-to-picture", tmpfile, {'Range' => 'bytes=0-3'}
expect(response.body).to be_nil
expect(File.size(tmpfile)).to eq(4)
FileUtils.rm tmpfile
end

it "downloads a very large file" do
tmpfile = "/tmp/large-succeeded"
tf = Tempfile.new
tf.close
tmpfile = tf.path

@session.get_file "/very-large", tmpfile
expect(File.size(tmpfile)).to eq(15 * 1024 * 1024)
end

it "raises an exception if the download body limit is exceeded when using direct-to-file download" do
tmpfile = "/tmp/large-aborted"
tf = Tempfile.new
tf.close
tmpfile = tf.path

@session.download_byte_limit = 1024
@session.buffer_size = 1024
expect {
@session.get_file "/very-large", tmpfile
}.to raise_error(Patron::Error)
# On Ruby 2.x Patron::Aborted takes precedence, but
# on 1.9 it will be Patron::PartialFileError
expect(File.size(tmpfile)).to be < (1024 * 3)
# on 1.9 it will be Patron::PartialFileError, so we cannot match on exception.
#
# Not clear why, but Patron (or libCURL, or the two in combination)
# may fetch more bytes than we permit it to - for example,
# on Darwin the limit is respected exactly, while on Linux in GH actions
# it does retrieve substantially more.
# The URL we are hitting is serving a file that is 15 megabytes. On Linux
# the tempfile fills to 103344 in our tests, so this is probably either
# OS-dependent or related to timings with the RubyVM context switching.
# To ensure our limiting works, it is enough to check that the downloaded file
# is perceptibly smaller than the complete size of 15MB. Let's say < 1MB.
expect(File.size(tmpfile)).to be < (1024 * 1024)
end

it "raises an exception if the download body limit is exceeded when using download-to-memory" do
Expand Down
3 changes: 2 additions & 1 deletion spec/support/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ WrongContentLengthServlet = Proc.new {|env|

# Serves a substantial amount of data
LargeServlet = Proc.new {|env|
rng = Random.new
len = 15 * 1024 * 1024
body = Enumerator.new do |y|
15.times do
y.yield(Random.new.bytes(1024 * 1024))
y.yield(rng.bytes(1024 * 1024))
end
end
[200, {'Content-Type' => 'binary/octet-stream', 'Content-Length' => len.to_s}, body]
Expand Down
0