Re: [akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-05 Thread Konrad Malawski
Let's continue the discussion in the ticket.
As Viktor found, it'd seem the 1.0 spec simply does not support this
though...?

On Tue, Apr 5, 2016 at 2:29 PM, xiaog zh  wrote:

> https://github.com/akka/akka/issues/20236
>
> Can somebody give me a little clue or even guide me get this problem fixed?
>
> On Tuesday, April 5, 2016 at 6:14:30 PM UTC+8, André wrote:
>>
>> 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é
>>
>> On Tuesday, April 5, 2016 at 10:17:42 AM UTC+2, xiaog zh wrote:
>>>
>>> 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:
>>> com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@39a2fc30
>>> 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)
>>>
>>>
>>> On Tuesday, April 5, 2016 at 3:44:37 PM UTC+8, √ wrote:

 Could you include the error?

 --
 Cheers,
 √
 On Apr 5, 2016 08:37, "xiaog zh"  wrote:

> 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().singleReq

Re: [akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-05 Thread xiaog zh
https://github.com/akka/akka/issues/20236

Can somebody give me a little clue or even guide me get this problem fixed?

On Tuesday, April 5, 2016 at 6:14:30 PM UTC+8, André wrote:
>
> 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é
>
> On Tuesday, April 5, 2016 at 10:17:42 AM UTC+2, xiaog zh wrote:
>>
>> 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: 
>> com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@39a2fc30
>> 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)
>>
>>
>> On Tuesday, April 5, 2016 at 3:44:37 PM UTC+8, √ wrote:
>>>
>>> Could you include the error?
>>>
>>> -- 
>>> Cheers,
>>> √
>>> On Apr 5, 2016 08:37, "xiaog zh"  wrote:
>>>
 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.u

Re: [akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-05 Thread André
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é

On Tuesday, April 5, 2016 at 10:17:42 AM UTC+2, xiaog zh wrote:
>
> 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: 
> com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@39a2fc30
> 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)
>
>
> On Tuesday, April 5, 2016 at 3:44:37 PM UTC+8, √ wrote:
>>
>> Could you include the error?
>>
>> -- 
>> Cheers,
>> √
>> On Apr 5, 2016 08:37, "xiaog zh"  wrote:
>>
>>> 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)
>>>
>>>
>>>
>>> -- 
>>> >> Read the docs: http://akka.io/docs/
>>> >> Check the FAQ: 
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >> Search the archives: 
>>> https://groups.google.com/group/akka-user
>>> --- 
>>> You received this message bec

Re: [akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-05 Thread xiaog zh
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: 
com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@39a2fc30
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)


On Tuesday, April 5, 2016 at 3:44:37 PM UTC+8, √ wrote:
>
> Could you include the error?
>
> -- 
> Cheers,
> √
> On Apr 5, 2016 08:37, "xiaog zh" > wrote:
>
>> 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)
>>
>>
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> 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 akka-user+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You recei

Re: [akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-05 Thread Viktor Klang
Could you include the error?

-- 
Cheers,
√
On Apr 5, 2016 08:37, "xiaog zh"  wrote:

> 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)
>
>
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka 2.4.3 cannot read response body when using http 1.0 request

2016-04-04 Thread xiaog zh
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)



-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.