mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-27 23:40:38 +05:30
Use non-streaming api when not invoked with block
Defaulting to the streaming api of `HTTP::Client` causes some issues since the streaming respone content needs to be accessed through #body_io rather than #body
This commit is contained in:
parent
cdb6eef055
commit
a3864e6691
@ -29,6 +29,8 @@ module Invidious::ConnectionPool
|
|||||||
abstract def pool : DB::Pool(PoolClient)
|
abstract def pool : DB::Pool(PoolClient)
|
||||||
|
|
||||||
{% for method in %w[get post put patch delete head options] %}
|
{% for method in %w[get post put patch delete head options] %}
|
||||||
|
# Streaming API for {{method.id.upcase}} request.
|
||||||
|
# The response will have its body as an `IO` accessed via `HTTP::Client::Response#body_io`.
|
||||||
def {{method.id}}(*args, **kwargs, &)
|
def {{method.id}}(*args, **kwargs, &)
|
||||||
self.client do | client |
|
self.client do | client |
|
||||||
client.{{method.id}}(*args, **kwargs) do | response |
|
client.{{method.id}}(*args, **kwargs) do | response |
|
||||||
@ -42,11 +44,11 @@ module Invidious::ConnectionPool
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Executes a {{method.id.upcase}} request.
|
||||||
|
# The response will have its body as a `String`, accessed via `HTTP::Client::Response#body`.
|
||||||
def {{method.id}}(*args, **kwargs)
|
def {{method.id}}(*args, **kwargs)
|
||||||
{{method.id}}(*args, **kwargs) do | response |
|
self.client do | client |
|
||||||
return response
|
return client.{{method.id}}(*args, **kwargs)
|
||||||
ensure
|
|
||||||
response.body_io?.try &. skip_to_end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user