You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/05/18 09:23:52 UTC

[GitHub] philipjkim opened a new issue #152: Why is the body of web action response base64 string, not object?

philipjkim opened a new issue #152: Why is the body of web action response base64 string, not object?
URL: https://github.com/apache/incubator-openwhisk-package-alarms/issues/152
 
 
   In `action/lib/common.js` and `action/alarmWebAction.js`, there are web action responses which the body is bas64 string of JSON. I wonder why the body is base64 string, not the response or error object. 
   
   ```js
   // https://github.com/apache/incubator-openwhisk-package-alarms/blob/master/action/lib/common.js#L100-L104
   return {
       statusCode: statusCode,
       headers: { 'Content-Type': 'application/json' },
       body: new Buffer(JSON.stringify(params)).toString('base64')
   };
   ```
   
   I think the following return statement is more simple:
   
   ```js
   return {
       statusCode: statusCode,
       headers: { 'Content-Type': 'application/json' },
       body: params
   };
   ```
   
   After testing with a simple web action, I found the difference between the base64-encoded JSON string body and object body:
   - with base64 body, I get one-line JSON response like:
     ```
     {"__ow_method":"get","__ow_headers":{"host":"controllers","user-agent":"curl/7.54.0","accept":"*/*"},"__ow_path":""}
     ```
   - with object body, I get multi-line pretty JSON response like:
     ```json
     {
       "__ow_method": "get",
       "__ow_headers": {
         "host": "controllers",
         "user-agent": "curl/7.54.0",
         "accept": "*/*"
       },
       "__ow_path": ""
     }
     ```
   
   Is there any intent using base64-encoded JSON string body?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services