File: http_accept.html

package info (click to toggle)
libapache2-mod-rivet 3.2.2-1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 6,296 kB
  • sloc: xml: 8,554; tcl: 7,568; ansic: 7,094; sh: 5,017; makefile: 195; sql: 91; lisp: 78
file content (33 lines) | stat: -rw-r--r-- 4,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>http_accept</title><link rel="stylesheet" type="text/css" href="rivet.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Apache Rivet 3.2"><link rel="up" href="commands.html" title="Rivet Tcl Commands and Variables"><link rel="prev" href="html.html" title="html"><link rel="next" href="import_keyvalue_pairs.html" title="import_keyvalue_pairs"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">http_accept</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="html.html"><img src="images/prev.png" alt="Prev"></a> </td><th width="60%" align="center">Rivet Tcl Commands and Variables</th><td width="20%" align="right"> <a accesskey="n" href="import_keyvalue_pairs.html"><img src="images/next.png" alt="Next"></a></td></tr></table></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="http_accept"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>http_accept — Parse HTTP Accept header lines</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex;   word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::http_accept
                 ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>-zeroweight</code></em></span>?
                 ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>-default</code></em></span>?
                 ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>-list</code></em></span>?
                http_accept_line</span> </div></div></div><div class="refsect1"><a name="idm1289"></a><h2>Description</h2><p style="width:90%">
                Command for parsing HTTP Accept header lines that tell the
                server about preferences and/or capabilities of the browser 
                (e.g. content language,media type, etc.). The following 
                script
            </p><p style="width:90%">
                <span style="font-family:monospace"><span class="command"><strong>::rivet::http_accept</strong></span></span> returns a dictionary
                value in which every content preference is matched to its
                precedence value
            </p><pre class="programlisting">load_headers
set language_precedence [::rivet::http_accept $headers(Accept-Language)]
foreach lan [dict keys $language_precedence] {
                puts "$lan -&gt; [dict get $language_precedence $lan]"
}</pre><p style="width:90%">
                when run from a browser where 5 languages were chosen
                would output
            </p><pre class="programlisting">en-us -&gt; 1
en -&gt; 0.8
it -&gt; 0.6
de-de -&gt; 0.4
fr-fr -&gt; 0.2</pre><p style="width:90%">
                The <em class="replaceable"><code>-list</code></em> switch would suppress
                the precedence values and the accepted fields 
                are returned listed with decreasing precedence order.
            </p><pre class="programlisting"> puts [::rivet::http_accept -list $headers(Accept)]
text/html application/xhtml+xml application/xml */*
            </pre><p style="width:90%">

            </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="html.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="commands.html"><img src="images/up.png" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="import_keyvalue_pairs.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">html </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> import_keyvalue_pairs</td></tr></table></div></body></html>