HTML 中的自定义 HTTP 请求标头

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3047711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:27:54  来源:igfitidea点击:

Custom HTTP Request headers in HTML

htmlhttpformsheader

提问by matsko

Does anyone know if its possible to send out custom http REQUEST headers in HTML without having to use javascript (no xhr wrapper).

有谁知道是否可以在 HTML 中发送自定义 http REQUEST 标头而不必使用 javascript(没有 xhr 包装器)。

Would it be possible to define them as meta tags within the head? Or may they be defined in the form somewhere?

是否可以将它们定义为头部内的元标记?或者它们可以在某处的形式中定义?

<meta http-equip="x-something-custom" name="custom value" />

this works, however, this is a RESPONSE header. What I need to set a REQUEST header.

这是有效的,但是,这是一个 RESPONSE 标头。我需要设置一个 REQUEST 标头。

I'm not looking for setting hidden fields in forms, but actual raw http header manipulation with html tags.

我不是在寻找在表单中设置隐藏字段,而是使用 html 标签进行实际的原始 http 标头操作。

Is this possible?

这可能吗?

采纳答案by BalusC

Does anyone know if it's possible to send out custom HTTP request headers in HTML without having to use JavaScript?

有谁知道是否可以在 HTML 中发送自定义 HTTP 请求标头而不必使用 JavaScript?

No, it's not possible.

不,这不可能。

What is it, the functional requirement for which you think that this is the solution? Elaborate that, then we may be able to come up with a suitable solution.

它是什么,您认为这是解决方案的功能需求?详细说明一下,然后我们可能会想出一个合适的解决方案。

回答by Ben S

Why do you need to set something in the header?

为什么你需要在标题中设置一些东西?

If it's for testing you can use a Firefox extensionor a web proxyto manipulate the header.

如果是为了测试,您可以使用Firefox 扩展Web 代理来操作标头。

Otherwise, it cannot be done from HTML.

否则,它不能从 HTML 完成