ihx 0 Posted January 4, 2019 Hello, I'm porting my app to Tokyo from Rio. I'm calling a SOAP service which was imported through WSDL and to accept gzipped responses I had modified the OnBeforePost event like this: procedure TMainForm.HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Data: Pointer); const INTERNET_OPTION_HTTP_DECODING = 65; contentEncodingHeader = 'Accept-Encoding: gzip, deflate'; var Flag: LongBool; begin if( MyAppSettings.SoapGzipEnabled ) then begin Flag := True; HttpAddRequestHeaders(Data, PChar(contentEncodingHeader), Length(contentEncodingHeader), HTTP_ADDREQ_FLAG_ADD); InternetSetOption(Data, INTERNET_OPTION_HTTP_DECODING, PChar(@Flag), SizeOf(Flag)); end; //if end; //proc This worked like a charm in Seattle + Tokyo, result ot the method in SOAP envelope was gzipped according to MSNetMon and automatically unzipped in the returning ArrayOfItems. Unfortunately, guys at EMBT changed OnBeforePost parameters from THTTPReqResp + Pointer to THTTPReqResp + THTTPClient. So I modified my OnBeforePost event to this: procedure TMainForm.HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; Client: THTTPClient); begin if( MyAppSettings.SoapGzipEnabled ) then begin Client.AcceptEncoding := 'gzip, deflate'; end; //if end; //proc According to MSNetMon, the returned SOAP envelope is gzipped and has the same size as when called the old method in Seattle and Tokyo, so I think so far so good. The problem is I get EDOMParseError 'An invalid character was found at Line 1' and that's all 😞 When I remove the Client.AcceptEncoding line, everything works, just the result is a plain xml with a size of 3MB (gzipped is 65kB), so gzippid is a must. Any idea what can be wrong? I think I'm missing something but can't find it. Thanks in advance! Share this post Link to post
Jacek Laskowski 57 Posted January 4, 2019 try to debug HTTPClient after exit from this event Share this post Link to post
ihx 0 Posted January 4, 2019 Unfortunately debugging didn't help, exit from this event is OK, the exception occurs after last step from the THTTPReqResp.Execute, when the result should be passed to program. I think the problem is that the Delphi client cannot decode the received gzipped data from webservice, as the InternetSetOption was not set and to be honest I have no idea where to put it. The Soap.SOAPHTTPTrans.pas unit as well as System.Net.HTTPClient,pas seems to be completely rewritten in Rio and the existing solution for processing gzipped results in previous Delphi versions won't work Share this post Link to post
Jacek Laskowski 57 Posted January 5, 2019 Then try to debug the GZIP usage or place of parsing response headers. IMHO Rio has many errors in HTTPClient classes, see: Share this post Link to post
ihx 0 Posted January 5, 2019 Well it seems the same story again - upgrading existing projects to latest version of Delphi is pain in the <you know where>. First it takes several weeks or months for new external components to appear and then trouble getting things which worked to work as they should in the latest version... I can't afford wasting more time fixing upgrade problems and telling the boss that investing money into Delphi upgrade + all necessary components was a waste of time (again). So I'm back to 10.2 for now, we'll see when the gyus at EMBT get fixed this 😞 Share this post Link to post
Dmitry Arefiev 101 Posted January 5, 2019 (edited) 1) This is worth to report, but rather as a feature request. Support for automatic decoding may be done easily using WinHTTP WINHTTP_OPTION_DECOMPRESSION option. And probably already in 10.3 Update 1. As a quick workaround, you can modify System.Net.HttpClient.Win.pas, for example: function TWinHTTPClient.DoExecuteRequest(const ARequest: THTTPRequest; var AResponse: THTTPResponse; const AContentStream: TStream): TWinHTTPClient.TExecutionResult; begin ..... // Enable automatic decoding LOptionValue := WINHTTP_DECOMPRESSION_FLAG_GZIP or WINHTTP_DECOMPRESSION_FLAG_DEFLATE or WINHTTP_DECOMPRESSION_FLAG_ALL; WinHttpSetOption(LRequest.FWRequest, WINHTTP_OPTION_DECOMPRESSION, @LOptionValue, sizeof(LOptionValue)); .... end; 2) THTTPReqResp was using WinINet API directly. In 10.3 it was completely reworked to enable support of other platforms, including Linux, OSX, etc. Edited January 5, 2019 by Dmitry Arefiev 1 Share this post Link to post
ihx 0 Posted January 7, 2019 @Dmitry Arefiev Dmitry thanks for hint, I did it same way, now the gzipped result is correctly unzipped and processed 👍 Share this post Link to post
Sherlock 663 Posted January 7, 2019 Quote I cant enter text!!! @ihxPlease, explain what you mean. Is it safe to assume, you want the previous post deleted? Share this post Link to post
ihx 0 Posted January 7, 2019 @Sherlock Yes I wan to delete that post - I used the @ tag with name and I after that I couldn't enter any new letters or delete existing text. I know this happens sometimes on IPBoard in Firefox. Workaround is to write the text first and then add the @ tag to beginning. Share this post Link to post
Dmitry Arefiev 101 Posted January 7, 2019 On 1/5/2019 at 3:10 PM, ihx said: .... we'll see when the gyus at EMBT get fixed this 😞 @ihx, please, report this issue to https://quality.embarcadero.com Share this post Link to post