idHTTP Returns <!DOCTYPE html> error

426 Views Asked by At

What I'm trying to achieve is return some data from a web page using idhtp1.GET When I do:

sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=IPHERE');
redt1.Lines.Add(idhtpGeo.Get(sGeo));

it works perfectly, but once I do this:

sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=' + sData);

(added sData) it gives me the error DOCTYPE html.

image

Here is a part of the source:

procedure TfrmMap.GetGeo(sData : string);
begin
  try
  idhtpGeo.ConnectTimeout := 5000;
  idhtpGeo.HandleRedirects := True;
  sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=' + sData);
  redt1.Lines.Add(sGeo);
  redt1.Lines.Add(idhtpGeo.Get(sGeo));
  except
    MessageDlg('Failed to load Geo Data!', mtError, [mbOK], 0);
  end;
end;  

sData is just the IP. I also tried using the SynaCode unit to encode the URL(sGeo), and it didn't give me any errors but the data being returned wasn't correct.

The encoded URL looks as follows:

http://www.robin-william.net/Osiris/geo.php?ip=88.106.170.45%0A

Any help would be greatly appreciated.

1

There are 1 best solutions below

1
On

Nevermind I found the problem. Just had to trim the string named sData.