简体   繁体   English

使用自定义请求标题打开URL

[英]Open URL with Custom Request headers

My team hosts a set of central web pages that is used by many different organizations. 我的团队托管了一组中央网页,许多不同的组织都在使用这些网页。 These pages change their look and feel (fonts, images, etc.) based on which organization calls the page. 这些页面根据哪个组织调用页面来改变其外观(字体,图像等)。 This is determined by a custom HTTP Request Header: "organization". 这由自定义HTTP请求标头确定:“组织”。 I am building a test site to test the look and feel of ALL of the different organizations. 我正在建立一个测试站点,以测试所有不同组织的外观。

My plan was to have a web site with a drop down where our QA people can choose an Org then click something (button/link) to open the central web pages with the look and feel for that org. 我的计划是建立一个带下拉菜单的网站,供我们的质量检查人员选择一个组织,然后单击某些内容(按钮/链接)以打开具有该组织外观的中心网页。 Note that when calling these central pages the URL in the browser MUST change to the URL of the page. 请注意,在调用这些中心页面时,浏览器中的URL必须更改为页面的URL。 So far all ideas/samples I can find involve getting the page content from the remote server and displaying it IN the calling page (URL does NOT change). 到目前为止,我能找到的所有想法/示例都涉及从远程服务器获取页面内容并将其显示在调用页面中(URL不变)。 Bottom line is I need to be able to set HTTP Request Headers then open a new URL with those headers. 最重要的是,我需要能够设置HTTP请求标头,然后使用这些标头打开一个新的URL。

I can use JavaScript, ASP Classic, Java and/or other similar technologies/languages. 我可以使用JavaScript,ASP Classic,Java和/或其他类似的技术/语言。 Any ideas to get me started? 有什么想法可以让我入门吗?

I did find some similar questions to mine but none of them allow the URL to change in the browser so it doesn't work. 我确实找到了一些类似的问题要解决,但没有一个问题允许URL在浏览器中更改,因此无法正常工作。

EDIT: 编辑:

OK so it seems to not be possible via code. 确定,因此似乎无法通过代码实现。 We cannot use a proxy since corporate has locked our browsers down and we cannot change proxy settings (even on dynamically created browser profiles). 我们无法使用代理,因为企业已将浏览器锁定,并且我们无法更改代理设置(即使在动态创建的浏览器配置文件中)。 So is it possible to add custom HTTP Request Headers in IIS Express? 那么是否可以在IIS Express中添加自定义HTTP请求标头? If so I can write java test cases that modify the config files of IIS Express then start the server and load a central test page that redirects to the appropriate pages. 如果是这样,我可以编写修改IIS Express的配置文件的Java测试用例,然后启动服务器并加载重定向到适当页面的中央测试页面。 Can this be done? 能做到吗?

I am dying to know how the architect of this solution intended for end users to add headers indicating their organizational membership. 我很想知道这个解决方案的架构师打算如何让最终用户添加标头来指示其组织成员身份。 Corporate proxy perhaps? 企业代理也许? Who knows. 谁知道。 Seems cray cray. 似乎克雷克雷。 Whatever the intention was, you should be trying to adhere to it, if you want an accurate test. 无论打算是什么,如果要进行准确的测试,都应该尝试遵守它。

But if can't do that, and your sole need is to perform testing under the assumption that the headers can be added somehow (just not by you), and you have control over your browser, you can use an add-on, such as Modify Headers for FireFox . 但是,如果不能做到这一点,并且您唯一的需要是在可以以某种方式添加标头(只是您自己不能添加标头)的前提下执行测试,并且您可以控制浏览器,则可以使用附加组件,例如作为FireFox的修改标题

You could also build something separate to act as a proxy and add the headers, such as the solution to this question . 您还可以构建一些单独的东西来充当代理并添加标头,例如此问题的解决方案。 Point your browser at the proxy and voila. 将浏览器指向代理和瞧​​。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用javascript打开网址并为请求设置自定义HTTP标头? - How to open a url using javascript and set custom HTTP headers to the request? 使用 JavaScript 中的自定义请求标头导航到 URL - Navigate to URL with custom request headers in JavaScript 如何在javascript中将请求标头作为数组添加到window.open post url? - How to add request headers as array to window.open post url in javascript? 自定义标头未添加到Request对象 - custom headers are not added to Request object serviceworker 是否可以向 url 请求添加标头 - serviceworker is it possible to add headers to url request 自定义标头已添加到Access-Control-Request-Headers中 - Custom headers get added to Access-Control-Request-Headers Angular 2中针对每个请求的自定义Http标头 - Custom Http headers in Angular 2 for every request 使用自定义标头ReactJS获取GET请求 - Fetch GET Request with custom headers ReactJS 带有多个部分自定义标头的jQuery ajax请求? - jQuery ajax request with mutiple part custom headers? 是否可以使用XHR(“Ajax”请求)发送自定义标头? - Is it possible to send custom headers with an XHR (“Ajax” request)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM