Programmatically pass additional header info along with URL to open a browser

守給你的承諾、 提交于 2020-01-06 02:49:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!