Currently we reset the flush strategy after a request is written and its response is received. If client starts writing another pipelined request on the same connection, it ends up using an overridden flush strategy of the previous request that is still waiting for its response.
Modifications:
For client connections (pipelined and non-pipelined) move flush strategy reset from "after full request-response completion" to "before completion of the request write". Using beforeFinally we guarantee that reset will happen before any retry/repeat operator initiates a new request on the same connection. It's safe to use "before" because for in-flight request the effective FlushStrategy is captured at the beginning of the write and doesn't change regardless of the reset. Only a new request will see the effect of the reset.
Reproduce described scenario in FlushStrategyOnClientTest.
Refactor FlushStrategyOnServerTest to use TransportObserver to observe flushes. This helps to use a real HttpServerContext instead of faking a ServerContext and reuse code for FlushStrategyOnClientTest.
Rename Cancellable in NettyHttpServer to highlight it's responsible for reset of FlushStrategy.
Result:
Second pipelined request on the same connection uses its own FlushStrategy.
Motivation:
Currently we reset the flush strategy after a request is written and its response is received. If client starts writing another pipelined request on the same connection, it ends up using an overridden flush strategy of the previous request that is still waiting for its response.
Modifications:
beforeFinally
we guarantee that reset will happen before any retry/repeat operator initiates a new request on the same connection. It's safe to use "before" because for in-flight request the effectiveFlushStrategy
is captured at the beginning of the write and doesn't change regardless of the reset. Only a new request will see the effect of the reset.FlushStrategyOnClientTest
.FlushStrategyOnServerTest
to useTransportObserver
to observe flushes. This helps to use a realHttpServerContext
instead of faking aServerContext
and reuse code forFlushStrategyOnClientTest
.Cancellable
inNettyHttpServer
to highlight it's responsible for reset of FlushStrategy.Result:
Second pipelined request on the same connection uses its own
FlushStrategy
.