I am accessing the Google Maps API via a TWebBrowser in Delphi XE3.
Initially the TWebBrowser is loaded via Navigate2 to 'about:blank'. The HTML to be rendered is then generated dynamically in code and loaded into the TWebBrowser via a stream.
It looks like the TWebBrowser only sends the referer header when actually navigating to a URL, not when sending a GET request, as when loading the API from a script element.
I can't use Navigate2 to load the "web page", since there is no server to load it from.
Is there any way to force TWebBrowser to include a specific referer header when it issues GETs, when the HTML it is rendering is loaded from a stream? After a couple of hours of searching, I have not found any hint of a way to do this.
Before you dynamically load HTML into
TWebBrowser, modify the HTML to insert a
<base href="..."> tag into the HTML's
<head> to indicate the URL where the HTML originally came from. That URL is then used for resolving relative URLs, establish the Referer, etc.
©2020 All rights reserved.