codeconsole opened a new issue, #15172: URL: https://github.com/apache/grails-core/issues/15172
### Expected Behavior # RestfulController has bad logic for json requests Performing a `application/json` save or update request with multipartForm data results in a `text/html` response. For modern REST usage it’s a leaky abstraction—mixing input and output negotiation leads to surprising 302s. Either the redirect logic should change for json requests or the default response type binding should change. https://github.com/apache/grails-core/blob/0de145df4b8055d35cc91b8acf8477142b23445b/grails-rest-transforms/src/main/groovy/grails/rest/RestfulController.groovy#L112-L122 With that logic: ``` curl -i -L -X POST 'http://localhost:8081/user/save' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148' \ -H 'Accept: application/json' \ --data 'name=Sample' ``` results in ```html <!doctype html> <html lang="en" class="no-js"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title> Show User </title> </head> <body> .... ``` instead of what is expected ```json {"id":6,"name":"Sample"} ``` This is due to `User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148` which is Safari web browser. A decision needs to be made: Should json save/update events result in redirects when json is requested? A default grails app has the following yml ```html grails: mime: disable: accept: header: userAgents: - Gecko - WebKit - Presto - Trident ``` Removing WebKit has no impact on results ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information _No response_ ### Example Application _No response_ ### Version 7.0.0 -- 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]
