HTTP2 Chunked responses from asset files


(ssanthosh) #1

I was trying the HTTP2 settings in Pay 2.6 and I encountered this error when serving static content from the assets folder.
It looks like we cannot and is not necessary return Chunked-Respones in HTTP2
How can I get around it
Thanks in advance
java.lang.IllegalArgumentException: requirement failed: HTTP/1.0 responses must not have a chunked entity
at scala.Predef$.require(Predef.scala:277)
at akka.http.scaladsl.model.HttpResponse.(HttpMessage.scala:410)
at akka.http.scaladsl.model.HttpResponse$.apply(HttpMessage.scala:478)
at play.core.server.akkahttp.AkkaModelConversion.$anonfun$convertResult$2(AkkaModelConversion.scala:235)
at akka.http.scaladsl.util.FastFuture$.$anonfun$map$1(FastFuture.scala:23)
at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:55)
at akka.http.scaladsl.util.FastFuture$.map$extension(FastFuture.scala:23)
at play.core.server.akkahttp.AkkaModelConversion.$anonfun$convertResult$1(AkkaModelConversion.scala:219)
at play.core.server.common.ServerResultUtils.resultConversionWithErrorHandling(ServerResultUtils.scala:134)
at play.core.server.akkahttp.AkkaModelConversion.convertResult(AkkaModelConversion.scala:241)
at play.core.server.AkkaHttpServer.$anonfun$executeAction$3(AkkaHttpServer.scala:303)
at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
at akka.http.scaladsl.util.FastFuture$.$anonfun$transformWith$3(FastFuture.scala:51)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at play.api.libs.streams.Execution$trampoline$.executeScheduled(Execution.scala:109)


(Marcos Pereira) #2

Maybe the message is a little misleading since it says HTTP/1.0. Can you show the kind of request you are sending?

This is defined at RFC7548, section 8.1:

HTTP/2 uses DATA frames to carry message payloads. The “chunked” transfer encoding defined in Section 4.1 of [RFC7230] MUST NOT be used in HTTP/2.

Best.


(ssanthosh) #3

I created a basic Play Scala sample application and enabled it with HTTP2 as per Play Documentation. https://www.playframework.com/documentation/2.6.x/AkkaHttpServer
The only difference is that I included bootstrap.css (Large file) to my index.html and put it in the
public/stylesheets folder.
Now when I access https://localhost:9443/assets/html/index.html from Chrome browser which supports HTTP2, (I see the browser using h2 protocol), I get this error.

The point is, I did not write any custom code to serve the css file. It is whatever comes out of the box with Play.

This leads me to think that whatever underlying mechanism the AkkaHttpServer using to create the http2 frames should factor in Chunked responses coming from layer above and
convert the chunks to normal http2 frames and factor in END_STREAM frame when appropriate

I’ll be more than happy to contribute

Santhosh