the akka-http client documentation states the following:
Be sure to consume the response entities dataBytes:Source[ByteString,Unit] by for example connecting it to a Sink (for example response.discardEntityBytes() if you don’t care about the response entity), since otherwise Akka HTTP (and the underlying Streams infrastructure) will understand the lack of entity consumption as a back-pressure signal and stop reading from the underlying TCP connection!
When using singleHttpRequest to get a Future[HttpResponse], I am sometimes using an unmarshaller that was created using Unmarshaller.strict.
When using Unmarhsaller[HttpEntity, T],
Looking at the akka source code, it seems that after using marshallers obtained using Unmarshaller.strict, we should call discardEntityBytes, or make sure the unmarshaller calls that method, or consumes the bytes. When using Unmarshaller[HttpEntity, T], we would need to make sure those bytes are consumed.
Is this a correct assumption?
Update:
This is the implementation of Unmarshaller.strict:
def strict[A, B](f: A ⇒ B): Unmarshaller[A, B] = Unmarshaller(_ => a ⇒ FastFuture.successful(f(a)))
Which calls Unmarshaller.apply, which ends up calling withMaterializer, which creates an anonymous Unmarshaller. See more on github. No where in this implementation does the unmarshaller consumes or verifies the consumption of bytes from the entity, or calls discardBytes.