primary-type/secondary-type
such as
"text/plain" of "img/gif"
Content-type: text/plain; charset=us-ascii (Plain text)
Content-type: text/plain; charset="us-ascii"
encoding := "Content-Transfer-Encoding" ":" mechanism
mechanism := "7bit" / "8bit" / "binary" /
"quoted-printable" / "base64" /
ietf-token / x-token
Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: base64
Accept-Charset
Accept-Charset: iso-8859-5, unicode-1-1;q=0.8
Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0
Accept-Language: da, en-gb;q=0.8, en;q=0.7
A document returned from a server to a client can use the following tags to indicate language etc
HTTP/1.1 200 OK
Content-Type: text/html; charset=EUC-JP
Content-Encoding: identity
Content-Language: en-US
From the HTTP 1.1 specification:
From the HTTP 1.1 specification:
From the HTTP 1.1 specification:
http://.../foo.var
may contain
URI: foo
URI: foo.en.html
Content-type: text/html
Content-language: en
URI: foo.fr.de.html
Content-type: text/html;charset=iso-8859-2
Content-language: fr, de
foo.en.html
if the language is set to
English, but foo.fr.de.html
if it is set to either French or German
httpd.conf
file to contain
AddHandler type-map var
to use the file extension .var
as a type-map
.var
file as well
MultiViews
property
foo
and this doesn't exist, then the possibilities based by adding language, html etc
are tried
DocumentRoot
on jan.newmarch.name
is set to
/home/httpd/html/
.
The directory /home/httpd/html/i18n/httpd/multiviews
is marked
as MultiViews
. It contains
foo.en.html
foo.fr.html
A request for http://jan.newmarch.name/i18n/httpd/multiviews/foo
returns foo.en.html
if the language is set to English
httpd.conf
directives such as
<Directory "/home/httpd/html/i18n/httpd/multiviews">
Options MultiViews
</Directory>
.htaccess
file in the directory containing
options MultiViews
Set the directive in httpd.conf
AllowOverride All
for the DocumentRoot
directory
.../english/...
.../chinese/...
<a href=".../english/index.html"><img src="english.png"></a>
See http://www.ietf.org/rfc/rfc3987.txt
telnet
to issue
HTTP requests to a server e.g.
telnet jan.newmarch.name 80
HEAD / HTTP/1.0
// several blank lines
HTTP/1.0 200 OK
Date: Tue, 03 May 2005 12:09:15 GMT
Server: Apache/2.0.49 (Fedora)
Accept-Ranges: bytes
Content-Type: text/html
Connection: close
127.0.0.1 - - [02/May/2005:17:36:02 +1000] "GET /i18n/httpd/httpd.html HTTP/1.1" 200 11005 "http://l
ocalhost/i18n/httpd/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.
1"
127.0.0.1 - - [02/May/2005:17:36:03 +1000] "GET /i18n/stylesheet.css HTTP/1.1" 200 511 "http://local
host/i18n/httpd/httpd.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefo
x/1.0.1"
127.0.0.1 - - [02/May/2005:17:36:03 +1000] "GET /favicon.ico HTTP/1.1" 404 286 "-" "Mozilla/5.0 (X11
; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1"
127.0.0.1 - - [02/May/2005:17:36:13 +1000] "GET /favicon.ico HTTP/1.1" 404 286 "-" "Mozilla/5.0 (X11
; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1"
127.0.0.1 - - [02/May/2005:20:52:42 +1000] "GET / HTTP/1.1" 200 2000 "-" "Mozilla/5.0 (X11; U; Linux
i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1"
test-cgi
. On my system
a request from Firefox to this gives
SERVER_SOFTWARE = Apache/2.0.49 (Fedora)
SERVER_NAME = jan.newmarch.name
GATEWAY_INTERFACE = CGI/1.1
SERVER_PROTOCOL = HTTP/1.0
SERVER_PORT = 80
REQUEST_METHOD = GET
HTTP_ACCEPT = text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
SCRIPT_NAME = /cgi-bin/test-cgi
QUERY_STRING =
REMOTE_HOST =
REMOTE_ADDR = 202.7.176.132
REMOTE_USER =
AUTH_TYPE =
CONTENT_TYPE =
CONTENT_LENGTH =
GATEWAY_INTERFACE=CGI/1.1
HOSTNAME=jan.newmarch.name
HTTP_ACCEPT='text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET='ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING=gzip,deflate
HTTP_ACCEPT_LANGUAGE='fr,en-us;q=0.7,en;q=0.3'
HTTP_CACHE_CONTROL=max-age=259200
HTTP_CONNECTION=keep-alive
HTTP_HOST=jan.newmarch.name
HTTP_USER_AGENT='Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1'
HTTP_VIA='1.1 nme-pow-pr3.tpgi.com.au:3128 (squid/2.5.STABLE7)'
HTTP_X_FORWARDED_FOR=60.240.156.157
REMOTE_ADDR=202.7.176.132
REMOTE_PORT=61898
REQUEST_METHOD=GET
REQUEST_URI=/cgi-bin/test-cgi
SCRIPT_FILENAME=/home/httpd/cgi-bin/test-cgi
SCRIPT_NAME=/cgi-bin/test-cgi
SERVER_ADDR=130.194.57.75
SERVER_ADMIN=root@localhost
SERVER_NAME=jan.newmarch.name
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.0
SERVER_SIGNATURE='Apache/2.0.49 (Fedora) Server at jan.newmarch.name Port 80
'
SERVER_SOFTWARE='Apache/2.0.49 (Fedora)'
import java.net.*;
import java.io.*;
public class EchoServer {
final static protected int PORT = 8001;
public static void main(String[] argv) {
try {
new EchoServer();
} catch(IOException e) {
e.printStackTrace();
}
}
public EchoServer() throws IOException {
ServerSocket server = new ServerSocket(PORT);
Socket socket = server.accept();
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();
DataOutputStream out = new DataOutputStream(os);
BufferedReader in = new BufferedReader(new InputStreamReader(is));
out.writeBytes("HTTP/1.1 404 OK\n");
out.writeBytes("Content-Type: text/plain\n\n");
String line;
line = in.readLine();
// check that line is GET url HTTP/1.0
// \extract url
// find the file for that url
// open the file
// write it to the out stream
while ((line = in.readLine()) != null &&
(line.length() != 0)) {
out.writeBytes(line + "\n");
}
out.close();
socket.close();
}
}
http://localhost:8001/
displays back in the browser as
GET / HTTP/1.1
Host: localhost:8001
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: fr,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive