ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/tcp_http.ext
(Generate patch)

Comparing deliantra/server/ext/tcp_http.ext (file contents):
Revision 1.11 by root, Sun Nov 11 04:29:11 2012 UTC vs.
Revision 1.12 by root, Sun Nov 11 05:53:12 2012 UTC

112 $self->send ("HTTP/1.1 100 go on\015\012") 112 $self->send ("HTTP/1.1 100 go on\015\012")
113 if $req =~ /^expect:.*\b100-continue\b/i; 113 if $req =~ /^expect:.*\b100-continue\b/i;
114 114
115 if ($uri =~ m%^/([0-9a-f]+)(M?)$%) { # faces 115 if ($uri =~ m%^/([0-9a-f]+)(M?)$%) { # faces
116 my $want_meta = $2; 116 my $want_meta = $2;
117 my $idx = $cf::FACEHASH{pack "H*", $1}; 117 my $idx = $cf::face::HASH{pack "H*", $1};
118 118
119 $idx 119 $idx
120 or do { $self->respond ("404 illegal face name"), next }; 120 or do { $self->respond ("404 illegal face name"), next };
121 121
122 if ($req =~ /if-none-match/i) { # dirtiest hack evar 122 if ($req =~ /if-none-match/i) { # dirtiest hack evar
123 $self->respond ("304 not modified", "", $cache_headers); 123 $self->respond ("304 not modified", "", $cache_headers);
124 next; 124 next;
125 } 125 }
126 126
127 my $type = cf::face::get_type $idx, 1; 127 my $type = cf::face::get_type $idx;
128 my $data = cf::face::get_data $idx, 1; 128 my $data = cf::face::get_data $idx;
129 129
130 (my $meta, $data) = unpack "(w/a*)*", $data 130 (my $meta, $data) = unpack "(w/a*)*", $data
131 if $type & 1; 131 if $type & 1;
132 132
133 if ($want_meta) { 133 if ($want_meta) {
140 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers); 140 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers);
141 } 141 }
142 142
143 } elsif (my $idx = (cf::face::find "res/http$uri") || (cf::face::find "res/http${uri}index.html")) { 143 } elsif (my $idx = (cf::face::find "res/http$uri") || (cf::face::find "res/http${uri}index.html")) {
144 # TODO: use etag (shudder) 144 # TODO: use etag (shudder)
145 my $data = cf::face::get_data $idx, 1; 145 my $data = cf::face::get_data $idx;
146 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers); 146 $self->respond ("200 OK", $data, (content_type $data) . $cache_headers);
147 147
148 } elsif (cf::face::find "res/http$uri/index.html") { 148 } elsif (cf::face::find "res/http$uri/index.html") {
149 $self->respond ("302 dirslash", "", "location: $uri/\015\012"); 149 $self->respond ("302 dirslash", "", "location: $uri/\015\012");
150 150
151 } elsif ($uri eq "/debug") { # for debugging 151 } elsif ($uri eq "/debug") { # for debugging
152 my @body = "<html><body>"; 152 my @body = "<html><body>";
153 153
154 for my $type (6, 5, 4, 3, 2, 1, 0) { 154 for my $type (6, 5, 4, 3, 2, 1, 0) {
155 push @body, "<h1>$type</h1>"; 155 push @body, "<h1>$type</h1><table><tr><th>#</th><th>csum</th><th>size</th><th>name</th><th>meta</th></tr>";
156 156
157 for (1 .. cf::face::faces_size - 1) { 157 for (1 .. cf::face::faces_size - 1) {
158 cf::cede_to_tick; 158 cf::cede_to_tick;
159 159
160 next if $type != cf::face::get_type $_; 160 next if $type != cf::face::get_type $_;
161 my $name = cf::face::get_name $_; 161 my $name = cf::face::get_name $_;
162 my $id = unpack "H*", cf::face::get_chksum $_, 1; 162 my $id = unpack "H*", cf::face::get_csum $_, 0;
163 push @body, "$_ <a href='$id'>$name ($id)</a>"; 163 push @body, "<tr><td>$_</td><td>$id</td><td>$cf::face::SIZE[0][$_]</td><td><a href='$id'>$name</a></td>";
164 push @body, " <a href='${id}M'>(meta)</a>" if $type & 1; 164 push @body, "<td><a href='${id}M'>meta</a>" if $type & 1;
165 push @body, "<br>"; 165 push @body, "</tr>";
166 } 166 }
167
168 push @body, "</table>";
167 } 169 }
168 170
169 push @body, "</body></html>"; 171 push @body, "</body></html>";
170 172
171 my $body = join "", @body; 173 my $body = join "", @body;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines