You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Martin Kraemer <Ma...@mch.sni.de> on 1998/05/26 17:53:16 UTC
Negotiation - can someone explain?
The language negotiation algorithm seems to be somewhat unpredictable.
Combined with DirectoryIndex and language definitions like "en-US" or
"de-CH" they even look broken to me.
In a directory containing these files...
lrwxrwxrwx 1 martin 14 May 26 16:38 index.html.shtml -> index.shtml.en
-rw-r--r-- 1 martin 339 May 7 13:11 index.shtml.de
-rw-r--r-- 1 martin 735 May 7 13:11 index.shtml.de-BY
-rw-r--r-- 1 martin 735 May 7 13:09 index.shtml.de-By
-rw-r--r-- 1 martin 339 May 7 13:11 index.shtml.en
-rw-r--r-- 1 martin 295 May 7 13:11 index.shtml.fr
this script....
---snip---
#!/bin/sh
head /etc/httpd.conf
n=0
for lang in th de en fr de-By "th, de-ch" "en;q=0.1, de-by;q=0.2" "en;q=0.6, de-by;q=0.2, de;q=0.5" "en-US;q=0.6, de-by;q=0.2, de;q=0.5" "en-US;q=0.1, de-by;q=0.2, de;q=0.5"
do
for URL in /~martin/neg/ /~martin/neg/index
do
n=`expr 1 + $n`
echo "($n)=== Lang=$lang URL=$URL ==="
netcat localhost 80 <<-. | tr -d '\015' |
HEAD $URL HTTP/1.0
Accept-Language: $lang
Host: localhost
.
(
read proto status message
if [ _$status = _200 ]; then
grep -i language
else
echo "$status $message"
fi
cat
echo ""
)
done
done
---snip---
...produces this output:
<Directory /home/martin/pgtm0035/WWW/neg/>
AllowOverride AuthConfig FileInfo Indexes Limit
Options +MultiViews -Indexes +FollowSymLinks +SymLinksIfOwnerMatch +ExecCGI
DirectoryIndex index
<Limit GET POST>
order deny,allow
allow from all
</Limit>
</Directory>
(1)=== Lang=th URL=/~martin/neg/ ===
(2)=== Lang=th URL=/~martin/neg/index ===
Vary: accept-language
(3)=== Lang=de URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de
(4)=== Lang=de URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: de
(5)=== Lang=en URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: en
(6)=== Lang=en URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: en
(7)=== Lang=fr URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: fr
(8)=== Lang=fr URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: fr
(9)=== Lang=de-By URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de-by
(10)=== Lang=de-By URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: de-by
(11)=== Lang=th, de-ch URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de
(12)=== Lang=th, de-ch URL=/~martin/neg/index ===
Vary: accept-language
(13)=== Lang=en;q=0.1, de-by;q=0.2 URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de-by
(14)=== Lang=en;q=0.1, de-by;q=0.2 URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: de-by
(15)=== Lang=en;q=0.6, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: en
(16)=== Lang=en;q=0.6, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: en
(17)=== Lang=en-US;q=0.6, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de
(18)=== Lang=en-US;q=0.6, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: de
(19)=== Lang=en-US;q=0.1, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/ ===
Vary: accept-language
Content-Language: de
(20)=== Lang=en-US;q=0.1, de-by;q=0.2, de;q=0.5 URL=/~martin/neg/index ===
Vary: accept-language
Content-Language: de
- - - - - -
Now my questions:
In (1),
- why does a request for neg/ (with a "DirectoryIndex index") give
different results from a request for neg/index ?
- Why is there no "Vary: accept-language" header for the
"index.html.shtml" file?
In (12),
- why is there no "Content-Language: de" header, or better:
- why was the "index.html.shtml" file chosen in preferance over
"index.shtml.de"?
In (17) and (18),
- why was the english variant not chosen? It still had a better quality
than the german variant.
When I rename the index.html.shtml to index.shtml.shtml, then the same
test gives a different output:
--- x1 Tue May 26 17:11:32 1998
+++ x2 Tue May 26 17:12:49 1998
@@ -7,13 +7,14 @@
allow from all
</Limit>
</Directory>
-lrwxrwxrwx 1 martin dbx 14 May 26 16:38 index.html.shtml -> index.shtml.en
-rw-r--r-- 1 martin dbx 339 May 7 13:11 index.shtml.de
-rw-r--r-- 1 martin dbx 735 May 7 13:11 index.shtml.de-BY
-rw-r--r-- 1 martin dbx 735 May 7 13:09 index.shtml.de-By
-rw-r--r-- 1 martin dbx 339 May 7 13:11 index.shtml.en
-rw-r--r-- 1 martin dbx 295 May 7 13:11 index.shtml.fr
+lrwxrwxrwx 1 martin dbx 14 May 26 16:38 index.shtml.shtml -> index.shtml.en
(1)=== Lang=th URL=/~martin/neg/ ===
+Vary: accept-language
(2)=== Lang=th URL=/~martin/neg/index ===
Vary: accept-language
@@ -56,6 +57,7 @@
(12)=== Lang=th, de-ch URL=/~martin/neg/index ===
Vary: accept-language
+Content-Language: de
(13)=== Lang=en;q=0.1, de-by;q=0.2 URL=/~martin/neg/ ===
Vary: accept-language
So, in (1) and (12),
- why does index.html.shtml give different output for a .../ request
and a .../index request, while with index.shtml.shtml the two are
identical?
Hmmm... Puzzled,
Martin
--
| S I E M E N S | <Ma...@mch.sni.de> | Siemens Nixdorf
| ------------- | Voice: +49-89-636-46021 | Informationssysteme AG
| N I X D O R F | FAX: +49-89-636-44994 | 81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request
RE: Negotiation - can someone explain?
Posted by Lars Eilebrecht <La...@unix-ag.org>.
According to Martin Kraemer:
> In (1),
> - why does a request for neg/ (with a "DirectoryIndex index") give
> different results from a request for neg/index ?
Probably a bug...
> - Why is there no "Vary: accept-language" header for the
> "index.html.shtml" file?
Why should Apache send a vary header, there is no language token
in the filename...
BTW, why do you use "index.html.shtml" and not just "index.shtml"?
> In (12),
> - why is there no "Content-Language: de" header, or better:
> - why was the "index.html.shtml" file chosen in preferance over
> "index.shtml.de"?
Hmmm... the index.html.shtml thing is more or less a hack
and causes problems if the language token has a prefix. I've
noticed it myself on a setup where I have file.de.html, file.en.html
and file.html -> file.en.html. A request with de-DE returns
file.html instead of file.de.html.
> In (17) and (18),
> - why was the english variant not chosen? It still had a better quality
> than the german variant.
This is IMHO correct, because there is only an en, but no en-US variant
available. RFC 2068 says:
Note: This use of a prefix matching rule does not imply that
language tags are assigned to languages in such a way that it is
always true that if a user understands a language with a certain
tag, then this user will also understand all languages with tags
for which this tag is a prefix. The prefix rule simply allows the
use of prefix tags if this is the case.
ciao...
--
Lars Eilebrecht - Bugs come in through open Windows.
sfx@unix-ag.org
http://www.home.unix-ag.org/sfx/