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_r130366069
########## File path: core/controller/src/main/scala/whisk/core/controller/WebActions.scala ########## @@ -251,36 +258,31 @@ protected[core] object WhiskWebActionsApi extends Directives { } } - 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), "UTF-8")).map((mediaType, _)) Review comment: is json considered binary still per the akka types (vs spray) and could we perhaps allow json body in http requests to skip base64 encoding in the future? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services