+Doc #20192 update http example to always consume response (#21241)

The single-request-in-actor-example does not consume the response
in where the status code is not OK.  Although this is unlikely
to cause backpressure issues as the response is likely to have
a HttpEntity.Strict entity, the example is confusing as it
does not follow the warning about always consuming the response.
This commit is contained in:
Bernard Leach 2016-08-24 19:16:08 +10:00 committed by Konrad Malawski
parent 57fdc758ce
commit ac8c4dc1b1
5 changed files with 47 additions and 44 deletions

View file

@ -207,8 +207,9 @@ class HttpClientExampleSpec extends WordSpec with Matchers with CompileOnlySpec
def receive = {
case HttpResponse(StatusCodes.OK, headers, entity, _) =>
log.info("Got response, body: " + entity.dataBytes.runFold(ByteString(""))(_ ++ _))
case HttpResponse(code, _, _, _) =>
case resp @ HttpResponse(code, _, _, _) =>
log.info("Request failed, response code: " + code)
resp.discardEntityBytes()
}
}