0

I heard that the meta tag in html can be used to specify response key-value pairs, if so, how does it work under the hood? How does the server responding with html page understands the meta tag before the html parser parses it?

Example of the meta tag:

<meta http-equiv="set-cookie" content="userid=xyz; expires=Wednesday, 08-Aug-00 23:59:59 GMT;" />
Then008
  • 13
  • 1
  • 3

1 Answers1

1

I heard that the meta tag in html can be used to specify response key-value pairs

In very limited terms.

if so, how does it work under the hood? How does the server responding with html page understands the meta tag before the html parser parses it?

It doesn't. It is interpreted by the browser.

Example of the meta tag

cookie is not a valid value for http-equiv. I think you meant set-cookie which is marked as non-conforming in the specification so you should not use it.

is not a valid attribute delimited character either. You need " or '.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Yeah I was confused about the usage of cookie as it's sent in the request headers but the example I posted is copied from http://www.mytoptutorials.com/html/tag/setting-cookies-meta-tag/. – Then008 Jul 09 '18 at 09:23
  • 1
    @user547729 — They are giving bad advice. – Quentin Jul 09 '18 at 09:26
  • The browser can only interpret the HTML after the server responds with the resource. When a response has already been recieved how does the browser even transfer those header field names with their respective values? – Then008 Jul 09 '18 at 09:29
  • @user547729 — The same way as the browser transfers the `` tag, and all the rest of the HTML. It's part of the response body! – Quentin Jul 09 '18 at 09:35
  • I guess I'm asking it in a confusing way, sorry. What I mean is that the HTML interpretation is initiated when the response has already been made by the server. Those response header field names specified in the meta tags is understood by the browser but isn't it too late for the browser to transfer those "response" header field names as the response has already been completed before interpretation. – Then008 Jul 09 '18 at 09:45
  • Since the browser is **reading** the response and not sending it. No. It isn't too late. – Quentin Jul 09 '18 at 09:47
  • That means meta tags cannot be used to transfer **response headers**, right? – Then008 Jul 09 '18 at 09:51
  • @user547729 — No. That is why the attribute has **equiv** in the name. They are equivalent to HTTP response headers. – Quentin Jul 09 '18 at 09:52
  • Ohh. Thanks alot! – Then008 Jul 09 '18 at 09:53