QnaList > Groups > Akka-User > Apr 2016
faq

[akka-user] Akka 2.4.3 Cannot Read Response Body When Using Http 1.0 Request

Hi,
  Below is a whole unit test in my project, and it fails when using 
`HTTP/1.0` protocol, success when using `HTTP/1.1`. Can somebody help 
explain the reason?
// setup mock server
val json   """
    |{"result":true}
  """.stripMargin
val source = Source(ByteString(json) :: Nil)
val mockRoutes = path("test" / "proxy_chunked.do") {
  get {
    complete {
      HttpResponse(StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, source))
    }
  }
} ~ complete {
  HttpResponse(StatusCodes.NotFound)
}
val (_, host, port) = AkkaHttpTestUtils.temporaryServerHostnameAndPort()
val bindingFuture = Http().bindAndHandle(mockRoutes, host, port)
val request = HttpRequest(
  HttpMethods.GET,
  uri = s"http://${host}:${port}/test/proxy_chunked.do",
  protocol = HttpProtocols.`HTTP/1.0`
)
val futureByteString = Http().singleRequest(request).map { resp =>
  println("response returned")
  resp.entity.dataBytes
} flatMap { source =>
  source.runFold(ByteString.empty)((r, bs) => r ++ bs)
}
val byteString = Await.result(futureByteString, 10 seconds)
byteString.utf8String shouldEqual (json)
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

asked Apr 4 2016 at 23:09

xiaog zh 's gravatar image



5 Replies for : [akka-user] Akka 2.4.3 Cannot Read Response Body When Using Http 1.0 Request
Could you include the error?
Cheers,
√
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

answered Apr 5 2016 at 00:44

Viktor Klang 's gravatar image


debug level logs:
INFO - akka.event.slf4j.Slf4jLogger - Slf4jLogger started
DEBUG - akka.event.EventStream - logger log1-Slf4jLogger started
DEBUG - akka.event.EventStream - Default Loggers started
DEBUG - com.typesafe.sslconfig.akka.AkkaSSLConfig - Initializing 
AkkaSSLConfig extension...
DEBUG - com.typesafe.sslconfig.akka.AkkaSSLConfig - buildHostnameVerifier: 
created hostname verifier: 
[email protected]
DEBUG - akka.io.TcpListener - Successfully bound to /127.0.0.1:57407
DEBUG - akka.http.impl.engine.client.PoolInterfaceActor - (Re-)starting 
host connection pool to localhost:57407
DEBUG - akka.http.impl.engine.client.PoolSlot$SlotProcessor - become 
unconnected, from subscriber pending
DEBUG - akka.http.impl.engine.client.PoolSlot$SlotProcessor - become 
unconnected, from subscriber pending
DEBUG - akka.http.impl.engine.client.PoolSlot$SlotProcessor - become 
unconnected, from subscriber pending
DEBUG - akka.http.impl.engine.client.PoolSlot$SlotProcessor - become 
unconnected, from subscriber pending
DEBUG - akka.io.TcpOutgoingConnection - Attempting connection to 
[localhost/127.0.0.1:57407]
DEBUG - akka.io.TcpListener - New connection accepted
DEBUG - akka.io.TcpOutgoingConnection - Connection established to 
[localhost/127.0.0.1:57407]
INFO - akka.actor.LocalActorRef - Message [akka.io.Tcp$ResumeReading$] from 
Actor[akka://ProxyActorTest/user/StreamSupervisor-1/$$b#-1567866888] to 
Actor[akka://ProxyActorTest/system/IO-TCP/selectors/$a/1#1829940929] was 
not delivered. [1] dead letters encountered. This logging can be turned off 
or adjusted with configuration settings 'akka.log-dead-letters' and 
'akka.log-dead-letters-during-shutdown'.
DEBUG - akka.http.impl.engine.client.PoolSlot$SlotProcessor - Slot 0 
disconnected after regular connection close
response returned
Futures timed out after [10 seconds]
java.util.concurrent.TimeoutException: Futures timed out after [10 seconds]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:190)
at 
scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
at scala.concurrent.Await$.result(package.scala:190)
at 
com.oneapm.mordor.actors.marathon.ProxyActorTest$$anonfun$1$$anonfun$apply$mcV$sp$3.apply$mcV$sp(ProxyActorTest.scala:160)
at 
com.oneapm.mordor.actors.marathon.ProxyActorTest$$anonfun$1$$anonfun$apply$mcV$sp$3.apply(ProxyActorTest.scala:122)
at 
com.oneapm.mordor.actors.marathon.ProxyActorTest$$anonfun$1$$anonfun$apply$mcV$sp$3.apply(ProxyActorTest.scala:122)
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

answered Apr 5 2016 at 01:09

xiaog zh 's gravatar image


The mandatory connection closing in HTTP 1.0 doesn't seem to work with 
non-strict entities.
HttpResponse(StatusCodes.OK, entity = 
HttpEntity(ContentTypes.`application/json`, json)) works.
HttpResponse(StatusCodes.OK, entity = 
HttpEntity(ContentTypes.`application/json`, source), headers = 
Connection("close") :: Nil) produces the same failure when requested with 
HTTP 1.1.
Could you open a ticket?
Cheers
André
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

answered Apr 5 2016 at 03:14

=?ISO-8859-1?Q?Andr=E9?= 's gravatar image


https://github.com/akka/akka/issues/20236
Can somebody give me a little clue or even guide me get this problem fixed?
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

answered Apr 5 2016 at 05:29

xiaog zh 's gravatar image


Let's continue the discussion in the ticket.
As Viktor found, it'd seem the 1.0 spec simply does not support this
though...?
Cheers,
Konrad 'ktoso' Malawski
Akka <http://akka.io/> @ Lightbend <http://lightbend.com/>
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]
To post to this group, send email to [email protected]
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

answered Apr 5 2016 at 05:47

Konrad Malawski 's gravatar image


Related discussions

Tagged

Group Akka-user

asked Apr 4 2016 at 23:09

active Apr 5 2016 at 05:47

posts:6

users:4

Akka-dev

Akka-user

©2013 QnaList.com