25

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

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.

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

Is this possible?

Richard JP Le Guen
  • 28,364
  • 7
  • 89
  • 119
matsko
  • 21,895
  • 21
  • 102
  • 144
  • Related post -[How to set a Header field on POST a form?](https://stackoverflow.com/q/9516865/465053) – RBT Sep 29 '22 at 05:59

2 Answers2

22

Does anyone know if it's possible to send out custom HTTP request headers in HTML without having to use 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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    Well I am trying to get this done using a RESTful URL that supplies the same data as JSON, XML or a file download (application/json, application/xml or text/plain). I think the correct way to use HTTP in this case is to send an Accepts header, but I think I am going to have to do something else. – Jason Jackson May 22 '14 at 23:23
  • There is no functional requirement. Using html form withour ajax is a more simple solution. – Anton Lyhin Aug 27 '16 at 14:41
  • 1
    One requirement is - to set the Authorization headers required to use Oauth2 protected API being called on the form submit – Anurag Jul 25 '22 at 14:01
7

Why do you need to set something in the header?

If it's for testing you can use a Firefox extension or a web proxy to manipulate the header.

Otherwise, it cannot be done from HTML.

Ben S
  • 68,394
  • 30
  • 171
  • 212