Assume "image/svg+xml" support for Firefox-1.5.
[MyWeb.git] / svg-gecko-force.patch
1 Index: Web.pm
2 ===================================================================
3 RCS file: /home/short/pserver/cvs/MyWeb/Web.pm,v
4 retrieving revision 1.15
5 diff -u -p -r1.15 Web.pm
6 --- Web.pm      10 Nov 2005 06:39:24 -0000      1.15
7 +++ Web.pm      5 Dec 2005 13:51:46 -0000
8 @@ -204,11 +204,44 @@ my($class,%args)=@_;
9  
10         $W->{"headers_in"}=$W->{"r"}->headers_in();
11         Wrequire 'My::Hash::Merge';
12 +       my $headers_in_orig=$W->{"headers_in"};
13         $W->{"headers_in"}=My::Hash::Merge->new(
14 -                       $W->{"headers_in"},
15 +                       # Proper ordering - "Accept" is overriding!
16                         My::Hash::Sub->new({
17                                 "_remote_ip"=>sub { return $W->{"r"}->connection()->remote_ip(); },
18 +                               "Accept"=>sub {
19 +                                       return our $r||=do {
20 +                                               my $accept_string=$headers_in_orig->{"Accept"};
21 +                                               if ($accept_string && (my $gecko_version=$W->{"browser"}->gecko_version())) {
22 +                                                       # Since Gecko "rv:1.8", that means since Firefox-1.5.
23 +                                                       if ("001-008" le join("-",map((sprintf("%03d",$_)),split(/[.]/,$gecko_version)))) {
24 +                                                               my $http_headers=HTTP::Headers->new($accept_string);
25 +                                                               my $format=HTTP::Negotiate::choose([
26 +                                                                       [
27 +                                                                               "image/catch-missing-svg-type",  # ID
28 +                                                                               0.9,  # QS
29 +                                                                               "image/catch-missing-svg-type",  # Content-Type
30 +                                                                               ],
31 +                                                                       [
32 +                                                                               "image/svg+xml",  # ID
33 +                                                                               0.8,  # QS
34 +                                                                               "image/svg+xml",  # Content-Type
35 +                                                                               ],
36 +                                                                       ],$http_headers);
37 +                                                               if ($format && $format eq "image/catch-missing-svg-type") {
38 +                                                                       # Image requests: "image/png,*/*;q=0.5"
39 +                                                                       # and thus "image/png" is assigned the same priority.
40 +                                                                       # FIXME: RFC 2068 (HTTP/1.1) does not specify the behavior!
41 +                                                                       #        HTTP::Negotiate fortunately follows the ordering preferences.
42 +                                                                       $accept_string="image/svg+xml,".$accept_string;
43 +                                                                       }
44 +                                                               }
45 +                                                       }
46 +                                               $accept_string;
47 +                                               };
48 +                                       },
49                                 }),
50 +                       $W->{"headers_in"},
51                         );
52         Wrequire 'My::Hash::Readonly';
53         $W->{"headers_in"}=My::Hash::Readonly->new($W->{"headers_in"});
54 Index: Hash/Merge.pm
55 ===================================================================
56 RCS file: /home/short/pserver/cvs/MyWeb/Hash/Merge.pm,v
57 retrieving revision 1.1
58 diff -u -p -r1.1 Merge.pm
59 --- Hash/Merge.pm       18 Sep 2005 06:43:14 -0000      1.1
60 +++ Hash/Merge.pm       5 Dec 2005 13:51:46 -0000
61 @@ -40,19 +40,16 @@ my($class,@parents)=@_;
62         return $self;
63  }
64  
65 +# Multiplicity is permitted, first one is chosen.
66  sub key_find($$)
67  {
68  my($self,$key)=@_;
69  
70 -       my $count=0;
71         my $first;
72         for my $parent (@{$self->{"parents"}}) {
73                 next if !exists $parent->{$key};
74 -               $count++;
75                 $first||=$parent;
76                 }
77 -       # 0 IS allowed here.
78 -       cluck "Duplicity ($count-icity) for key: $key" if $count>=2;
79         $first||=$self->{"parents"}[0];
80         return $first;
81  }