jesse-r-s-hines commented on issue #10681:
URL: https://github.com/apache/apisix/issues/10681#issuecomment-1904299908

   Currently, if you do not specify `input_format` and there's no 
`Content-Type` header the plugin will skip trying to parse the response body. 
This allows arbitrary transformations as it doesn't try to parse the body but 
still runs the template which can access the original body with `_body`.
   
   The only problem is it spams warnings about "no input format to parse 
request/response body". I'd like an explicit `"input_format": "none"` to just 
silence that warning.
   
   In our case we also have an upstream service that sometimes returns 
incorrect `Content-Type` headers, so it would be nice if `"input_format": 
"none"` caused it to not try to parse the content regardless of `Content-Type` 
and let the template logic do whatever is necessary to convert to the correct 
format. Currently if you don't strip `Content-Type` with `response-rewrite` the 
plugin will abort before calling the template if it can't parse the original 
response.
   
   So something like:
   
   Original response:
   ```
   Content-Type: application/json
   Body:
   not actually json
   ```
   
   Config:
   ```json
   "body-transformer": {
       "response": {
           "template": "{\"message\": \"{* string.gsub(_body, 'not ', '') *}\"}"
       }
   }
   ```
   
   Transformed response:
   ```
   Content-Type: application/json
   Body:
   {"message": "actually json"}
   ```
   
   
   
   Thanks!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to