rabbah commented on a change in pull request #2218: Port Controller from Spray
to Akka
URL:
https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r132814130
##########
File path:
core/controller/src/main/scala/whisk/core/controller/WebActions.scala
##########
@@ -256,36 +264,31 @@ protected[core] object WhiskWebActionsApi extends
Directives {
case _ => throw new Throwable("Invalid header")
}
- private def interpretHttpResponse(code: StatusCode, headers:
List[RawHeader], str: String, transid: TransactionId): RequestContext => Unit =
{
+ private def interpretHttpResponse(code: StatusCode, headers:
List[RawHeader], str: String, transid: TransactionId) = {
val parsedHeader: Try[MediaType] = headers.find(_.lowercaseName ==
`Content-Type`.lowercaseName) match {
case Some(header) =>
- HttpParser.parseHeader(header) match {
- case Right(header: `Content-Type`) =>
- val mediaType = header.contentType.mediaType
+ MediaType.parse(header.value) match {
+ case Right(mediaType: MediaType) =>
// lookup the media type specified in the content
header to see if it is a recognized type
MediaTypes.getForKey(mediaType.mainType ->
mediaType.subType).map(Success(_)).getOrElse {
// this is a content-type that is not recognized,
reject it
Failure(RejectRequest(BadRequest,
Messages.httpUnknownContentType)(transid))
}
-
- case _ =>
- Failure(RejectRequest(BadRequest,
Messages.httpUnknownContentType)(transid))
+ case _ => Failure(RejectRequest(BadRequest,
Messages.httpUnknownContentType)(transid))
}
case None => Success(`text/html`)
}
parsedHeader.flatMap { mediaType =>
- if (mediaType.binary) {
- Try(HttpData(Base64.getDecoder().decode(str))).map((mediaType,
_))
+ if (mediaType.binary || mediaType == `application/json`) {
+ Try(new String(Base64.getDecoder().decode(str),
StandardCharsets.UTF_8)).map((mediaType, _))
Review comment:
once this is merged - let's open an issue to support json without base64
serdes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services