You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Sutton <pa...@ukweb.com> on 1996/10/21 14:53:31 UTC
Multiple Content Languages
HTTP/1.1 allows each resource to have more than one content-language
associated with it. Apache currently handles only a single content
language, so, for example
foo.en.fr.html
would be returned with Content-Language: fr (the fr overrides the en
because extensions are parsed left-to-right).
The patch below updates Apache to support more than one language per
resource. It replaces(*) the request_rec's content_language string
with an array, content_languages. mod_mime.c is updated to push each
language from the filename onto this array, and http_protocol.c writes
out a correct Content-Language response header.
(* for backwards compatibility, r->content_language is still available
to modules. It now records the _first_ language encountered in the
file extensions, since that seemed more logical. The code to output
the Content-Language header ignores this field though, so if any
changes a module makes to r->content_language will be ignored. I'll
update mod_negotiation to handle multiple languages in each variant
soon).
Paul
-
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.61
diff -c -r1.61 http_protocol.c
*** http_protocol.c 1996/10/20 20:45:50 1.61
--- http_protocol.c 1996/10/21 12:16:26
***************
*** 1012,1019 ****
if (r->content_encoding)
bvputs(fd,"Content-Encoding: ", r->content_encoding, "\015\012", NULL);
! if (r->content_language)
! bvputs(fd,"Content-Language: ", r->content_language, "\015\012", NULL);
/* We now worry about this here */
--- 1012,1026 ----
if (r->content_encoding)
bvputs(fd,"Content-Encoding: ", r->content_encoding, "\015\012", NULL);
! if (r->content_languages && r->content_languages->nelts) {
! int i;
! bputs("Content-Langauge: ", fd);
! for (i = 0; i < r->content_languages->nelts; ++i) {
! char *lang = ((char**)(r->content_languages->elts))[i];
! bvputs(fd, i ? ", " : "", lang, NULL);
! }
! bputs("\015\012", fd);
! }
/* We now worry about this here */
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.57
diff -c -r1.57 httpd.h
*** httpd.h 1996/10/20 20:45:52 1.57
--- httpd.h 1996/10/21 12:16:27
***************
*** 451,457 ****
char *handler; /* What we *really* dispatch on */
char *content_encoding;
! char *content_language;
int no_cache;
int no_local_copy;
--- 451,458 ----
char *handler; /* What we *really* dispatch on */
char *content_encoding;
! char *content_language; /* for back-compat. only -- do not use */
! array_header *content_languages;
int no_cache;
int no_local_copy;
Index: mod_mime.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_mime.c,v
retrieving revision 1.12
diff -c -r1.12 mod_mime.c
*** mod_mime.c 1996/10/20 18:03:36 1.12
--- mod_mime.c 1996/10/21 12:16:27
***************
*** 250,256 ****
/* Check for Content-Language */
if ((type = table_get (conf->language_types, ext))) {
! r->content_language = type;
found = 1;
}
--- 250,263 ----
/* Check for Content-Language */
if ((type = table_get (conf->language_types, ext))) {
! char **new;
!
! if (!r->content_language)
! r->content_language = type; /* back compat. only */
! if (!r->content_languages)
! r->content_languages = make_array (r->pool, 2, sizeof(char*));
! new = (char **)push_array (r->content_languages);
! *new = type;
found = 1;
}
***************
*** 278,283 ****
--- 285,291 ----
if (!found) {
r->content_type = NULL;
r->content_language = NULL;
+ r->content_languages = NULL;
r->content_encoding = NULL;
r->handler = orighandler;
}
Re: Multiple Content Languages
Posted by Brian Behlendorf <br...@organic.com>.
I +1 this; I think there's sufficient votes now for Paul to commit it.
Brian
On Mon, 21 Oct 1996, Paul Sutton wrote:
> HTTP/1.1 allows each resource to have more than one content-language
> associated with it. Apache currently handles only a single content
> language, so, for example
>
> foo.en.fr.html
>
> would be returned with Content-Language: fr (the fr overrides the en
> because extensions are parsed left-to-right).
>
> The patch below updates Apache to support more than one language per
> resource. It replaces(*) the request_rec's content_language string
> with an array, content_languages. mod_mime.c is updated to push each
> language from the filename onto this array, and http_protocol.c writes
> out a correct Content-Language response header.
>
> (* for backwards compatibility, r->content_language is still available
> to modules. It now records the _first_ language encountered in the
> file extensions, since that seemed more logical. The code to output
> the Content-Language header ignores this field though, so if any
> changes a module makes to r->content_language will be ignored. I'll
> update mod_negotiation to handle multiple languages in each variant
> soon).
>
> Paul
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com www.apache.org hyperreal.com http://www.organic.com/JOBS