These are chat archives for IndySockets/Indy

Aug 2016
Ludwig Behm
Aug 29 2016 23:09
Hy everyone, I'm trying to overwrite a response generated by datasnap (running on TIdHTTPWebBrokerBridge). TDSRESTWebDispatcher sends eventual StatusCode 401 and to hide the annoying browser login window, I want to send StatusCode 403 instead. After trying several DataSnap specific events which show absolutely no effect, I would like to try to intercept the response on the Indy-level.
Is there a nice way to hook into the server response and overwrite every StatusCode of 401 with 403? PS: I have access to an Intercept interface.
Remy Lebeau
Aug 29 2016 23:19
If you don't have access to the actual source that is populating the original HTTP response, you can't really change its behavior. With an Intercept, it might be possible to alter the data as it is being sent, but that would require parsing the HTTP data that passes through the Intercept. The data is arbitrary bytes from the Intercept's perspective, so you would need to write a stateful parser in case you get multiple OnSend events. I would be more inclined to suggest figuring out why DataSnap is sending a 401 reply to begin with and see if there is a way to change that behavior, instead of trying to modify the response data after the fact. Especially since modifying the 401 may break non-browser clients that could have logged in without prompting the user. Why are you using a web browser to access a DataSnap REST server in the first place?