Recent

Author Topic: How to set custom HOST header with TIdHTTP  (Read 10464 times)

tolisoft

  • Newbie
  • Posts: 4
How to set custom HOST header with TIdHTTP
« on: April 02, 2013, 11:56:42 am »
Hello Colleagues,
I want to set custom Host header with TIdHTTP component but I did not have luck to do is. At the moment I am trying something like:
Code: [Select]
    HttpClient:=TidHTTP.Create(nil);
    HttpClient.HTTPOptions := [];
    Response := TStringList.Create;
    success := True;

    if HostHeader.Text <> '' then
        HttpClient.Request.CustomHeaders.Values['Host'] := HostHeader.Text;

    try
        response.Text := HttpClient.Get(SrvAddrEdit.text + '?supported_flags=supported_flags');
    except
        ShowMessage('Cannot read from the server!');
        success := False;
    end;             

I am using wireshark and I sniff the traffic so custom Host header is missing in http header. Maybe I am not setting it correctly.

What is the right way to set custom Host header for this http request?

 

TinyPortal © 2005-2018