class Anthropic::Internal::Transport::PooledNetRequester
def build_request(request, &blk)
-
(Array(Net::HTTPGenericRequest, Proc))
-
Other tags:
- Yieldparam: -
Parameters:
-
blk
(Proc
) -- -
request
(Hash{Symbol=>Object}
) -- .
Options Hash:
(**request)
-
:headers
(Hash{String=>String}
) -- -
:url
(URI::Generic
) -- -
:method
(Symbol
) --
Other tags:
- Api: - private
def build_request(request, &blk) method, url, headers, body = request.fetch_values(:method, :url, :headers, :body) req = Net::HTTPGenericRequest.new( method.to_s.upcase, !body.nil?, method != :head, URI(url.to_s) # ensure we construct a URI class of the right scheme ) headers.each { req[_1] = _2 } case body in nil nil in String req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"] req.body_stream = Anthropic::Internal::Util::ReadIOAdapter.new(body, &blk) in StringIO req["content-length"] ||= body.size.to_s unless req["transfer-encoding"] req.body_stream = Anthropic::Internal::Util::ReadIOAdapter.new(body, &blk) in Pathname | IO | Enumerator req["transfer-encoding"] ||= "chunked" unless req["content-length"] req.body_stream = Anthropic::Internal::Util::ReadIOAdapter.new(body, &blk) end [req, req.body_stream&.method(:close)] end