Reputation: 7408
I'm facing a weird issue in which the Get()
method of TIdHTTP
on a valid URL is returning a blank string, but only on specific machines. Also, in these same machines, if I navigate to the same URL in Google Chrome, it will return the expected value.
No exception occurs, just an empty string is returned. Tried both HTTPS and HTTP versions of the URL, and the same problem happens. Also tried using the CookieManager
and setting HandleRedirects
to true, no luck.
The machine in question is Windows 2012 server, and my app is whitelisted on its firewall.
Is there anything I could try to diagnose / fix this issue ? I'm lost !
Upvotes: 1
Views: 382
Reputation: 596592
Unfortunately, there is not enough information provided to diagnose what is happening. Since there is no exception being raised, there are only two possibilities. Either:
the server really is sending blank body data, such as if you are using Indy's default UserAgent
and the server does not like/recognize it. Some servers are UserAgent-aware and will deliver different data for different agents. Try setting the TIdHTTP.Request.UserAgent
property to mimic a real web browser, see if the result changes.
the server is sending body data, but the data is getting lost when converted to a String
, such as due to an invalid charset conversion. TIdHTTP.Get()
has an overload that fills a TStream
instead of return a String
, you can use that to rule out any issue with charset handling.
I suggest you look at the raw HTTP traffic to make sure the request and response are what you are expecting them to be. To capture the raw data, you can use a packet sniffer, like Wireshark. Or assign one of Indy's TIdConnectionIntercept
-derived components, like TIdLog...
, to the TIdHTTP.Intercept
property.
Upvotes: 3