patron 0.13.4 → 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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -0
  3. data/README.md +113 -50
  4. data/ext/patron/extconf.rb +55 -20
  5. data/ext/patron/session_ext.c +1092 -761
  6. data/lib/patron/compat.rb +57 -0
  7. data/lib/patron/error.rb +25 -13
  8. data/lib/patron/header_parser.rb +27 -25
  9. data/lib/patron/request.rb +98 -142
  10. data/lib/patron/response.rb +33 -24
  11. data/lib/patron/response_decoding.rb +60 -67
  12. data/lib/patron/session.rb +127 -104
  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 -49
  17. data/.autotest +0 -15
  18. data/.github/workflows/ci.yml +0 -26
  19. data/.gitignore +0 -10
  20. data/.rspec +0 -0
  21. data/.travis.yml +0 -13
  22. data/.yardopts +0 -1
  23. data/Gemfile +0 -17
  24. data/Rakefile +0 -31
  25. data/ext/patron/.gitignore +0 -4
  26. data/ext/patron/membuffer.c +0 -85
  27. data/ext/patron/membuffer.h +0 -78
  28. data/ext/patron/sglib.h +0 -1952
  29. data/lib/patron/proxy_type.rb +0 -11
  30. data/patron.gemspec +0 -38
  31. data/pic.png +0 -0
  32. data/script/console +0 -11
  33. data/script/test_server +0 -7
  34. data/spec/header_parser_spec.rb +0 -101
  35. data/spec/patron_spec.rb +0 -28
  36. data/spec/request_spec.rb +0 -77
  37. data/spec/response_spec.rb +0 -145
  38. data/spec/sample_response_headers/headers_wetransfer.txt +0 -18
  39. data/spec/sample_response_headers/headers_wetransfer_with_proxy_status.txt +0 -20
  40. data/spec/sample_response_headers/headers_wetransfer_with_redirect.txt +0 -24
  41. data/spec/sample_response_headers/headers_with_set_cookie.txt +0 -9
  42. data/spec/sample_response_headers/sample_http2_header.txt +0 -16
  43. data/spec/sample_response_headers/webmock_headers_without_trailing_crlf.txt +0 -15
  44. data/spec/session_spec.rb +0 -698
  45. data/spec/session_ssl_spec.rb +0 -313
  46. data/spec/spec_helper.rb +0 -34
  47. data/spec/support/certs/cacert.pem +0 -36
  48. data/spec/support/certs/privkey.pem +0 -51
  49. data/spec/support/config.ru +0 -146
  50. data/spec/support/fork.rb +0 -70
  51. data/spec/support/test_server.rb +0 -26
  52. data/spec/util_spec.rb +0 -71
metadata CHANGED
@@ -1,97 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
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: 2025-02-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/workflows/ci.yml"
22
- - ".gitignore"
23
- - ".rspec"
24
- - ".travis.yml"
25
- - ".yardopts"
26
22
  - CHANGELOG.md
27
- - Gemfile
28
23
  - LICENSE
29
24
  - README.md
30
- - Rakefile
31
- - ext/patron/.gitignore
32
25
  - ext/patron/extconf.rb
33
- - ext/patron/membuffer.c
34
- - ext/patron/membuffer.h
35
26
  - ext/patron/session_ext.c
36
- - ext/patron/sglib.h
37
27
  - lib/patron.rb
28
+ - lib/patron/compat.rb
38
29
  - lib/patron/error.rb
39
30
  - lib/patron/header_parser.rb
40
- - lib/patron/proxy_type.rb
41
31
  - lib/patron/request.rb
42
32
  - lib/patron/response.rb
43
33
  - lib/patron/response_decoding.rb
44
34
  - lib/patron/session.rb
45
35
  - lib/patron/util.rb
46
36
  - lib/patron/version.rb
47
- - patron.gemspec
48
- - pic.png
49
- - script/console
50
- - script/test_server
51
- - spec/header_parser_spec.rb
52
- - spec/patron_spec.rb
53
- - spec/request_spec.rb
54
- - spec/response_spec.rb
55
- - spec/sample_response_headers/headers_wetransfer.txt
56
- - spec/sample_response_headers/headers_wetransfer_with_proxy_status.txt
57
- - spec/sample_response_headers/headers_wetransfer_with_redirect.txt
58
- - spec/sample_response_headers/headers_with_set_cookie.txt
59
- - spec/sample_response_headers/sample_http2_header.txt
60
- - spec/sample_response_headers/webmock_headers_without_trailing_crlf.txt
61
- - spec/session_spec.rb
62
- - spec/session_ssl_spec.rb
63
- - spec/spec_helper.rb
64
- - spec/support/certs/cacert.pem
65
- - spec/support/certs/privkey.pem
66
- - spec/support/config.ru
67
- - spec/support/fork.rb
68
- - spec/support/test_server.rb
69
- - spec/util_spec.rb
70
37
  homepage: https://github.com/toland/patron
71
38
  licenses:
72
39
  - MIT
73
40
  metadata:
74
- allowed_push_host: https://rubygems.org
75
- post_install_message: |2
76
-
77
- Thank you for installing Patron. On OSX, make sure you are using libCURL with OpenSSL.
78
- SecureTransport-based builds might cause crashes in forking environments.
79
-
80
- 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'
81
45
  rdoc_options: []
82
46
  require_paths:
83
47
  - lib
84
- - ext
85
48
  required_ruby_version: !ruby/object:Gem::Requirement
86
49
  requirements:
87
50
  - - ">="
88
51
  - !ruby/object:Gem::Version
89
- version: '0'
52
+ version: '3.3'
90
53
  required_rubygems_version: !ruby/object:Gem::Requirement
91
54
  requirements:
92
55
  - - ">="
93
56
  - !ruby/object:Gem::Version
94
- version: 1.2.0
57
+ version: '0'
95
58
  requirements: []
96
59
  rubygems_version: 3.6.2
97
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,26 +0,0 @@
1
- name: Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby-version: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4.1]
12
-
13
- name: Specs - Ruby ${{ matrix.ruby-version }}
14
- steps:
15
- - uses: actions/checkout@v4
16
- - name: Install libcurl
17
- run: |
18
- sudo apt-get update
19
- sudo apt-get -y install libcurl4 libcurl4-openssl-dev
20
- - name: Set up Ruby ${{ matrix.ruby-version }}
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby-version }}
24
- bundler-cache: true # 'bundle install' and cache
25
- - name: Run tests
26
- run: bundle exec rake
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,17 +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", '~> 3.11'
15
- gem "rake-compiler"
16
- gem "webrick", "~> 1.8"
17
- gem "base64"
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
-