TIdHTTP
in Indy 8 simply does not support PUT
requests. It only supports HEAD
, GET
, and POST
requests. And unfortunately, you can't force a PUT
request manually (without altering Indy's source code) as the TIdHTTP.DoRequest()
method takes a TIdHTTPMethod
enum that defines only those 3 HTTP requests.
Indy 9 added support for additional HTTP requests: OPTIONS
, TRACE
, PUT
, DELETE
, and CONNECT
.
Indy 10 added support for user-specified HTTP methods, so TIdHTTP
is no longer limited to a hard-coded subset of requests.
The current version of Indy (at the time of this writing) is 10.6.2.5457, and still supports Delphi 6 (1).
I STRONGLY urge you to upgrade away from Indy 8, as it is EXTREMELY old and no longer supported by Indy's developers. Please don't use it. If you do not want to upgrade all the way to Indy 10, then at least upgrade to Indy 9 (though it is no longer supported either, except for bug fixes).
That being said, there is one possible workaround for Indy 8: IF the HTTP server you are sending your data to supports "verb tunneling", then you can use TIdHTTP.Post()
to send a POST
request while instructing the server to treat the request as if it were PUT
instead, eg:
// Sadly, there is no *standard* HTTP header for verb tunneling.
// Different vendors use different headers:
//
// Most vendors use 'X-HTTP-Method-Override'
// Microsoft uses 'X-HTTP-Method'
// IBM uses 'X-METHOD-OVERRIDE'
//
// Send whichever one is appropriate for your particular server, or
// just send them all and let the server work it out...
Http1.Request.ExtraHeaders.Values['X-HTTP-Method-Override'] := 'PUT';
Http1.Request.ExtraHeaders.Values['X-HTTP-Method'] := 'PUT';
Http1.Request.ExtraHeaders.Values['X-METHOD-OVERRIDE'] := 'PUT';
Http1.Post(URI, ...);
(1): support for pre-Unicode versions of Delphi, which includes Delphi 6, will be dropped in a future Indy 11 maintenance release. Indy 10 will be the last version to support old compilers.