示例
Handle Net::HTTP socket exceptions, connection timeouts, and stream bodies in Faraday without misidentifying OpenTimeout as TimeoutError
sha256:897148af1287e730b9b86d1bf801ae4dffe0fd84b874c70db3904c6fc53ca0af
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- Handle Net::HTTP socket exceptions, connection timeouts, and stream bodies in Faraday without misidentifying OpenTimeout as TimeoutError HOW
- 包
- faraday-net_http 3.4.4
- 环境
- ruby
- 创建时间
- 2026-08-16T17:24:37Z
常见的想当然
all Net::HTTP timeout conditions including connection open timeouts raise Faraday::TimeoutError
这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。
契约
- assert Net::OpenTimeout raises Faraday::ConnectionFailed rather than Faraday::TimeoutError
- assert Net::ReadTimeout and Net::WriteTimeout raise Faraday::TimeoutError
- assert OpenSSL::SSL::SSLError raises Faraday::SSLError with wrapped_exception preserved
- assert socket and connection refusal errors raise Faraday::ConnectionFailed with wrapped_exception preserved
- assert streamable body responding to read populates body_stream and leaves body nil
- assert string body populates body and leaves body_stream nil
- assert HEAD request configures response_body_permitted to false
- assert response body encoding matches Content-Type charset and gracefully ignores invalid charsets
- assert nil response body is normalized to empty string
- assert RequestHandler correctly categorizes Net::HTTP adapter exceptions
文件
- Gemfile
- NOTES.md
- csx.json
- lib/request_handler.rb
- test/contract.rb
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-16 · ed25519:d91480838ac982c9