patron 0.14.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -0
  3. data/README.md +83 -49
  4. data/ext/patron/extconf.rb +54 -23
  5. data/ext/patron/session_ext.c +1044 -923
  6. data/lib/patron/compat.rb +57 -0
  7. data/lib/patron/error.rb +21 -13
  8. data/lib/patron/header_parser.rb +27 -25
  9. data/lib/patron/request.rb +98 -144
  10. data/lib/patron/response.rb +28 -24
  11. data/lib/patron/response_decoding.rb +60 -67
  12. data/lib/patron/session.rb +114 -108
  13. data/lib/patron/util.rb +14 -12
  14. data/lib/patron/version.rb +3 -1
  15. data/lib/patron.rb +9 -15
  16. metadata +12 -58
  17. data/.autotest +0 -15
  18. data/.github/dependabot.yml +0 -6
  19. data/.github/workflows/ci.yml +0 -79
  20. data/.gitignore +0 -10
  21. data/.rspec +0 -0
  22. data/.travis.yml +0 -13
  23. data/.yardopts +0 -1
  24. data/Gemfile +0 -18
  25. data/Rakefile +0 -31
  26. data/ext/patron/.gitignore +0 -4
  27. data/ext/patron/membuffer.c +0 -85
  28. data/ext/patron/membuffer.h +0 -78
  29. data/ext/patron/sglib.h +0 -1952
  30. data/lib/patron/proxy_type.rb +0 -11
  31. data/patron.gemspec +0 -39
  32. data/pic.png +0 -0
  33. data/script/console +0 -11
  34. data/script/generate_client_certs +0 -65
  35. data/script/test_server +0 -7
  36. data/spec/header_parser_spec.rb +0 -101
  37. data/spec/patron_spec.rb +0 -28
  38. data/spec/request_spec.rb +0 -89
  39. data/spec/response_spec.rb +0 -145
  40. data/spec/sample_response_headers/headers_wetransfer.txt +0 -18
  41. data/spec/sample_response_headers/headers_wetransfer_with_proxy_status.txt +0 -20
  42. data/spec/sample_response_headers/headers_wetransfer_with_redirect.txt +0 -24
  43. data/spec/sample_response_headers/headers_with_set_cookie.txt +0 -9
  44. data/spec/sample_response_headers/sample_http2_header.txt +0 -16
  45. data/spec/sample_response_headers/webmock_headers_without_trailing_crlf.txt +0 -15
  46. data/spec/session_spec.rb +0 -865
  47. data/spec/session_ssl_spec.rb +0 -431
  48. data/spec/spec_helper.rb +0 -40
  49. data/spec/support/certs/cacert.pem +0 -36
  50. data/spec/support/certs/client.p12 +0 -0
  51. data/spec/support/certs/client_ca.pem +0 -20
  52. data/spec/support/certs/client_cert.pem +0 -20
  53. data/spec/support/certs/client_key.pem +0 -30
  54. data/spec/support/certs/privkey.pem +0 -51
  55. data/spec/support/certs/rogue_client.p12 +0 -0
  56. data/spec/support/config.ru +0 -153
  57. data/spec/support/fork.rb +0 -70
  58. data/spec/support/raw_request_capture.rb +0 -93
  59. data/spec/support/test_server.rb +0 -29
  60. data/spec/support/valgrind.supp +0 -2
  61. data/spec/util_spec.rb +0 -71
metadata CHANGED
@@ -1,106 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aeryn Riley Dowling-Toland
8
- bindir: exe
8
+ - Julik Tarkhanov
9
+ bindir: bin
9
10
  cert_chain: []
10
- date: 2026-10-27 00:00:00.000000000 Z
11
+ date: 2026-10-29 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: Ruby HTTP client library based on libcurl
13
14
  email:
14
15
  - aeryn.toland@gmail.com
16
+ - me@julik.nl
15
17
  executables: []
16
18
  extensions:
17
19
  - ext/patron/extconf.rb
18
20
  extra_rdoc_files: []
19
21
  files:
20
- - ".autotest"
21
- - ".github/dependabot.yml"
22
- - ".github/workflows/ci.yml"
23
- - ".gitignore"
24
- - ".rspec"
25
- - ".travis.yml"
26
- - ".yardopts"
27
22
  - CHANGELOG.md
28
- - Gemfile
29
23
  - LICENSE
30
24
  - README.md
31
- - Rakefile
32
- - ext/patron/.gitignore
33
25
  - ext/patron/extconf.rb
34
- - ext/patron/membuffer.c
35
- - ext/patron/membuffer.h
36
26
  - ext/patron/session_ext.c
37
- - ext/patron/sglib.h
38
27
  - lib/patron.rb
28
+ - lib/patron/compat.rb
39
29
  - lib/patron/error.rb
40
30
  - lib/patron/header_parser.rb
41
- - lib/patron/proxy_type.rb
42
31
  - lib/patron/request.rb
43
32
  - lib/patron/response.rb
44
33
  - lib/patron/response_decoding.rb
45
34
  - lib/patron/session.rb
46
35
  - lib/patron/util.rb
47
36
  - lib/patron/version.rb
48
- - patron.gemspec
49
- - pic.png
50
- - script/console
51
- - script/generate_client_certs
52
- - script/test_server
53
- - spec/header_parser_spec.rb
54
- - spec/patron_spec.rb
55
- - spec/request_spec.rb
56
- - spec/response_spec.rb
57
- - spec/sample_response_headers/headers_wetransfer.txt
58
- - spec/sample_response_headers/headers_wetransfer_with_proxy_status.txt
59
- - spec/sample_response_headers/headers_wetransfer_with_redirect.txt
60
- - spec/sample_response_headers/headers_with_set_cookie.txt
61
- - spec/sample_response_headers/sample_http2_header.txt
62
- - spec/sample_response_headers/webmock_headers_without_trailing_crlf.txt
63
- - spec/session_spec.rb
64
- - spec/session_ssl_spec.rb
65
- - spec/spec_helper.rb
66
- - spec/support/certs/cacert.pem
67
- - spec/support/certs/client.p12
68
- - spec/support/certs/client_ca.pem
69
- - spec/support/certs/client_cert.pem
70
- - spec/support/certs/client_key.pem
71
- - spec/support/certs/privkey.pem
72
- - spec/support/certs/rogue_client.p12
73
- - spec/support/config.ru
74
- - spec/support/fork.rb
75
- - spec/support/raw_request_capture.rb
76
- - spec/support/test_server.rb
77
- - spec/support/valgrind.supp
78
- - spec/util_spec.rb
79
37
  homepage: https://github.com/toland/patron
80
38
  licenses:
81
39
  - MIT
82
40
  metadata:
83
- allowed_push_host: https://rubygems.org
84
- post_install_message: |2
85
-
86
- Thank you for installing Patron. On OSX, make sure you are using libCURL with OpenSSL.
87
- SecureTransport-based builds might cause crashes in forking environments.
88
-
89
- For more info see https://github.com/curl/curl/issues/788
41
+ source_code_uri: https://github.com/toland/patron
42
+ changelog_uri: https://github.com/toland/patron/blob/master/CHANGELOG.md
43
+ bug_tracker_uri: https://github.com/toland/patron/issues
44
+ rubygems_mfa_required: 'true'
90
45
  rdoc_options: []
91
46
  require_paths:
92
47
  - lib
93
- - ext
94
48
  required_ruby_version: !ruby/object:Gem::Requirement
95
49
  requirements:
96
50
  - - ">="
97
51
  - !ruby/object:Gem::Version
98
- version: '2.3'
52
+ version: '3.3'
99
53
  required_rubygems_version: !ruby/object:Gem::Requirement
100
54
  requirements:
101
55
  - - ">="
102
56
  - !ruby/object:Gem::Version
103
- version: 2.5.0
57
+ version: '0'
104
58
  requirements: []
105
59
  rubygems_version: 3.6.2
106
60
  specification_version: 4
data/.autotest DELETED
@@ -1,15 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- at.clear_mappings
3
-
4
- at.add_mapping(%r{^spec/.+_spec\.rb$}) do |filename,_|
5
- filename
6
- end
7
-
8
- at.add_mapping(%r{^lib/patron/(.+)\.rb$}) do |_,match|
9
- [ "spec/#{match[1]}_spec.rb" ]
10
- end
11
-
12
- at.add_mapping(%r{^spec/spec_helper\.rb$}) do
13
- at.files_matching(%r{^spec/.+_spec\.rb$})
14
- end
15
- end
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "github-actions"
4
- directory: "/"
5
- schedule:
6
- interval: "weekly"
@@ -1,79 +0,0 @@
1
- name: Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-24.04
8
- continue-on-error: ${{ matrix.allow-failure || false }}
9
- strategy:
10
- fail-fast: false
11
- matrix:
12
- ruby-version: ["2.4", "3.0", "3.4.1", "4.0.5"]
13
- include:
14
- - ruby-version: "head"
15
- allow-failure: true
16
-
17
- name: Specs - Ruby ${{ matrix.ruby-version }}
18
- steps:
19
- - uses: actions/checkout@v7
20
- - name: Install libcurl
21
- run: |
22
- sudo apt-get update
23
- sudo apt-get -y install libcurl4 libcurl4-openssl-dev
24
- - name: Set up Ruby ${{ matrix.ruby-version }}
25
- uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby-version }}
28
- bundler-cache: true # 'bundle install' and cache
29
- - name: Run tests
30
- run: bundle exec rake
31
-
32
- valgrind:
33
- runs-on: ubuntu-latest
34
- name: Specs under valgrind memcheck
35
- steps:
36
- - uses: actions/checkout@v7
37
- - name: Install libcurl and valgrind
38
- run: |
39
- sudo apt-get update
40
- sudo apt-get -y install libcurl4-openssl-dev valgrind
41
- - name: Set up Ruby
42
- uses: ruby/setup-ruby@v1
43
- with:
44
- ruby-version: "3.4"
45
- bundler-cache: true
46
- - name: Compile the extension with debug info
47
- run: bundle exec rake clobber compile
48
- env:
49
- PATRON_EXTRA_CFLAGS: "-g -O1"
50
- - name: Run the specs under memcheck
51
- # The ruby process itself is under valgrind (bundle exec only sets up the environment).
52
- # Specs tagged :timing assert on wall-clock windows that valgrind's slowdown breaks.
53
- run: |
54
- bundle exec valgrind --error-exitcode=99 --leak-check=no --undef-value-errors=no \
55
- --child-silent-after-fork=yes --num-callers=30 \
56
- --suppressions=spec/support/valgrind.supp \
57
- ruby -S rspec --tag ~timing
58
-
59
- malloc-check:
60
- runs-on: ubuntu-latest
61
- name: Specs with glibc malloc checking
62
- steps:
63
- - uses: actions/checkout@v7
64
- - name: Install libcurl
65
- run: |
66
- sudo apt-get update
67
- sudo apt-get -y install libcurl4-openssl-dev
68
- - name: Set up Ruby
69
- uses: ruby/setup-ruby@v1
70
- with:
71
- ruby-version: "3.4"
72
- bundler-cache: true
73
- - name: Run tests
74
- # glibc aborts on heap corruption and fills freed memory with 0xA5, so a use-after-free
75
- # shows up as garbage data rather than passing by luck
76
- run: bundle exec rake
77
- env:
78
- MALLOC_CHECK_: "3"
79
- MALLOC_PERTURB_: "165"
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- .rbenv*
2
- .rvmrc
3
- *.bundle
4
- coverage
5
- rdoc
6
- doc
7
- pkg
8
- tmp
9
- .yardoc
10
- Gemfile.lock
data/.rspec DELETED
File without changes
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- rvm:
2
- - 2.3.8
3
- - 2.4.5
4
- - 2.5.3
5
- - 2.6.1
6
- - ruby-head
7
-
8
- dist: trusty
9
- cache: bundler
10
-
11
- matrix:
12
- allow_failures:
13
- - rvm: ruby-head
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup markdown
data/Gemfile DELETED
@@ -1,18 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Runtime dependencies are in the gemspec
4
- gemspec
5
-
6
- # Gems below are only needed for Patron development
7
- # and tests
8
- gem "rake", ">= 12.3.3"
9
- gem "rspec", ">= 2.3.0"
10
- gem "simplecov", "~> 0.10"
11
- gem "yard", "~> 0.9.20"
12
- rack_version = RUBY_VERSION >= "3.3" ? "~> 2.2" : "~> 2.1.4"
13
- gem "rack", rack_version
14
- gem "puma", '~> 5.6'
15
- gem "rake-compiler"
16
- gem "webrick", "~> 1.8"
17
- gem "base64"
18
- gem "ostruct"
data/Rakefile DELETED
@@ -1,31 +0,0 @@
1
- require 'rake/clean'
2
- require 'rake/extensiontask'
3
- require 'rspec/core/rake_task'
4
- require "bundler/gem_tasks"
5
- require 'yard'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
-
9
- Rake::ExtensionTask.new do |ext|
10
- ext.name = 'session_ext' # indicate the name of the extension.
11
- ext.ext_dir = 'ext/patron' # search for 'hello_world' inside it.
12
- ext.lib_dir = 'lib/patron' # put binaries into this folder.
13
- end
14
-
15
- CLEAN.include FileList["ext/patron/*"].exclude(/^.*\.(rb|c|h)$/)
16
- CLOBBER.include %w( doc coverage pkg )
17
-
18
- desc "Start an IRB shell"
19
- task :shell => :compile do
20
- sh 'irb -I./lib -I./ext -r patron'
21
- end
22
-
23
- desc "Generate YARD documentation"
24
- YARD::Rake::YardocTask.new do |t|
25
- t.files = ['lib/**/*.rb', 'ext/**/*.c' ]
26
- t.options = ['--markup markdown']
27
- t.stats_options = ['--list-undoc']
28
- end
29
-
30
- task :default => [:clobber, :compile, :spec]
31
- task :build => [:clobber] # Make sure no binaries end up in the gem
@@ -1,4 +0,0 @@
1
- *.bundle
2
- *.o
3
- mkmf.log
4
- Makefile
@@ -1,85 +0,0 @@
1
- #include <ruby.h>
2
- #include <assert.h>
3
- #include "membuffer.h"
4
-
5
- #define DEFAULT_CAPACITY 4096
6
- #define MAXVAL(a, b) ((a) > (b) ? (a) : (b))
7
-
8
- static int membuffer_ensure_capacity( membuffer* m, size_t length ) {
9
- size_t new_capacity;
10
- char* tmp_buf;
11
-
12
- if (m->capacity >= length) { return MB_OK; }
13
-
14
- new_capacity = MAXVAL(m->capacity, DEFAULT_CAPACITY);
15
- while (new_capacity < length) { new_capacity *= 2; }
16
-
17
- tmp_buf = ruby_xrealloc(m->buf, new_capacity+1);
18
- if (NULL == tmp_buf) { return MB_OUT_OF_MEMORY; }
19
- else {
20
- m->buf = tmp_buf;
21
- m->capacity = new_capacity;
22
- }
23
-
24
- return MB_OK;
25
- }
26
-
27
- void membuffer_init( membuffer* m ) {
28
- assert(NULL != m);
29
-
30
- m->buf = NULL;
31
- m->length = 0;
32
- m->capacity = 0;
33
- }
34
-
35
- void membuffer_destroy( membuffer* m ) {
36
- if (NULL == m) { return; }
37
-
38
- if (NULL != m->buf) { ruby_xfree(m->buf); }
39
- m->buf = NULL;
40
- m->length = 0;
41
- m->capacity = 0;
42
- }
43
-
44
- void membuffer_clear( membuffer* m ) {
45
- assert(NULL != m);
46
-
47
- if (NULL != m->buf) {
48
- memset(m->buf, 0, m->capacity+1);
49
- m->length = 0;
50
- }
51
- }
52
-
53
- int membuffer_insert( membuffer* m, size_t index, const void* src, size_t length ) {
54
- int rc = MB_OK;
55
- assert(NULL != m);
56
-
57
- /* sanity checks on the inputs */
58
- if (index > m->length) { return MB_OUT_OF_BOUNDS; }
59
- if (NULL == src || 0 == length) { return MB_OK; }
60
-
61
- /* increase capacity if needed */
62
- rc = membuffer_ensure_capacity( m, m->length + length );
63
- if (MB_OK != rc) { return rc; }
64
-
65
- /* move data in the buffer to the right of the insertion point */
66
- memmove( m->buf + index + length, m->buf + index, m->length - index );
67
-
68
- /* copy date into the insertion point */
69
- memcpy( m->buf + index, src, length );
70
- m->length += length;
71
- m->buf[m->length] = 0; /* null terminate the buffer */
72
-
73
- return MB_OK;
74
- }
75
-
76
- int membuffer_append( membuffer* m, const void* src, size_t length ) {
77
- assert(NULL != m);
78
- return membuffer_insert( m, m->length, src, length );
79
- }
80
-
81
- VALUE membuffer_to_rb_str( membuffer* m ) {
82
- assert(NULL != m);
83
- return rb_str_new(m->buf, m->length);
84
- }
85
-
@@ -1,78 +0,0 @@
1
-
2
- #ifndef PATRON_MEMBUFER_H
3
- #define PATRON_MEMBUFER_H
4
-
5
- #include <stdlib.h>
6
-
7
- #define MB_OK 0
8
- #define MB_OUT_OF_MEMORY 1
9
- #define MB_OUT_OF_BOUNDS 2
10
-
11
- /**
12
- * Implementation of a simple memory buffer for collecting the response body
13
- * and headers from a curl request. The memory buffer will grow to accomodate
14
- * the data inserted into it.
15
- *
16
- * When the memory buffer needs more capacity, it will reallocate memory from
17
- * the heap. It will request twice it's current capacity.
18
- */
19
- typedef struct {
20
- char *buf;
21
- size_t length;
22
- size_t capacity;
23
- } membuffer;
24
-
25
- /**
26
- * Initialize the memory buffer by setting default values of 0 for the length
27
- * and capacity.
28
- */
29
- void membuffer_init( membuffer* m );
30
-
31
- /**
32
- * Free any memory used by the memory buffer.
33
- */
34
- void membuffer_destroy( membuffer* m );
35
-
36
- /**
37
- * Clear the contents of the memory buffer. The length will be set to zero,
38
- * but the capacity will remain unchanged - i.e. memory will not be freed by
39
- * his method.
40
- */
41
- void membuffer_clear( membuffer* m );
42
-
43
- /**
44
- * Attempt to insert the given _src_ data into the memory buffer at the given
45
- * _index_. This method will shift data in the memory buffer to the right in
46
- * order to insert the _src_ data.
47
- *
48
- * This method will fail if the _index_ is out of bounds for the memory
49
- * buffer, if the _src_ is NULL or the _length_ to insert is 0. This method
50
- * can also fail if the memory buffer needs to expand it's capacity but no
51
- * memory is available.
52
- *
53
- * Return Codes:
54
- * MB_OK
55
- * MB_OUT_OF_MEMORY
56
- * MB_OUT_OF_BOUNDS
57
- */
58
- int membuffer_insert( membuffer* m, size_t index, const void* src, size_t length );
59
-
60
- /**
61
- * Append the given _src_ data to the end of the memory buffer. This method
62
- * calls `membuffer_insert` to append the data.
63
- *
64
- * Return Codes:
65
- * MB_OK
66
- * MB_OUT_OF_MEMORY
67
- */
68
- int membuffer_append( membuffer* m, const void* src, size_t length );
69
-
70
- /**
71
- * Convert the memory buffer into a Ruby String instance. This method will
72
- * return an empty String instance if the memory buffer is empty. This method
73
- * will never return Qnil.
74
- */
75
- VALUE membuffer_to_rb_str( membuffer* m );
76
-
77
- #endif
78
-