问题
I have an application which at one point wants to launch a particular URL in the default browser. This is pretty simple and can be achieved using ShellExecute on Windows. However the catch is that the server expects some additional custom header information (for authentication/identification purposes) to be sent along with the GET request. Is there any way by which this (additional header) information could be passed to the browser while launching it?
Note:- I want to launch the default browser and not use a Web browser control
回答1:
As I understand you have only one option: add intermidiate page (in internet or on localhost).
You have to create yoursite.com/sendHeaders.php or localhost/sendHeaders.php (or any another extension; choose language what do you prefer), which does following:
- Unpack parameters (URL and headers),
- Connect to the URL, send the headers,
- Print the answer in browser.
So you will open in your browser intermediate page yoursite.com/sendHeaders.php?url=realUrl&headers=packedHeaders, but browser will show you a page realUrl, which received proper headers.
来源:https://stackoverflow.com/questions/19021226/programmatically-pass-additional-header-info-along-with-url-to-open-a-browser