Compare commits
25 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
196267c11d | ||
|
|
1260b6a101 | ||
|
|
b27c6d55c2 | ||
|
|
3d0ae00653 | ||
|
|
ec69c58547 | ||
|
|
a0abbd7e41 | ||
|
|
d48b28f77e | ||
|
|
82beb8afba | ||
|
|
a7c00e1606 | ||
|
|
d81799c196 | ||
|
|
2734b32f54 | ||
|
|
c8b6f5da89 | ||
|
|
9f0d0fa3c8 | ||
|
|
8cdb112ef3 | ||
|
|
78c5802cac | ||
|
|
ebc2b1ef4e | ||
|
|
01813feef7 | ||
|
|
d7033b1a2b | ||
|
|
6d9fc75a33 | ||
|
|
228bfa5cbd | ||
|
|
d200536f3a | ||
|
|
8162145c5f | ||
|
|
361199b86f | ||
|
|
f7f2e509bd | ||
|
|
53658c6279 |
12 changed files with 790 additions and 45 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,2 +1,5 @@
|
|||
/faraday-0.8.8.gem
|
||||
/faraday-0.9.0.gem
|
||||
/faraday-0.15.4-tests.tgz
|
||||
/faraday-0.15.4.gem
|
||||
/faraday-1.0.1.gem
|
||||
|
|
|
|||
24
faraday-1.0.1-net-http-persistent-3-error-kind.patch
Normal file
24
faraday-1.0.1-net-http-persistent-3-error-kind.patch
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
From 687108bb4ddc2511aeaae7449dd401fe62dd5ceb Mon Sep 17 00:00:00 2001
|
||||
From: Matt <iMacTia@users.noreply.github.com>
|
||||
Date: Thu, 31 Dec 2020 10:51:03 +0000
|
||||
Subject: [PATCH] Adds Ruby 3.0 to CI Matrix (#1226)
|
||||
|
||||
---
|
||||
.github/workflows/ci.yml | 6 +-----
|
||||
Gemfile | 2 +-
|
||||
lib/faraday/adapter/net_http_persistent.rb | 2 +-
|
||||
3 files changed, 3 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/faraday/adapter/net_http_persistent.rb b/lib/faraday/adapter/net_http_persistent.rb
|
||||
index ff20c256..26bcc2ce 100644
|
||||
--- a/lib/faraday/adapter/net_http_persistent.rb
|
||||
+++ b/lib/faraday/adapter/net_http_persistent.rb
|
||||
@@ -51,7 +51,7 @@ def proxy_uri(env)
|
||||
|
||||
def perform_request(http, env)
|
||||
http.request env[:url], create_request(env)
|
||||
- rescue Errno::ETIMEDOUT => e
|
||||
+ rescue Errno::ETIMEDOUT, Net::OpenTimeout => e
|
||||
raise Faraday::TimeoutError, e
|
||||
rescue Net::HTTP::Persistent::Error => e
|
||||
raise Faraday::TimeoutError, e if e.message.include? 'Timeout'
|
||||
80
faraday-pr1523-testsuite-undefined-method-change.patch
Normal file
80
faraday-pr1523-testsuite-undefined-method-change.patch
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
From 05f2d9486bd88dc0030e002e65cb7d91a67b3f5d Mon Sep 17 00:00:00 2001
|
||||
From: Koichi ITO <koic.ito@gmail.com>
|
||||
Date: Tue, 15 Aug 2023 13:18:31 +0900
|
||||
Subject: [PATCH] Fix a test failure using Ruby 3.3.0dev
|
||||
|
||||
This PR fixes the following test failure using Ruby 3.3.0dev:
|
||||
|
||||
```console
|
||||
$ ruby -v
|
||||
ruby 3.3.0dev (2023-08-14T15:48:39Z master 52837fcec2) [x86_64-darwin22]
|
||||
$ bundle exec rspec spec/faraday_spec.rb
|
||||
|
||||
Randomized with seed 57031
|
||||
|
||||
Faraday
|
||||
has a version number
|
||||
proxies to default_connection
|
||||
uses method_missing on Faraday if there is no proxyable method (FAILED - 1)
|
||||
proxies methods that exist on the default_connection
|
||||
proxied methods can be accessed
|
||||
|
||||
Failures:
|
||||
|
||||
1) Faraday proxies to default_connection uses method_missing on Faraday if there is no proxyable method
|
||||
Failure/Error:
|
||||
expect { Faraday.this_method_does_not_exist }.to raise_error(
|
||||
NoMethodError, expected_message
|
||||
)
|
||||
|
||||
expected NoMethodError with "undefined method `this_method_does_not_exist' for Faraday:Module",
|
||||
got #<NoMethodError: undefined method `this_method_does_not_exist' for module Faraday> with backtrace:
|
||||
# ./lib/faraday.rb:147:in `method_missing'
|
||||
# ./spec/faraday_spec.rb:27:in `block (4 levels) in <top (required)>'
|
||||
# ./spec/faraday_spec.rb:27:in `block (3 levels) in <top (required)>'
|
||||
# ./spec/faraday_spec.rb:27:in `block (3 levels) in <top (required)>'
|
||||
```
|
||||
|
||||
That error message has been changed by https://github.com/ruby/ruby/commit/e7b8d32e in Ruby 3.3.0dev.
|
||||
|
||||
cf. https://bugs.ruby-lang.org/issues/18285
|
||||
|
||||
So the test error message is changed:
|
||||
|
||||
Ruby 3.2 or lower:
|
||||
|
||||
```
|
||||
undefined method `this_method_does_not_exist' for Faraday:Module
|
||||
```
|
||||
|
||||
Ruby 3.3.0dev:
|
||||
|
||||
```
|
||||
NoMethodError: undefined method `this_method_does_not_exist' for module Faraday
|
||||
```
|
||||
---
|
||||
spec/faraday_spec.rb | 11 +++++++----
|
||||
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/spec/faraday_spec.rb b/spec/faraday_spec.rb
|
||||
index 8b603ebbd..25d9d4fa9 100644
|
||||
--- a/spec/faraday_spec.rb
|
||||
+++ b/spec/faraday_spec.rb
|
||||
@@ -18,10 +18,13 @@
|
||||
end
|
||||
|
||||
it 'uses method_missing on Faraday if there is no proxyable method' do
|
||||
- expect { Faraday.this_method_does_not_exist }.to raise_error(
|
||||
- NoMethodError,
|
||||
- "undefined method `this_method_does_not_exist' for Faraday:Module"
|
||||
- )
|
||||
+ expected_message = if RUBY_VERSION >= '3.3'
|
||||
+ "undefined method `this_method_does_not_exist' for module Faraday"
|
||||
+ else
|
||||
+ "undefined method `this_method_does_not_exist' for Faraday:Module"
|
||||
+ end
|
||||
+
|
||||
+ expect { Faraday.this_method_does_not_exist }.to raise_error(NoMethodError, expected_message)
|
||||
end
|
||||
|
||||
it 'proxied methods can be accessed' do
|
||||
23
faraday-pr1549-unespace-rack-utils-query-result.patch
Normal file
23
faraday-pr1549-unespace-rack-utils-query-result.patch
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
From 66551ecc79f5d3d5bca1a2523bd8736db8c2220c Mon Sep 17 00:00:00 2001
|
||||
From: Mattia Giuffrida <giuffrida.mattia@gmail.com>
|
||||
Date: Sat, 20 Jan 2024 16:48:26 +0000
|
||||
Subject: [PATCH] Unescape the result of `Rack::Utils.build_nested_query`
|
||||
|
||||
---
|
||||
spec/faraday/params_encoders/nested_spec.rb | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/spec/faraday/params_encoders/nested_spec.rb b/spec/faraday/params_encoders/nested_spec.rb
|
||||
index 46312047f..83da22dc4 100644
|
||||
--- a/spec/faraday/params_encoders/nested_spec.rb
|
||||
+++ b/spec/faraday/params_encoders/nested_spec.rb
|
||||
@@ -62,7 +62,8 @@
|
||||
it 'encodes rack compat' do
|
||||
params = { a: [{ one: '1', two: '2' }, '3', ''] }
|
||||
result = Faraday::Utils.unescape(Faraday::NestedParamsEncoder.encode(params)).split('&')
|
||||
- expected = Rack::Utils.build_nested_query(params).split('&')
|
||||
+ escaped = Rack::Utils.build_nested_query(params)
|
||||
+ expected = Rack::Utils.unescape(escaped).split('&')
|
||||
expect(result).to match_array(expected)
|
||||
end
|
||||
|
||||
24
faraday-pr1560-ruby34-backtrace-change.patch
Normal file
24
faraday-pr1560-ruby34-backtrace-change.patch
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
From 8cdc483218d4612d53239f48785567b6b6d056cd Mon Sep 17 00:00:00 2001
|
||||
From: m-nakamura145 <masato.nakamura145@gmail.com>
|
||||
Date: Fri, 24 May 2024 23:23:24 +0900
|
||||
Subject: [PATCH] Fix compatibility with Ruby 3.4.0-preview1
|
||||
|
||||
---
|
||||
spec/faraday_spec.rb | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/spec/faraday_spec.rb b/spec/faraday_spec.rb
|
||||
index 30be29cf8..c3583f184 100644
|
||||
--- a/spec/faraday_spec.rb
|
||||
+++ b/spec/faraday_spec.rb
|
||||
@@ -18,7 +18,9 @@
|
||||
end
|
||||
|
||||
it 'uses method_missing on Faraday if there is no proxyable method' do
|
||||
- expected_message = if RUBY_VERSION >= '3.3'
|
||||
+ expected_message = if RUBY_VERSION >= '3.4'
|
||||
+ "undefined method 'this_method_does_not_exist' for module Faraday"
|
||||
+ elsif RUBY_VERSION >= '3.3'
|
||||
"undefined method `this_method_does_not_exist' for module Faraday"
|
||||
else
|
||||
"undefined method `this_method_does_not_exist' for Faraday:Module"
|
||||
30
faraday-pr1604-ruby34-hash-inspect-formatting-change.patch
Normal file
30
faraday-pr1604-ruby34-hash-inspect-formatting-change.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
From 74962b2d77af4a1ca6bc557031e6c24759dbafa7 Mon Sep 17 00:00:00 2001
|
||||
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
|
||||
Date: Tue, 3 Dec 2024 15:48:12 +0900
|
||||
Subject: [PATCH] [TEST] fix compatibility with ruby 3.4.0dev
|
||||
|
||||
ruby 3.4 changes Hash#inspect formatting as:
|
||||
https://bugs.ruby-lang.org/issues/20433
|
||||
|
||||
Closes #1602
|
||||
---
|
||||
spec/faraday/error_spec.rb | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/spec/faraday/error_spec.rb b/spec/faraday/error_spec.rb
|
||||
index fd30e2d34..170f32672 100644
|
||||
--- a/spec/faraday/error_spec.rb
|
||||
+++ b/spec/faraday/error_spec.rb
|
||||
@@ -21,7 +21,11 @@
|
||||
it { expect(subject.wrapped_exception).to be_nil }
|
||||
it { expect(subject.response).to eq(exception) }
|
||||
it { expect(subject.message).to eq('the server responded with status 400') }
|
||||
- it { expect(subject.inspect).to eq('#<Faraday::ClientError response={:status=>400}>') }
|
||||
+ if RUBY_VERSION >= '3.4'
|
||||
+ it { expect(subject.inspect).to eq('#<Faraday::ClientError response={status: 400}>') }
|
||||
+ else
|
||||
+ it { expect(subject.inspect).to eq('#<Faraday::ClientError response={:status=>400}>') }
|
||||
+ end
|
||||
end
|
||||
|
||||
context 'with string' do
|
||||
30
faraday-rack-pr13-rack31-rack_input.patch
Normal file
30
faraday-rack-pr13-rack31-rack_input.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
From a590bc34e40b62484440dcd4ab5147c0c02bb425 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Schleifer <github@segaja.de>
|
||||
Date: Wed, 9 Apr 2025 09:21:05 +0200
|
||||
Subject: [PATCH] Fix tests for rack 3.1: env['rack.input'] is optional (#13)
|
||||
|
||||
* fix(spec): fix tests for rack 3.1
|
||||
|
||||
* feat(ci): add ruby 3.4 to CI test matrix
|
||||
|
||||
---------
|
||||
|
||||
Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
|
||||
---
|
||||
.github/workflows/ci.yml | 1 +
|
||||
spec/support/webmock_rack_app.rb | 2 +-
|
||||
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/spec/support/webmock_rack_app.rb b/spec/support/webmock_rack_app.rb
|
||||
index a3212c7..894c411 100644
|
||||
--- a/spec/support/webmock_rack_app.rb
|
||||
+++ b/spec/support/webmock_rack_app.rb
|
||||
@@ -49,7 +49,7 @@ def req_headers(env)
|
||||
end
|
||||
|
||||
def req_body(env)
|
||||
- env['rack.input'].read
|
||||
+ env['rack.input']&.read
|
||||
end
|
||||
|
||||
def process_response(req_signature)
|
||||
246
parser.rb
Normal file
246
parser.rb
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
module MultipartParser
|
||||
# A low level parser for multipart messages,
|
||||
# based on the node-formidable parser.
|
||||
class Parser
|
||||
|
||||
def initialize
|
||||
@boundary = nil
|
||||
@boundary_chars = nil
|
||||
@lookbehind = nil
|
||||
@state = :parser_uninitialized
|
||||
@index = 0 # Index into boundary or header
|
||||
@flags = {}
|
||||
@marks = {} # Keep track of different parts
|
||||
@callbacks = {}
|
||||
end
|
||||
|
||||
# Initializes the parser, using the given boundary
|
||||
def init_with_boundary(boundary)
|
||||
@boundary = "\r\n--" + boundary
|
||||
@lookbehind = "\0"*(@boundary.length + 8)
|
||||
@state = :start
|
||||
|
||||
@boundary_chars = {}
|
||||
@boundary.each_byte do |b|
|
||||
@boundary_chars[b.chr] = true
|
||||
end
|
||||
end
|
||||
|
||||
# Registers a callback to be called when the
|
||||
# given event occurs. Each callback is expected to
|
||||
# take three parameters: buffer, start_index, and end_index.
|
||||
# All of these parameters may be null, depending on the callback.
|
||||
# Valid callbacks are:
|
||||
# :end
|
||||
# :header_field
|
||||
# :header_value
|
||||
# :header_end
|
||||
# :headers_end
|
||||
# :part_begin
|
||||
# :part_data
|
||||
# :part_end
|
||||
def on(event, &callback)
|
||||
@callbacks[event] = callback
|
||||
end
|
||||
|
||||
# Writes data to the parser.
|
||||
# Returns the number of bytes parsed.
|
||||
# In practise, this means that if the return value
|
||||
# is less than the buffer length, a parse error occured.
|
||||
def write(buffer)
|
||||
i = 0
|
||||
buffer_length = buffer.length
|
||||
index = @index
|
||||
flags = @flags.dup
|
||||
state = @state
|
||||
lookbehind = @lookbehind
|
||||
boundary = @boundary
|
||||
boundary_chars = @boundary_chars
|
||||
boundary_length = @boundary.length
|
||||
boundary_end = boundary_length - 1
|
||||
|
||||
while i < buffer_length
|
||||
c = buffer[i, 1]
|
||||
case state
|
||||
when :parser_uninitialized
|
||||
return i;
|
||||
when :start
|
||||
index = 0;
|
||||
state = :start_boundary
|
||||
when :start_boundary # Differs in that it has no preceeding \r\n
|
||||
if index == boundary_length - 2
|
||||
return i unless c == "\r"
|
||||
index += 1
|
||||
elsif index - 1 == boundary_length - 2
|
||||
return i unless c == "\n"
|
||||
# Boundary read successfully, begin next part
|
||||
callback(:part_begin)
|
||||
state = :header_field_start
|
||||
else
|
||||
return i unless c == boundary[index+2, 1] # Unexpected character
|
||||
index += 1
|
||||
end
|
||||
i += 1
|
||||
when :header_field_start
|
||||
state = :header_field
|
||||
@marks[:header_field] = i
|
||||
index = 0
|
||||
when :header_field
|
||||
if c == "\r"
|
||||
@marks.delete :header_field
|
||||
state = :headers_almost_done
|
||||
else
|
||||
index += 1
|
||||
unless c == "-" # Skip hyphens
|
||||
if c == ":"
|
||||
return i if index == 1 # Empty header field
|
||||
data_callback(:header_field, buffer, i, :clear => true)
|
||||
state = :header_value_start
|
||||
else
|
||||
cl = c.downcase
|
||||
return i if cl < "a" || cl > "z"
|
||||
end
|
||||
end
|
||||
end
|
||||
i += 1
|
||||
when :header_value_start
|
||||
if c == " " # Skip spaces
|
||||
i += 1
|
||||
else
|
||||
@marks[:header_value] = i
|
||||
state = :header_value
|
||||
end
|
||||
when :header_value
|
||||
if c == "\r"
|
||||
data_callback(:header_value, buffer, i, :clear => true)
|
||||
callback(:header_end)
|
||||
state = :header_value_almost_done
|
||||
end
|
||||
i += 1
|
||||
when :header_value_almost_done
|
||||
return i unless c == "\n"
|
||||
state = :header_field_start
|
||||
i += 1
|
||||
when :headers_almost_done
|
||||
return i unless c == "\n"
|
||||
callback(:headers_end)
|
||||
state = :part_data_start
|
||||
i += 1
|
||||
when :part_data_start
|
||||
state = :part_data
|
||||
@marks[:part_data] = i
|
||||
when :part_data
|
||||
prev_index = index
|
||||
|
||||
if index == 0
|
||||
# Boyer-Moore derived algorithm to safely skip non-boundary data
|
||||
# See http://debuggable.com/posts/parsing-file-uploads-at-500-
|
||||
# mb-s-with-node-js:4c03862e-351c-4faa-bb67-4365cbdd56cb
|
||||
while i + boundary_length <= buffer_length
|
||||
break if boundary_chars.has_key? buffer[i + boundary_end].chr
|
||||
i += boundary_length
|
||||
end
|
||||
c = buffer[i, 1]
|
||||
end
|
||||
|
||||
if index < boundary_length
|
||||
if boundary[index, 1] == c
|
||||
if index == 0
|
||||
data_callback(:part_data, buffer, i, :clear => true)
|
||||
end
|
||||
index += 1
|
||||
else # It was not the boundary we found, after all
|
||||
index = 0
|
||||
end
|
||||
elsif index == boundary_length
|
||||
index += 1
|
||||
if c == "\r"
|
||||
flags[:part_boundary] = true
|
||||
elsif c == "-"
|
||||
flags[:last_boundary] = true
|
||||
else # We did not find a boundary after all
|
||||
index = 0
|
||||
end
|
||||
elsif index - 1 == boundary_length
|
||||
if flags[:part_boundary]
|
||||
index = 0
|
||||
if c == "\n"
|
||||
flags.delete :part_boundary
|
||||
callback(:part_end)
|
||||
callback(:part_begin)
|
||||
state = :header_field_start
|
||||
i += 1
|
||||
next # Ugly way to break out of the case statement
|
||||
end
|
||||
elsif flags[:last_boundary]
|
||||
if c == "-"
|
||||
callback(:part_end)
|
||||
callback(:end)
|
||||
state = :end
|
||||
else
|
||||
index = 0 # False alarm
|
||||
end
|
||||
else
|
||||
index = 0
|
||||
end
|
||||
end
|
||||
|
||||
if index > 0
|
||||
# When matching a possible boundary, keep a lookbehind
|
||||
# reference in case it turns out to be a false lead
|
||||
lookbehind[index-1] = c
|
||||
elsif prev_index > 0
|
||||
# If our boundary turns out to be rubbish,
|
||||
# the captured lookbehind belongs to part_data
|
||||
callback(:part_data, lookbehind, 0, prev_index)
|
||||
@marks[:part_data] = i
|
||||
|
||||
# Reconsider the current character as it might be the
|
||||
# beginning of a new sequence.
|
||||
i -= 1
|
||||
end
|
||||
|
||||
i += 1
|
||||
when :end
|
||||
i += 1
|
||||
else
|
||||
return i;
|
||||
end
|
||||
end
|
||||
|
||||
data_callback(:header_field, buffer, buffer_length)
|
||||
data_callback(:header_value, buffer, buffer_length)
|
||||
data_callback(:part_data, buffer, buffer_length)
|
||||
|
||||
@index = index
|
||||
@state = state
|
||||
@flags = flags
|
||||
|
||||
return buffer_length
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Issues a callback.
|
||||
def callback(event, buffer = nil, start = nil, the_end = nil)
|
||||
return if !start.nil? && start == the_end
|
||||
if @callbacks.has_key? event
|
||||
@callbacks[event].call(buffer, start, the_end)
|
||||
end
|
||||
end
|
||||
|
||||
# Issues a data callback,
|
||||
# The only valid options is :clear,
|
||||
# which, if true, will reset the appropriate mark to 0,
|
||||
# If not specified, the mark will be removed.
|
||||
def data_callback(data_type, buffer, the_end, options = {})
|
||||
return unless @marks.has_key? data_type
|
||||
callback(data_type, buffer, @marks[data_type], the_end)
|
||||
unless options[:clear]
|
||||
@marks[data_type] = 0
|
||||
else
|
||||
@marks.delete data_type
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
152
reader.rb
Normal file
152
reader.rb
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
require 'multipart_parser/parser'
|
||||
|
||||
module MultipartParser
|
||||
class NotMultipartError < StandardError; end;
|
||||
|
||||
# A more high level interface to MultipartParser.
|
||||
class Reader
|
||||
|
||||
# Initializes a MultipartReader, that will
|
||||
# read a request with the given boundary value.
|
||||
def initialize(boundary)
|
||||
@parser = Parser.new
|
||||
@parser.init_with_boundary(boundary)
|
||||
@header_field = ''
|
||||
@header_value = ''
|
||||
@part = nil
|
||||
@ended = false
|
||||
@on_error = nil
|
||||
@on_part = nil
|
||||
|
||||
init_parser_callbacks
|
||||
end
|
||||
|
||||
# Returns true if the parser has finished parsing
|
||||
def ended?
|
||||
@ended
|
||||
end
|
||||
|
||||
# Sets to a code block to call
|
||||
# when part headers have been parsed.
|
||||
def on_part(&callback)
|
||||
@on_part = callback
|
||||
end
|
||||
|
||||
# Sets a code block to call when
|
||||
# a parser error occurs.
|
||||
def on_error(&callback)
|
||||
@on_error = callback
|
||||
end
|
||||
|
||||
# Write data from the given buffer (String)
|
||||
# into the reader.
|
||||
def write(buffer)
|
||||
bytes_parsed = @parser.write(buffer)
|
||||
if bytes_parsed != buffer.size
|
||||
msg = "Parser error, #{bytes_parsed} of #{buffer.length} bytes parsed"
|
||||
@on_error.call(msg) unless @on_error.nil?
|
||||
end
|
||||
end
|
||||
|
||||
# Extracts a boundary value from a Content-Type header.
|
||||
# Note that it is the header value you provide here.
|
||||
# Raises NotMultipartError if content_type is invalid.
|
||||
def self.extract_boundary_value(content_type)
|
||||
if content_type =~ /multipart/i
|
||||
if match = (content_type =~ /boundary=(?:"([^"]+)"|([^;]+))/i)
|
||||
$1 || $2
|
||||
else
|
||||
raise NotMultipartError.new("No multipart boundary")
|
||||
end
|
||||
else
|
||||
raise NotMultipartError.new("Not a multipart content type!")
|
||||
end
|
||||
end
|
||||
|
||||
class Part
|
||||
attr_accessor :filename, :headers, :name, :mime
|
||||
|
||||
def initialize
|
||||
@headers = {}
|
||||
@data_callback = nil
|
||||
@end_callback = nil
|
||||
end
|
||||
|
||||
# Calls the data callback with the given data
|
||||
def emit_data(data)
|
||||
@data_callback.call(data) unless @data_callback.nil?
|
||||
end
|
||||
|
||||
# Calls the end callback
|
||||
def emit_end
|
||||
@end_callback.call unless @end_callback.nil?
|
||||
end
|
||||
|
||||
# Sets a block to be called when part data
|
||||
# is read. The block should take one parameter,
|
||||
# namely the read data.
|
||||
def on_data(&callback)
|
||||
@data_callback = callback
|
||||
end
|
||||
|
||||
# Sets a block to be called when all data
|
||||
# for the part has been read.
|
||||
def on_end(&callback)
|
||||
@end_callback = callback
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init_parser_callbacks
|
||||
@parser.on(:part_begin) do
|
||||
@part = Part.new
|
||||
@header_field = ''
|
||||
@header_value = ''
|
||||
end
|
||||
|
||||
@parser.on(:header_field) do |b, start, the_end|
|
||||
@header_field << b[start...the_end]
|
||||
end
|
||||
|
||||
@parser.on(:header_value) do |b, start, the_end|
|
||||
@header_value << b[start...the_end]
|
||||
end
|
||||
|
||||
@parser.on(:header_end) do
|
||||
@header_field.downcase!
|
||||
@part.headers[@header_field] = @header_value
|
||||
if @header_field == 'content-disposition'
|
||||
if @header_value =~ /name="([^"]+)"/i
|
||||
@part.name = $1
|
||||
end
|
||||
if @header_value =~ /filename="([^;]+)"/i
|
||||
match = $1
|
||||
start = (match.rindex("\\") || -1)+1
|
||||
@part.filename = match[start...(match.length)]
|
||||
end
|
||||
elsif @header_field == 'content-type'
|
||||
@part.mime = @header_value
|
||||
end
|
||||
@header_field = ''
|
||||
@header_value = ''
|
||||
end
|
||||
|
||||
@parser.on(:headers_end) do
|
||||
@on_part.call(@part) unless @on_part.nil?
|
||||
end
|
||||
|
||||
@parser.on(:part_data) do |b, start, the_end|
|
||||
@part.emit_data b[start...the_end]
|
||||
end
|
||||
|
||||
@parser.on(:part_end) do
|
||||
@part.emit_end
|
||||
end
|
||||
|
||||
@parser.on(:end) do
|
||||
@ended = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
From bf03db0979954ef4dd8646c53b73a003af70a953 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
||||
Date: Fri, 24 Jul 2020 20:39:25 +0200
|
||||
Subject: [PATCH] Properly fix test failure with Rack 2.1+.
|
||||
|
||||
Rack is not to blame, just naive test case which was enough so far.
|
||||
|
||||
Fixes #1119
|
||||
---
|
||||
spec/support/shared_examples/request_method.rb | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/spec/support/shared_examples/request_method.rb b/spec/support/shared_examples/request_method.rb
|
||||
index 8e2828a2..917e48ca 100644
|
||||
--- a/spec/support/shared_examples/request_method.rb
|
||||
+++ b/spec/support/shared_examples/request_method.rb
|
||||
@@ -13,8 +13,8 @@
|
||||
end
|
||||
|
||||
it 'handles headers with multiple values' do
|
||||
- request_stub.to_return(headers: { 'Set-Cookie' => 'one, two' })
|
||||
- expect(response.headers['set-cookie']).to eq('one, two')
|
||||
+ request_stub.to_return(headers: { 'Set-Cookie' => 'name=value' })
|
||||
+ expect(response.headers['set-cookie']).to eq('name=value')
|
||||
end
|
||||
|
||||
it 'retrieves the response headers' do
|
||||
|
|
@ -2,93 +2,199 @@
|
|||
%global gem_name faraday
|
||||
|
||||
Name: rubygem-%{gem_name}
|
||||
Version: 0.9.0
|
||||
Release: 6%{?dist}
|
||||
Version: 1.0.1
|
||||
Release: 18%{?dist}
|
||||
Summary: HTTP/REST API client library
|
||||
Group: Development/Languages
|
||||
License: MIT
|
||||
URL: https://github.com/lostisland/faraday
|
||||
URL: https://lostisland.github.io/faraday
|
||||
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
|
||||
# Since we don't have multipart-parser in Fedora, include the essential part
|
||||
# just for testing purposes.
|
||||
# https://github.com/danabr/multipart-parser/blob/master/lib/multipart_parser/parser.rb
|
||||
Source1: https://raw.githubusercontent.com/danabr/multipart-parser/master/lib/multipart_parser/parser.rb
|
||||
# https://github.com/danabr/multipart-parser/blob/master/lib/multipart_parser/reader.rb
|
||||
Source2: https://raw.githubusercontent.com/danabr/multipart-parser/master/lib/multipart_parser/reader.rb
|
||||
# Fix Rack 2.1+ test compatibility.
|
||||
# https://github.com/lostisland/faraday/pull/1171
|
||||
Patch0: rubygem-faraday-1.0.1-Properly-fix-test-failure-with-Rack-2.1.patch
|
||||
# Extracted from:
|
||||
# https://github.com/lostisland/faraday/commit/687108bb4ddc2511aeaae7449dd401fe62dd5ceb
|
||||
Patch1: faraday-1.0.1-net-http-persistent-3-error-kind.patch
|
||||
# "undefined method" error message changed with ruby 3.3
|
||||
# https://github.com/lostisland/faraday/pull/1523
|
||||
# https://github.com/ruby/ruby/pull/6950
|
||||
Patch2: faraday-pr1523-testsuite-undefined-method-change.patch
|
||||
# ruby3.4 backtrace quoting change
|
||||
# https://github.com/lostisland/faraday/pull/1560
|
||||
Patch3: faraday-pr1560-ruby34-backtrace-change.patch
|
||||
# ruby3.4 Hash#inspect formatting change
|
||||
# https://github.com/lostisland/faraday/pull/1604
|
||||
Patch4: faraday-pr1604-ruby34-hash-inspect-formatting-change.patch
|
||||
# https://github.com/lostisland/faraday-rack/pull/13
|
||||
# https://github.com/lostisland/faraday-rack/commit/a590bc34e40b62484440dcd4ab5147c0c02bb425
|
||||
# Patch for rack 3.1 wrt env['rack.input'] is optional
|
||||
Patch5: faraday-rack-pr13-rack31-rack_input.patch
|
||||
# https://github.com/lostisland/faraday/pull/1549
|
||||
# https://github.com/lostisland/faraday/commit/66551ecc79f5d3d5bca1a2523bd8736db8c2220c.patch
|
||||
# Unescape the result of Rack::Utils.build_nested_query for rack 3.1
|
||||
Patch6: faraday-pr1549-unespace-rack-utils-query-result.patch
|
||||
BuildRequires: ruby(release)
|
||||
# Don't install these until test suite can be ran again. See %%check below
|
||||
#BuildRequires: wget
|
||||
#BuildRequires: lsof
|
||||
#BuildRequires: rubygem(sinatra)
|
||||
#BuildRequires: rubygem(minitest)
|
||||
BuildRequires: rubygem(multipart-post) => 1.2
|
||||
BuildRequires: rubygem(multipart-post) < 3
|
||||
BuildRequires: rubygems-devel
|
||||
BuildRequires: ruby
|
||||
BuildRequires: ruby >= 2.3
|
||||
BuildRequires: rubygem(multipart-post)
|
||||
BuildRequires: rubygem(rack)
|
||||
BuildRequires: rubygem(rspec)
|
||||
BuildRequires: rubygem(webmock)
|
||||
# Adapter test dependencies, might be optionally disabled.
|
||||
BuildRequires: rubygem(em-http-request)
|
||||
BuildRequires: rubygem(excon)
|
||||
BuildRequires: rubygem(httpclient)
|
||||
BuildRequires: rubygem(net-http-persistent)
|
||||
BuildRequires: rubygem(rack-test)
|
||||
BuildRequires: rubygem(typhoeus)
|
||||
BuildArch: noarch
|
||||
|
||||
# Filter from RPM's autorequires.
|
||||
%global __requires_exclude ^/usr/bin/env$
|
||||
|
||||
%description
|
||||
HTTP/REST API client library
|
||||
HTTP/REST API client library.
|
||||
|
||||
|
||||
%package doc
|
||||
Summary: Documentation for %{name}
|
||||
Group: Documentation
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
BuildArch: noarch
|
||||
|
||||
%description doc
|
||||
Documentation for %{name}
|
||||
Documentation for %{name}.
|
||||
|
||||
%prep
|
||||
gem unpack %{SOURCE0}
|
||||
mkdir -p multipart_parser/multipart_parser
|
||||
cp %{SOURCE1} %{SOURCE2} multipart_parser/multipart_parser
|
||||
|
||||
%setup -q -D -T -n %{gem_name}-%{version}
|
||||
|
||||
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
||||
%autosetup -n %{gem_name}-%{version} -p1
|
||||
|
||||
%build
|
||||
# Create the gem as gem install only works on a gem file
|
||||
gem build %{gem_name}.gemspec
|
||||
gem build ../%{gem_name}-%{version}.gemspec
|
||||
|
||||
# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
|
||||
# by default, so that we can move it into the buildroot in %%install
|
||||
%gem_install
|
||||
|
||||
# Remove unnecessary files
|
||||
pushd .%{gem_instdir}/
|
||||
rm %{gem_name}.gemspec
|
||||
rm Gemfile
|
||||
rm Rakefile
|
||||
rm .document
|
||||
popd
|
||||
|
||||
%install
|
||||
|
||||
mkdir -p %{buildroot}%{gem_dir}
|
||||
cp -pa .%{gem_dir}/* \
|
||||
cp -a .%{gem_dir}/* \
|
||||
%{buildroot}%{gem_dir}/
|
||||
|
||||
|
||||
|
||||
%check
|
||||
pushd .%{gem_instdir}
|
||||
# The test suite is ran by a custom bash script.
|
||||
# Skip test check until this is resolved.
|
||||
# https://github.com/lostisland/faraday/blob/v0.9.0/script/test
|
||||
#ruby -Ilib:test -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'
|
||||
# We don't care about code coverage.
|
||||
sed -i "/simplecov/ s/^/#/" spec/spec_helper.rb
|
||||
sed -i "/coveralls/ s/^/#/" spec/spec_helper.rb
|
||||
sed -i "/SimpleCov/,/^end$/ s/^/#/" spec/spec_helper.rb
|
||||
|
||||
# We don't need Pry.
|
||||
sed -i "/pry/ s/^/#/" spec/spec_helper.rb
|
||||
|
||||
# We don't have {patron,em-synchrony} available in Fedora.
|
||||
mv spec/faraday/adapter/em_synchrony_spec.rb{,.disabled}
|
||||
mv spec/faraday/adapter/patron_spec.rb{,.disabled}
|
||||
|
||||
# This needs http-net-persistent 3.0+.
|
||||
sed -i '/allows to set min_version in SSL settings/a\ skip' \
|
||||
spec/faraday/adapter/net_http_persistent_spec.rb
|
||||
|
||||
rspec -I%{_builddir}/multipart_parser -rspec_helper -r%{SOURCE1} spec -f d
|
||||
popd
|
||||
|
||||
%files
|
||||
%dir %{gem_instdir}
|
||||
%license %{gem_instdir}/LICENSE.md
|
||||
%{gem_libdir}
|
||||
%{gem_spec}
|
||||
%doc %{gem_instdir}/LICENSE.md
|
||||
%doc %{gem_instdir}/README.md
|
||||
%exclude %{gem_cache}
|
||||
%{gem_spec}
|
||||
|
||||
%files doc
|
||||
%doc %{gem_docdir}
|
||||
%{gem_instdir}/CHANGELOG.md
|
||||
%{gem_instdir}/CONTRIBUTING.md
|
||||
%{gem_instdir}/script
|
||||
%{gem_instdir}/test
|
||||
%doc %{gem_instdir}/CHANGELOG.md
|
||||
%doc %{gem_instdir}/README.md
|
||||
%{gem_instdir}/Rakefile
|
||||
%{gem_instdir}/examples
|
||||
%{gem_instdir}/spec
|
||||
|
||||
%changelog
|
||||
* Mon Dec 01 2025 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-18
|
||||
- Backport upstream patch for rack3.1 change
|
||||
|
||||
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-17
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
|
||||
|
||||
* Sat Jan 18 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-16
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
|
||||
|
||||
* Wed Dec 04 2024 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-15
|
||||
- Use upstreamed patch for ruby34 formatting change
|
||||
|
||||
* Sun Dec 01 2024 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-14
|
||||
- Support ruby3.4 backtrace / Hash inspect formatting change
|
||||
|
||||
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-13
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
|
||||
|
||||
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-12
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-11
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Fri Sep 22 2023 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-10
|
||||
- Backport upstream patch for testsuite with ruby3.3 undefined method
|
||||
message change
|
||||
|
||||
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||
|
||||
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
||||
|
||||
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||
|
||||
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||
|
||||
* Sat Feb 20 2021 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-4
|
||||
- Use upstream patch for net-http-persistent 4.0
|
||||
|
||||
* Sat Feb 20 2021 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.0.1-3
|
||||
- Support for net-http-persistent 4.0 net connection failure error change
|
||||
|
||||
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Thu Jul 23 2020 Vít Ondruch <vondruch@redhat.com> - 1.0.1-1
|
||||
- Update to Faraday 1.0.1.
|
||||
Resolves: rhbz#1756449
|
||||
|
||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.4-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.15.4-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Fri Mar 01 2019 Vít Ondruch <vondruch@redhat.com> - 0.15.4-1
|
||||
- Update to Faraday 0.15.4.
|
||||
|
||||
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
|
|
|
|||
2
sources
2
sources
|
|
@ -1 +1 @@
|
|||
f77914db9c4d4e8b2090447ec84ea746 faraday-0.9.0.gem
|
||||
SHA512 (faraday-1.0.1.gem) = 0374cf32669e1727f435b765d959c5cefd774a451073e88c81c3b49d73885798803b53580f591f1e8862813baf113be7efb7abdc4d526719002f899a7c3b5c82
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue