We are doing POST requests to a web service.
Works fine.
However, we notice that the requests are always HTTP 1.0, which causes our web server to decline to gzip the responses.
If the requests are HTTP 1.1, then the responses are gzipped.
How do we properly ask Indy 10 to issue HTTP 1.1 POST requests?
Thank you!
Include the hoKeepOrigProtocol
option into the HTTPOptions
property set (set it to True). Except that keep the ProtocolVersion
property set to pv1_1
(which is the default value).
In the TIdCustomHTTP.Post
method code there's a comment explaining the current behavior:
Currently when issuing a POST, IdHTTP will automatically set the protocol to version 1.0 independently of the value it had initially. This is because there are some servers that don't respect the RFC to the full extent. In particular, they don't respect sending/not sending the Expect: 100-Continue header. Until we find an optimum solution that does NOT break the RFC, we will restrict POSTS to version 1.0.
A few lines below is the change to the 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 is not changed) if you have the hoKeepOrigProtocol
option included in the HTTPOptions
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With