From 986e4ab558a5a8ec3d30e3ba0e935c14ca932271 Mon Sep 17 00:00:00 2001 From: fstrr Date: Thu, 2 Mar 2023 15:53:20 -0800 Subject: [PATCH] Syntax highlighting, fix resources --- techniques/server-side-script/SVR5.html | 136 +++++++++++++----------- 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/techniques/server-side-script/SVR5.html b/techniques/server-side-script/SVR5.html index d38ab3bcb1..fdb42920cd 100644 --- a/techniques/server-side-script/SVR5.html +++ b/techniques/server-side-script/SVR5.html @@ -1,62 +1,76 @@ -Specifying the default language in the HTTP header

Specifying the default language in the HTTP header

ID: SVR5

Technology: server-side-script

Type: Technique

When to Use

-

Server-side technologies, including server-side scripting languages and server configuration files for setting HTTP headers.

-

Description

-

The objective of this technique is to provide information on the primary language or languages in a Web Page, in order to identify the audience of the content. The Content-Language HTTP header can contain a list of one or more language codes, which can be used for language negotiation between a user agent and a server. If the language preferences in a user agent are set correctly, language negotiation can help the user to find a language version of the content that suits their preferences.

-

Note that the Content-Language HTTP header does not serve to identify the language used for processing the content. The content processing language can be identified by means of other techniques, such as the attributes lang and xml:lang in markup languages.

-

This technique ensures that the primary language of the document, as specified for example in the lang or xml:lang attribute, is listed in the Content-Language HTTP header.

-

Examples

-
-

Setting content language in Java Servlet and JSP

- -

In Java Servlet or JavaServer Pages (JSP), developers can use response.setHeader("Content-Language", lang), in which "lang" stands for a language tag (for example, "en" for English):

- -
…
+
+
+	
+		Specifying the default language in the HTTP header
+		
+	
+	
+		

Specifying the default language in the HTTP header

+
+

ID: SVR5

+

Technology: server-side-script

+

Type: Technique

+
+
+

When to Use

+

Server-side technologies, including server-side scripting languages and server configuration files for setting HTTP headers.

+
+
+

Description

+

The objective of this technique is to provide information on the primary language or languages in a Web page, in order to identify the audience of the content. The Content-Language HTTP header can contain a list of one or more language codes, which can be used for language negotiation between a user agent and a server. If the language preferences in a user agent are set correctly, language negotiation can help the user to find a language version of the content that suits their preferences.

+

Note that the Content-Language HTTP header does not serve to identify the language used for processing the content. The content processing language can be identified by means of other techniques, such as the attributes lang and xml:lang in markup languages.

+

This technique ensures that the primary language of the document, as specified for example in the lang or xml:lang attribute, is listed in the Content-Language HTTP header.

+
+
+

Examples

+
+

Setting content language in Java Servlet and JSP

+

In Java Servlet or JavaServer Pages (JSP), developers can use response.setHeader("Content-Language", lang), in which "lang" stands for a language tag (for example, "en" for English):

+ +
...
 public void doGet(HttpServletRequest request, HttpServletResponse response)
-    throws ServletException, IOException 
-{
-…
-  response.setHeader("Content-Language", "en");
-  PrintWriter out = response.getWriter();
-…
-}
-
-
-

Setting content language in PHP

- -

In PHP, developers can send a raw HTTP header with the header method. The following example sets the language to French:

- -
<?php  header('Content-language: fr');  …  ?>  
-
-

Tests

-

Procedure

-
    -
  1. Use a Live HTTP Header viewer to find the value of the "Content-Language" header.
  2. -
  3. Check that this value matches the default language of the Web page.
  4. -
-
-

Expected Results

-
    -
  • Step #2 is true.
  • -
-
-

Resources

- -

- W3C Internationalization FAQ: HTTP and meta for language information -

- - -

- Declaring metadata about the language(s) of the intended audience in Authoring HTML: Language declarations - W3C Working Group Note 3 June 2014.

- - -

- RFC 7321 3.1.3.2. Content-Language

- - -

- header in the PHP Manual.

- -
\ No newline at end of file + throws ServletException, IOException { + ... + response.setHeader("Content-Language", "en"); + PrintWriter out = response.getWriter(); + ... +}
+
+
+

Setting content language in PHP

+ +

In PHP, developers can send a raw HTTP header with the header method. The following example sets the language to French:

+ +
<?php header('Content-language: fr'); ... ?>
+
+

Tests

+

Procedure

+
    +
  1. Use a Live HTTP Header viewer to find the value of the Content-Language header.
  2. +
  3. Check that this value matches the default language of the Web page.
  4. +
+
+
+

Expected Results

+
    +
  • Step #2 is true.
  • +
+
+
+ +
+

Resources

+ +
+ + \ No newline at end of file