Delphi w Indy 10: idHTTPRequest POST is always HTTP 1.0, how to do HTTP 1.1?

We make POST requests to the web service.

It works great.

However, we notice that requests are always HTTP 1.0, which causes our web server to refuse gzip responses.

If the requests are HTTP 1.1, the responses will be gzipped.

How can we request Indy 10 to issue HTTP 1.1 POST requests?

Thanks!

+6
source share
2 answers

Include the hoKeepOrigProtocol parameter in the hoKeepOrigProtocol property HTTPOptions (set it to True). Except that the ProtocolVersion property is set to pv1_1 (which is the default value).

The TIdCustomHTTP.Post method TIdCustomHTTP.Post has a comment explaining the current behavior:

Currently, when sending a POST, IdHTTP automatically installs the protocol to version 1.0, regardless of its initial value. This is due to the fact that there are some servers that do not fully respect RFC. In particular, they do not respect the sending / non-sending header of the Expect: 100-Continue header. Until we find the best solution that does NOT violate the RFC, we will limit POSTS to version 1.0.

A few lines below is a change in version 1.0 with the following comment:

 // If hoKeepOrigProtocol is SET, it is possible to assume that the developer // is sure in operations of the server if not (hoKeepOrigProtocol in FOptions) then begin if Connected then begin Disconnect; end; FProtocolVersion := pv1_0; end; 

And the above code is skipped (the version does not change) if you have the hoKeepOrigProtocol option included in HTTPOptions .

+11
source

just need to write:

idHTTP.HTTPOptions: = [hoKeepOrigProtocol];

-1
source

Source: https://habr.com/ru/post/1208691/


All Articles