Permalink
Browse files

=akka-http remove unnecessary copying of entity (#2522)

Just a small improvement which I noticed while skimming the code.

The HttpEntity call made on this line already makes the content type be `text/plain` (UTF-8), the additional call made here created an entire copy of the entity object for each request and did not really have to do that since it is the right content type already. See here: https://github.com/akka/akka-http/blob/master/akka-http-core/src/main/scala/akka/http/scaladsl/model/HttpEntity.scala#L253
https://github.com/akka/akka-http/blob/master/akka-http-core/src/main/scala/akka/http/scaladsl/model/HttpEntity.scala#L253
  • Loading branch information...
ktoso authored and nbrady-techempower committed Jan 27, 2017
1 parent c7b6b23 commit fadd399886dcbf008902e1b9bbc44587e0b4bcc2
@@ -14,5 +14,5 @@ class PlaintextHandler(components: {
}
}
def response = HttpResponse(StatusCodes.OK, entity = HttpEntity("Hello, World!").withContentType(`text/plain`.withCharset(`UTF-8`)))
def response = HttpResponse(StatusCodes.OK, entity = HttpEntity("Hello, World!"))
}

0 comments on commit fadd399

Please sign in to comment.