- Clarify behaviour of streaming bodies and copy
Protocol::Rack::Body::Streaming
toProtocol::HTTP::Body::Streamable
. - Copy
Async::HTTP::Body::Writable
toProtocol::HTTP::Body::Writable
.
- Ensure chunks are flushed if required, when streaming.
The Request[]
and Response[]
methods now support keyword arguments as a convenient way to set various positional arguments.
# Request keyword arguments:
client.get("/", headers: {"accept" => "text/html"}, authority: "example.com")
# Response keyword arguments:
def call(request)
return Response[200, headers: {"content-Type" => "text/html"}, body: "Hello, World!"]
The Request
class now exposes a #interim_response
attribute which can be used to handle interim responses both on the client side and server side.
On the client side, you can pass a callback using the interim_response
keyword argument which will be invoked whenever an interim response is received:
client = ...
response = client.get("/index", interim_response: proc{|status, headers| ...})
On the server side, you can send an interim response using the #send_interim_response
method:
def call(request)
if request.headers["expect"] == "100-continue"
# Send an interim response:
request.send_interim_response(100)
end
# ...
end