Compare commits

...

8 Commits

Author SHA1 Message Date
HoneyryderChuck
84f5b303f2 Merge branch 'fix-faraday' into 'master'
adding error to faraday env on parallel failed requests

See merge request os85/httpx!234
2023-01-21 01:09:10 +00:00
HoneyryderChuck
f12c90f0ea adding error to faraday env on parallel failed requests 2023-01-20 23:57:07 +00:00
HoneyryderChuck
36c840ba5c Merge branch 'catlee/parallel_no_raise' into 'master'
Don't raise_for_status automatically in the Faraday adapter

Closes #224

See merge request os85/httpx!232
2023-01-20 17:28:25 +00:00
HoneyryderChuck
1f946fe66e Merge branch 'ruby-32' into 'master'
adding ruby 3.2 to CI

See merge request os85/httpx!233
2023-01-20 17:19:03 +00:00
HoneyryderChuck
8dae534bd0 faraday adapter: do not raise errors on parallel requests
instead, fill up the response with the same gibberish as typhoeus.
2023-01-20 17:18:36 +00:00
HoneyryderChuck
2e7d33f917 adding ruby 3.2 to CI 2023-01-20 10:39:22 +00:00
Chris AtLee
0c9fcdb60a Enable RaiseError middleware 2023-01-19 16:13:11 -05:00
Chris AtLee
cd93bddc2f Don't raise_for_status automatically in the Faraday adapter 2023-01-19 15:08:10 -05:00
5 changed files with 59 additions and 14 deletions

View File

@ -27,11 +27,6 @@ variables:
paths:
- coverage/
.jit_matrix: &jit_matrix
parallel:
matrix:
- RUBYOPT: ["", "--jit --jit-warnings --jit-wait"]
.yjit_matrix: &yjit_matrix
parallel:
matrix:
@ -76,19 +71,16 @@ test ruby 2/5:
./spec.sh ruby 2.5
test ruby 2/6:
<<: *test_settings
<<: *jit_matrix
only:
- master
script:
./spec.sh ruby 2.6
test ruby 2/7:
<<: *test_settings
<<: *jit_matrix
script:
./spec.sh ruby 2.7
test ruby 3/0:
<<: *test_settings
<<: *jit_matrix
script:
./spec.sh ruby 3.0
test ruby 3/1:
@ -96,6 +88,11 @@ test ruby 3/1:
<<: *yjit_matrix
script:
./spec.sh ruby 3.1
test ruby 3/2:
<<: *test_settings
<<: *yjit_matrix
script:
./spec.sh ruby 3.2
test truffleruby:
<<: *test_settings
script:
@ -108,7 +105,7 @@ coverage:
variables:
BUNDLE_WITHOUT: test:assorted
image: "ruby:3.1"
image: "ruby:3.2"
script:
- gem install simplecov --no-doc
# this is a workaround, because simplecov doesn't support relative paths.
@ -130,7 +127,7 @@ docs:
stage: deploy
needs:
- coverage
image: "ruby:3.1"
image: "ruby:3.2"
before_script:
- gem install hanna-nouveau
script:

View File

@ -0,0 +1,27 @@
version: '3'
services:
httpx:
image: ruby:3.1
environment:
- HTTPBIN_COALESCING_HOST=another
- HTTPX_RESOLVER_URI=https://doh/dns-query
links:
- "nghttp2:another"
depends_on:
- doh
doh:
image: registry.gitlab.com/os85/httpx/nghttp2:1
depends_on:
- doh-proxy
entrypoint:
/usr/local/bin/nghttpx
volumes:
- ./test/support/ci:/home
command:
--conf /home/doh-nghttp.conf --no-ocsp --frontend '*,443'
doh-proxy:
image: publicarray/doh-proxy
environment:
- "UNBOUND_SERVICE_HOST=127.0.0.11"

View File

@ -210,10 +210,14 @@ module Faraday
if parallel?(env)
handler = env[:parallel_manager].enqueue(env)
handler.on_response do |response|
response.raise_for_status
if response.is_a?(::HTTPX::Response)
save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
response_headers.merge!(response.headers)
end
else
env[:error] = response.error
save_response(env, 0, "", {}, nil)
end
end
return handler
end
@ -229,6 +233,7 @@ module Faraday
request.response_on_data = env.request.on_data if env.request.stream_response?
response = session.request(request)
# do not call #raise_for_status for HTTP 4xx or 5xx, as faraday has a middleware for that.
response.raise_for_status unless response.is_a?(::HTTPX::Response)
save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
response_headers.merge!(response.headers)

View File

@ -29,6 +29,22 @@ class FaradayTest < Minitest::Test
assert_equal "OK", resp2.reason_phrase
end
def test_adapter_in_parallel_errors
resp1 = nil
connection = create_connection
connection.in_parallel do
resp1 = connection.get("http://wfijojsfsoijf")
assert connection.in_parallel?
assert_nil resp1.reason_phrase
end
assert !connection.in_parallel?
assert_equal 0, resp1.status
assert_nil resp1.reason_phrase
assert_equal "", resp1.body
refute_nil resp1.env[:error]
end
def test_adapter_get_handles_compression
res = get(build_path("/gzip"))
assert JSON.parse(res.body.to_s)["gzipped"]

View File

@ -82,7 +82,7 @@ if [[ ${RUBY_VERSION:0:1} = "3" ]] && [[ ! $RUBYOPT =~ "jit" ]]; then
fi
# Lint first
if [[ ${RUBY_VERSION:0:3} = "3.1" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then
if [[ ${RUBY_VERSION:0:3} = "3.2" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then
bundle exec rake rubocop
fi