scala-server-lambda icon indicating copy to clipboard operation
scala-server-lambda copied to clipboard

Loss of content type

Open armandopadilla opened this issue 5 years ago • 1 comments

First of all, nice work.

I spotted an issue with the loss of the Content Type within the AkkaHttpLambdaHandler.proxyToAkkaRequest method.

What happens.

  1. User makes a request with Content-Type set to 'application/json' (can be anything really).
  2. Code recreates the HttpRequest by using HttpEntity.apply on the body.
  3. The above step results in the below, which can show the loss of the content-type.

HttpEntity.Strict(text/plain; charset=UTF-8,{ "name": "ArmandoPadilla" })

From the Akka-http perspective. This causes issues when using entity[as[JsValue]] which results in.

The request's Content-Type is not supported. Expected: application/json

armandopadilla avatar Sep 18 '19 22:09 armandopadilla

Interesting, thanks for reporting. At initial glance the code looks right:

https://github.com/howardjohn/scala-server-lambda/blob/master/akka-http-lambda/src/main/scala/io/github/howardjohn/lambda/akka/AkkaHttpLambdaHandler.scala#L45-L55

but maybe there is a subtle bug.

I'd be happy to merge any PRs but I probably won't be able to get to fixing this anytime soon due to lack of time

howardjohn avatar Sep 18 '19 22:09 howardjohn