dubeejw commented on a change in pull request #2218: Port Controller from Spray 
to Akka
URL: 
https://github.com/apache/incubator-openwhisk/pull/2218#discussion_r130368591
 
 

 ##########
 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:
   The `application/json` content-type is no longer considered a binary type in 
Akka, so we can probably remove the base64 encoding at some point.
 
----------------------------------------------------------------
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

Reply via email to