Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP response headers: multiple Link values

I'm working on SEO for a Rails App.

The website is fully localized, and I'm following this google article to add hreflang alternate links to the pages.

The HTML links in the <head> are ok.

I'm having some troubles with the response headers.

I understand that I'm supposed to provide values for each alternative version of the page, but I'm not sure about how to set multiple values.

I tried to pass them as a comma separated list. Browsers seem to receive it correctly, but since individual values contain semi-colons it looks wrong.

Is there any reference on it? Even an example webpage that is known to implement it correctly would help.

like image 668
tompave Avatar asked Aug 18 '14 17:08

tompave


People also ask

Can a HTTP header have multiple values?

The HTTP Headers can have one or more values depending on the header field definitions. A multi-valued header will have comma separated values. Here are a few examples of headers that contain multiple values: Cache-Control: no-cache, no-store, must-revalidate.

Can you have multiple of the same header?

A recipient MAY combine multiple header fields with the same field name into one field-name: field-value pair, without changing the semantics of the message, by appending each subsequent field value to the combined field value in order, separated by a comma.

What is multi value headers?

Multi-value headers. If requests from a client or responses from a Lambda function contain headers with multiple values or contains the same header multiple times, or query parameters with multiple values for the same key, you can enable support for multi-value header syntax.


1 Answers

I have no experience with this, but according to the examples in the same RFC they get separated by comma:

Link: </TheBook/chapter2>;
      rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
      </TheBook/chapter4>;
      rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel

It’s indirectly confirmed by 5.3 (emphasis mine):

Note that extension relation types are REQUIRED to be absolute URIs in Link headers, and MUST be quoted if they contain a semicolon (";") or comma (",") (as these characters are used as delimiters in the header itself).

like image 149
unor Avatar answered Oct 08 '22 10:10

unor