Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indy HTTP client- Need help on Overwriting HTTP method
#1
Hi, I used to built a Upnp control point using indy 10.5.9.4967.  Wtih Upnp event subscribe, I overwrite the HTTP method with following code and it works:
form1.myhttp.HTTPMethod := 'SUBSCRIBE';
......
form1.myhttp.Get(URL);

With Indy 10.6.1.518, I find idHTTP client doesn't have property "HTTPMethod" anymore and I tried following two property which doesn't work:
myhttp.Request.Method := 'SUBSCRIBE';
myhttp.Request.MethodOverride := 'SUBSCRIBE';

Can someone help me out?  thank you!
Reply
#2
In order to specify a custom method, you will have to call TIdHTTP.DoRequest() directly. However, it is currently a protected method, so you will have to use an accessor class to reach it, eg:

Code:
type
  TIdHTTPAccess = class(TIdHTTP)
  end;

TIdHTTPAccess(form1.myhttp).DoRequest('SUBSCRIBE', URL, nil, nil, []);

Reply
#3
(03-04-2020, 07:56 PM)rlebeau Wrote:
(03-04-2020, 04:39 AM)happyzj Wrote: With Indy 10.6.1.518, I find idHTTP client doesn't have property "HTTPMethod" anymore and I tried following two property which doesn't work:
myhttp.Request.Method := 'SUBSCRIBE';
myhttp.Request.MethodOverride := 'SUBSCRIBE';

In order to specify a custom method, you will have to call TIdHTTP.DoRequest() directly. However, it is a protected method, so you will have to use an accessor class to reach it, eg:

Code:
type
  TIdHTTPAccess = class(TIdHTTP)
  end;

TIdHTTPAccess(form1.myhttp).DoRequest('SUBSCRIBE', URL, nil, nil, []);

Thank you very much Rlebeau, in this case, would the custom header set in form1.myhttp - "myhttp.Request.CustomHeaders.Add(header)"would still take effect?  thank you.
Reply
#4
(03-04-2020, 08:00 PM)happyzj Wrote: would the custom header set in form1.myhttp - "myhttp.Request.CustomHeaders.Add(header)"would still take effect?

Yes. All of the higher level methods (Get(), Post(), Put(), etc) call DoRequest() to do the actual work for preparing and sending the request, and reading the response.

Reply
#5
(03-05-2020, 07:21 PM)rlebeau Wrote:
(03-04-2020, 08:00 PM)happyzj Wrote: would the custom header set in form1.myhttp - "myhttp.Request.CustomHeaders.Add(header)"would still take effect?

Yes.  All of the higher level methods (Get(), Post(), Put(), etc) call DoRequest() to do the actual work for preparing and sending the request, and reading the response.

Hi rlebeau, as always, thank you very much for your help, everthing is working now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)