Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 897 lines (751 sloc) 21.63 kB
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20b @alobbs Happy new year!
alobbs authored
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c39092 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-9…
alobbs authored
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
23 */
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
24
25 #include "common-internal.h"
26
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <time.h>
32
33 #include "server.h"
34 #include "server-protected.h"
3dcb4dd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@495 5dc97367-97…
alobbs authored
35 #include "dtm.h"
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
36 #include "mime.h"
37 #include "header.h"
38 #include "header-protected.h"
39 #include "handler_file.h"
40 #include "connection.h"
41 #include "connection-protected.h"
42 #include "module.h"
43 #include "iocache.h"
44 #include "util.h"
6440a71 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1269 5dc97367-9…
alobbs authored
45 #include "handler_dirlist.h"
4d387f4 @alobbs This patch changes substantially the way in which errors and warnings
alobbs authored
46 #include "error_log.h"
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
47
6d2aa7a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@433 5dc97367-97…
alobbs authored
48 #define ENTRIES "handler,file"
49
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
50
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97…
alobbs authored
51 /* Plug-in initialization
52 */
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
53 PLUGIN_INFO_HANDLER_EASIEST_INIT (file, http_get | http_head | http_options);
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97…
alobbs authored
54
55
56 /* Methods implementation
57 */
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
58 ret_t
be04810 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@283 5dc97367-97…
alobbs authored
59 cherokee_handler_file_props_free (cherokee_handler_file_props_t *props)
60 {
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97…
alobbs authored
61 return cherokee_handler_props_free_base (HANDLER_PROPS(props));
be04810 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@283 5dc97367-97…
alobbs authored
62 }
63
64
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
65 ret_t
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
66 cherokee_handler_file_configure (cherokee_config_node_t *conf,
67 cherokee_server_t *srv,
68 cherokee_module_props_t **_props)
b6c69ad @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@269 5dc97367-97…
alobbs authored
69 {
2459250 @alobbs Replace atoi() calls by either cherokee_atoi() or cherokee_atob().
alobbs authored
70 ret_t ret;
ee8023f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@384 5dc97367-97…
alobbs authored
71 cherokee_list_t *i;
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
72 cherokee_handler_file_props_t *props;
73
651edbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
alobbs authored
74 UNUSED(srv);
75
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
76 if (*_props == NULL) {
77 CHEROKEE_NEW_STRUCT (n, handler_file_props);
78
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
79 cherokee_handler_props_init_base (HANDLER_PROPS(n),
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97…
alobbs authored
80 MODULE_PROPS_FREE(cherokee_handler_file_props_free));
be04810 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@283 5dc97367-97…
alobbs authored
81
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
82 n->use_cache = true;
7b0e48a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@387 5dc97367-97…
alobbs authored
83 *_props = MODULE_PROPS(n);
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
84 }
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
85
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
86 props = PROP_FILE(*_props);
87
88 cherokee_config_node_foreach (i, conf) {
89 cherokee_config_node_t *subconf = CONFIG_NODE(i);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
90
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
91 if (equal_buf_str (&subconf->key, "iocache")) {
2459250 @alobbs Replace atoi() calls by either cherokee_atoi() or cherokee_atob().
alobbs authored
92 ret = cherokee_atob (subconf->val.buf, &props->use_cache);
93 if (ret != ret_ok) return ret;
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
94 }
95 }
96
b6c69ad @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@269 5dc97367-97…
alobbs authored
97 return ret_ok;
98 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
99
3509796 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@282 5dc97367-97…
alobbs authored
100
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
101 ret_t
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
102 cherokee_handler_file_new (cherokee_handler_t **hdl,
103 cherokee_connection_t *cnt,
104 cherokee_module_props_t *props)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
105 {
106 CHEROKEE_NEW_STRUCT (n, handler_file);
7a3e417 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1611 5dc97367-9…
alobbs authored
107
108 TRACE_CONN(cnt);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
109
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
110 /* Init the base class object
111 */
b69d2e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@476 5dc97367-97…
alobbs authored
112 cherokee_handler_init_base (HANDLER(n), cnt, HANDLER_PROPS(props), PLUGIN_INFO_HANDLER_PTR(file));
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
113
114 MODULE(n)->free = (module_func_free_t) cherokee_handler_file_free;
115 MODULE(n)->init = (handler_func_init_t) cherokee_handler_file_init;
116 HANDLER(n)->step = (handler_func_step_t) cherokee_handler_file_step;
117 HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_file_add_headers;
118
119 /* Supported features
120 */
c6dc1b3 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@2647 5dc97367-9…
skarcha authored
121 HANDLER(n)->support = hsupport_range;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
122
123 /* Init
124 */
125 n->fd = -1;
126 n->offset = 0;
127 n->mime = NULL;
128 n->info = NULL;
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
129 n->using_sendfile = false;
130 n->not_modified = false;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
131
132 /* Return the object
133 */
134 *hdl = HANDLER(n);
135 return ret_ok;
136 }
137
138
139 ret_t
140 cherokee_handler_file_free (cherokee_handler_file_t *fhdl)
141 {
142 if (fhdl->fd != -1) {
9a6e161 @alobbs Safer fd closing
alobbs authored
143 cherokee_fd_close (fhdl->fd);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
144 fhdl->fd = -1;
145 }
146
147 return ret_ok;
148 }
149
150
151 static ret_t
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
152 check_cached (cherokee_handler_file_t *fhdl)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
153 {
154 ret_t ret;
155 char *header;
156 cuint_t header_len;
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
157 cherokee_boolean_t has_modified_since = false;
158 cherokee_boolean_t has_etag = false;
159 cherokee_boolean_t not_modified_ms = false;
160 cherokee_boolean_t not_modified_etag = false;
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
161 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
24e214a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@551 5dc97367-97…
alobbs authored
162 cherokee_thread_t *thread = HANDLER_THREAD(fhdl);
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
163 cherokee_buffer_t *etag_local = THREAD_TMP_BUF1(thread);
164
165 cherokee_buffer_clean (etag_local);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
166
167 /* Based in time
168 */
169 ret = cherokee_header_get_known (&conn->header, header_if_modified_since, &header, &header_len);
170 if (ret == ret_ok) {
171 char tmp;
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
172 time_t req_time = 0;
173 char *end = header + header_len;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
174
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
175 has_modified_since = true;
176
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
177 /* Set EOL
178 */
179 tmp = *end;
180 *end = '\0';
181
182 /* Parse the Date string
183 */
ff9a881 @alobbs This patch adds support for an additional, but invalid, data format:
alobbs authored
184 ret = cherokee_dtm_str2time (header, header_len, &req_time);
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
185 if (unlikely (ret == ret_error)) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
186 LOG_WARNING (CHEROKEE_ERROR_HANDLER_FILE_TIME_PARSE, header);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
187
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
188 } else if (likely (ret == ret_ok)) {
189 /* The file is cached in the client
190 */
191 if (fhdl->info->st_mtime <= req_time) {
192 not_modified_ms = true;
193 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
194 }
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
195
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
196 /* Restore EOL
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
197 */
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
198 *end = tmp;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
199 }
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
200
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
201 /* HTTP/1.1 only headers from now on
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
202 */
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
203 if (conn->header.version < http_version_11) {
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
204 fhdl->not_modified = not_modified_ms;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
205 return ret_ok;
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
206 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
207
208 /* Based in ETag
209 */
210 ret = cherokee_header_get_known (&conn->header, header_if_none_match, &header, &header_len);
211 if (ret == ret_ok) {
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
212 /* Build local ETag
24e214a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@551 5dc97367-97…
alobbs authored
213 */
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
214 if (cherokee_buffer_is_empty (etag_local)) {
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
215 cherokee_buffer_add_char (etag_local, '"');
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
216 cherokee_buffer_add_ullong16 (etag_local, (cullong_t) fhdl->info->st_mtime);
217 cherokee_buffer_add_str (etag_local, "=");
218 cherokee_buffer_add_ullong16 (etag_local, (cullong_t) fhdl->info->st_size);
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
219 cherokee_buffer_add_char (etag_local, '"');
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
220 }
050676e @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@348 5dc97367-97…
alobbs authored
221
24e214a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@551 5dc97367-97…
alobbs authored
222 /* Compare ETag(s)
223 */
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
224 if ((header_len == etag_local->len) &&
225 (strncmp (header, etag_local->buf, etag_local->len) == 0))
24e214a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@551 5dc97367-97…
alobbs authored
226 {
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
227 not_modified_etag = true;
228 }
24e214a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@551 5dc97367-97…
alobbs authored
229
230 has_etag = true;
ab10533 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@371 5dc97367-97…
alobbs authored
231 }
232
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
233 /* If-Range
234 */
235 ret = cherokee_header_get_known (&conn->header, header_if_range, &header, &header_len);
236 if (ret == ret_ok) {
237 char tmp;
238 char *end = header + header_len;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
239
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
240 /* Set EOL
241 */
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
242 tmp = *end;
243 *end = '\0';
244
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
245 /* If-Range: "<Etag>"
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
246 */
247 if (strchr (header, '=')) {
248 /* Build local ETag if needed
249 */
250 if (cherokee_buffer_is_empty (etag_local)) {
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
251 cherokee_buffer_add_char (etag_local, '"');
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
252 cherokee_buffer_add_ullong16 (etag_local, (cullong_t) fhdl->info->st_mtime);
253 cherokee_buffer_add_str (etag_local, "=");
254 cherokee_buffer_add_ullong16 (etag_local, (cullong_t) fhdl->info->st_size);
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
255 cherokee_buffer_add_char (etag_local, '"');
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
256 }
257
258 /* Compare ETags
259 */
260 if ((header_len == etag_local->len) &&
261 (strncmp (header, etag_local->buf, etag_local->len) == 0))
262 {
263 not_modified_etag = true;
264 }
265
266 has_etag = true;
267 }
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
268
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
269 /* "If-Range: Sun, 14 Nov 2010 17:17:13 GMT"
270 */
271 else {
272 time_t req_time = 0;
273
ff9a881 @alobbs This patch adds support for an additional, but invalid, data format:
alobbs authored
274 ret = cherokee_dtm_str2time (header, header_len, &req_time);
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
275 if (unlikely (ret == ret_error)) {
276 LOG_WARNING (CHEROKEE_ERROR_HANDLER_FILE_TIME_PARSE, header);
277
278 } else if (likely (ret == ret_ok)) {
279 /* If the entity tag given in the If-Range
280 * header matches the current entity tag for
281 * the entity, then the server SHOULD provide
282 * the specified sub-range of the entity using
283 * a 206 (Partial content) response. If the
284 * entity tag does not match, then the server
285 * SHOULD return the entire entity using a 200
286 * (OK) response.
287 */
288 if (fhdl->info->st_mtime > req_time) {
289 conn->error_code = http_ok;
290
291 conn->range_start = -1;
292 conn->range_end = -1;
293 }
294 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
295 }
296
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
297 /* Restore EOL
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
298 */
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
299 *end = tmp;
300 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
301
147d8af @alobbs Tries to address a couple of problems related to the parsing of the
alobbs authored
302 /* If both If-Modified-Since and ETag have been found then
303 * both must match in order to return a not_modified response.
304 */
305 if (has_modified_since && has_etag) {
306 if (not_modified_ms && not_modified_etag) {
307 fhdl->not_modified = true;
308 return ret_ok;
309 }
310 } else {
311 if (not_modified_ms || not_modified_etag) {
312 fhdl->not_modified = true;
313 return ret_ok;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
314 }
315 }
316
317 return ret_ok;
318 }
319
320
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
321 static ret_t
322 open_local_directory (cherokee_handler_file_t *fhdl, cherokee_buffer_t *local_file)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
323 {
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
324 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
325
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
326 /* Check if it is already open
327 */
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
328 if (fhdl->fd > 0)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
329 return ret_ok;
330
331 /* Open it
332 */
a68f41b @alobbs Merges the Front-Line Cache branch.
alobbs authored
333 fhdl->fd = cherokee_open (local_file->buf, O_RDONLY | O_BINARY, 0);
a017626 @alobbs Set a few more close-on-exec flags.
alobbs authored
334 if (fhdl->fd > 0) {
335 cherokee_fd_set_closexec (fhdl->fd);
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
336 return ret_ok;
a017626 @alobbs Set a few more close-on-exec flags.
alobbs authored
337 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
338
339 /* Manage errors
340 */
341 switch (errno) {
342 case EACCES:
343 conn->error_code = http_access_denied;
344 break;
345 case ENOENT:
346 conn->error_code = http_not_found;
347 break;
348 default:
349 conn->error_code = http_internal_error;
350 }
351 return ret_error;
352 }
353
354
355 static ret_t
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
356 stat_local_directory (cherokee_handler_file_t *fhdl,
357 cherokee_buffer_t *local_file,
358 cherokee_iocache_entry_t **io_entry,
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
359 struct stat **info)
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
360 {
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
361 int re;
362 ret_t ret;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
363 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
364 cherokee_server_t *srv = CONN_SRV(conn);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
365
366 /* I/O cache
367 */
0044f1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2122 5dc97367-9…
alobbs authored
368 if ((srv->iocache != NULL) &&
369 (HDL_FILE_PROP(fhdl)->use_cache))
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
370 {
371 ret = cherokee_iocache_autoget (srv->iocache, local_file, iocache_stat, io_entry);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
372 TRACE (ENTRIES, "%s, use_iocache=1 ret=%d\n", local_file->buf, ret);
281d8e6 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@834 5dc97367-97…
alobbs authored
373
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
374 switch (ret) {
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
375 case ret_ok:
c19da29 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1676 5dc97367-9…
alobbs authored
376 case ret_ok_and_sent:
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
377 *info = &(*io_entry)->state;
33c9d33 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2661 5dc97367-9…
alobbs authored
378 return (*io_entry)->state_ret;
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
379
380 case ret_no_sys:
381 goto without;
382
c19da29 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1676 5dc97367-9…
alobbs authored
383 case ret_deny:
384 conn->error_code = http_access_denied;
385 break;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
386 case ret_not_found:
387 conn->error_code = http_not_found;
388 break;
389 default:
b45b836 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2101 5dc97367-9…
alobbs authored
390 RET_UNKNOWN(ret);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
391 conn->error_code = http_internal_error;
392 }
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
393
394 return ret_error;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
395 }
396
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
397 /* Without cache
398 */
399 without:
147fcf8 @alobbs {l,f,}stat() related fix. Ensure the EINTR signal is handler
alobbs authored
400 re = cherokee_stat (local_file->buf, &fhdl->cache_info);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
401 TRACE (ENTRIES, "%s, use_iocache=0 ret=%d\n", local_file->buf, re);
281d8e6 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@834 5dc97367-97…
alobbs authored
402
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
403 if (re >= 0) {
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
404 *info = &fhdl->cache_info;
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
405 return ret_ok;
406 }
407
408 switch (errno) {
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
409 case ENOENT:
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
410 conn->error_code = http_not_found;
411 break;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
412 case EACCES:
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
413 conn->error_code = http_access_denied;
414 break;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
415 default:
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
416 conn->error_code = http_internal_error;
417 }
418
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
419 return ret_error;
420 }
421
422
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
423 ret_t
870c0a6 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3166 5dc97367-9…
alobbs authored
424 cherokee_handler_file_custom_init (cherokee_handler_file_t *fhdl,
425 cherokee_buffer_t *local_file)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
426 {
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
427 ret_t ret;
337832a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1375 5dc97367-9…
alobbs authored
428 char *ext;
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
429 cherokee_iocache_entry_t *io_entry = NULL;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
430 cherokee_boolean_t use_io = false;
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
431 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
432 cherokee_server_t *srv = HANDLER_SRV(fhdl);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
433
434 /* Query the I/O cache
435 */
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
436 ret = stat_local_directory (fhdl, local_file, &io_entry, &fhdl->info);
eb98dbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1674 5dc97367-9…
alobbs authored
437 switch (ret) {
438 case ret_ok:
439 break;
440 case ret_not_found:
441 conn->error_code = http_not_found;
442 ret = ret_error;
443 goto out;
444 default:
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
445 goto out;
eb98dbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1674 5dc97367-9…
alobbs authored
446 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
447
448 /* Ensure it is a file
449 */
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
450 if (S_ISDIR(fhdl->info->st_mode)) {
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
451 conn->error_code = http_access_denied;
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
452 ret = ret_error;
453 goto out;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
454 }
455
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
456 /* Look for the mime type
457 */
458 if (srv->mime != NULL) {
870c0a6 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3166 5dc97367-9…
alobbs authored
459 ext = (local_file->buf + local_file->len) - 1;
460 while (ext > local_file->buf) {
1e011ca @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2721 5dc97367-9…
alobbs authored
461 if (*ext == '.') {
462 ret = cherokee_mime_get_by_suffix (srv->mime, ext+1, &fhdl->mime);
463 if (ret == ret_ok)
464 break;
465 }
466 ext--;
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
467 }
468 }
469
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
470 /* Is it cached on the client?
471 */
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
472 ret = check_cached (fhdl);
e77c518 @alobbs Wrong data was being logged for 416 responses. Thanks a million to
alobbs authored
473 if ((ret != ret_ok) || (fhdl->not_modified)) {
474 /* Set both ranges to zero to avoid file size errors in loggers
475 */
476 conn->range_start = 0;
477 conn->range_end = 0;
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
478 goto out;
e77c518 @alobbs Wrong data was being logged for 416 responses. Thanks a million to
alobbs authored
479 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
480
481 /* Is this file cached in the io cache?
482 */
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
483 use_io = ((srv->iocache != NULL) &&
07733fb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3016 5dc97367-9…
alobbs authored
484 (conn->encoder_new_func == NULL) &&
281d8e6 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@834 5dc97367-97…
alobbs authored
485 (HDL_FILE_PROP(fhdl)->use_cache) &&
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
486 (conn->socket.is_tls == non_TLS) &&
d7c81af @alobbs Expiration headers returned by Front-Line Cache can now be overwritten.
alobbs authored
487 (conn->flcache.mode == flcache_mode_undef) &&
d8bf318 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2188 5dc97367-9…
alobbs authored
488 (http_method_with_body (conn->header.method)) &&
489 (fhdl->info->st_size <= srv->iocache->max_file_size) &&
490 (fhdl->info->st_size >= srv->iocache->min_file_size));
6d2aa7a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@433 5dc97367-97…
alobbs authored
491
492 TRACE(ENTRIES, "Using iocache %d\n", use_io);
10dd99b @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1680 5dc97367-9…
alobbs authored
493
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
494 if (use_io) {
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
495 ret = cherokee_iocache_autoget_fd (srv->iocache,
496 local_file,
497 iocache_mmap,
498 &fhdl->fd,
499 &io_entry);
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
500
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
501 TRACE (ENTRIES, "iocache looked up, local=%s ret=%d\n",
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
502 local_file->buf, ret);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
503
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
504 switch (ret) {
505 case ret_ok:
c19da29 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1676 5dc97367-9…
alobbs authored
506 case ret_ok_and_sent:
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
507 break;
508 case ret_no_sys:
509 use_io = false;
510 break;
c19da29 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1676 5dc97367-9…
alobbs authored
511 case ret_deny:
512 conn->error_code = http_access_denied;
513 ret = ret_error;
514 goto out;
eb98dbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1674 5dc97367-9…
alobbs authored
515 case ret_not_found:
516 conn->error_code = http_not_found;
517 ret = ret_error;
518 goto out;
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
519 default:
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
520 goto out;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
521 }
10dd99b @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1680 5dc97367-9…
alobbs authored
522
523 /* Ensure the mmap content is ready
524 */
525 if (io_entry->mmaped == NULL)
526 use_io = false;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
527 }
528
529 /* Maybe open the file
530 */
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
531 if (! use_io) {
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
532 ret = open_local_directory (fhdl, local_file);
e12c277 @alobbs Partial transfers with a valid start range and an invalid end range
alobbs authored
533 if (ret != ret_ok) {
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
534 goto out;
e12c277 @alobbs Partial transfers with a valid start range and an invalid end range
alobbs authored
535 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
536 }
537
538 /* Is it a directory?
539 */
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
540 if (S_ISDIR (fhdl->info->st_mode)) {
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
541 conn->error_code = http_access_denied;
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
542 ret = ret_error;
543 goto out;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
544 }
545
546 /* Range 1: Check the range and file size
547 */
0566603 @alobbs If a "Range: bytes=" exceeds the file size, the reply had to a '206
alobbs authored
548 if (unlikely (conn->range_start >= fhdl->info->st_size))
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
549 {
dca6e83 @alobbs Fixes a problem handling partial requests (Content-Range). Thank to
alobbs authored
550 /* Sets the range limits, so the error handler can
551 * report the error properly.
552 */
553 conn->range_start = 0;
554 conn->range_end = fhdl->info->st_size;
555 conn->error_code = http_range_not_satisfiable;
e96b721 @alobbs Covers a second scenario of the bug #754. Again, thanks to Juan
alobbs authored
556
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
557 ret = ret_error;
558 goto out;
0566603 @alobbs If a "Range: bytes=" exceeds the file size, the reply had to a '206
alobbs authored
559 }
560
561 if (unlikely ((conn->range_end >= fhdl->info->st_size)))
562 {
e12c277 @alobbs Partial transfers with a valid start range and an invalid end range
alobbs authored
563 /* Range-end out of bounds. Set it to -1 so it is
564 * updated with the file size later on.
0566603 @alobbs If a "Range: bytes=" exceeds the file size, the reply had to a '206
alobbs authored
565 */
e12c277 @alobbs Partial transfers with a valid start range and an invalid end range
alobbs authored
566 conn->range_end = -1;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
567 }
568
569 /* Set the error code
570 */
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
571 if ((conn->range_start > -1) ||
572 (conn->range_end > -1))
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
573 {
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
574 conn->error_code = http_partial_content;
575 }
576
577 /* Range 2: Set the file length as the range end
578 */
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
579 if (conn->range_end == -1) {
580 if (conn->range_start == -1) {
581 conn->range_start = 0;
582 }
583 conn->range_end = fhdl->info->st_size - 1;
584 } else {
585 if (conn->range_start == -1) {
586 conn->range_start = fhdl->info->st_size - conn->range_end;
587 conn->range_end = fhdl->info->st_size - 1;
588 }
4a2a6be @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@419 5dc97367-97…
alobbs authored
589 }
981205c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@408 5dc97367-97…
alobbs authored
590
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
591 /* Set mmap or file position
592 */
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
593 if ((use_io) &&
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
594 (io_entry != NULL) &&
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
595 (io_entry->mmaped != NULL))
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
596 {
597 off_t len;
598
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
599 /* Set the mmap info
600 */
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
601 conn->io_entry_ref = io_entry;
602
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
603 len = conn->range_end - conn->range_start + 1;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
604
1e47304 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2701 5dc97367-9…
alobbs authored
605 conn->mmaped = ((char *)io_entry->mmaped) + conn->range_start;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
606 conn->mmaped_len = len;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
607 } else {
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
608 /* Does no longer care about the io_entry
609 */
610 cherokee_iocache_entry_unref (&io_entry);
611
981205c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@408 5dc97367-97…
alobbs authored
612 /* Seek the file if needed
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
613 */
614 if ((conn->range_start != 0) && (conn->mmaped == NULL)) {
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
615 fhdl->offset = conn->range_start;
616 lseek (fhdl->fd, fhdl->offset, SEEK_SET);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
617 }
618 }
619
620 /* Maybe use sendfile
621 */
981205c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@408 5dc97367-97…
alobbs authored
622 #ifdef WITH_SENDFILE
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
623 fhdl->using_sendfile = ((conn->mmaped == NULL) &&
624 (conn->encoder == NULL) &&
841e381 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3050 5dc97367-9…
alobbs authored
625 (conn->encoder_new_func == NULL) &&
626 (conn->socket.is_tls == non_TLS) &&
d7c81af @alobbs Expiration headers returned by Front-Line Cache can now be overwritten.
alobbs authored
627 (conn->flcache.mode == flcache_mode_undef) &&
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
628 (fhdl->info->st_size >= srv->sendfile.min) &&
841e381 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3050 5dc97367-9…
alobbs authored
629 (fhdl->info->st_size < srv->sendfile.max));
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
630
fc3cae0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@376 5dc97367-97…
alobbs authored
631 if (fhdl->using_sendfile) {
960fc3e fix cherokee_connection_set_cork()
ADF authored
632 cherokee_connection_set_cork (conn, true);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
633 BIT_SET (conn->options, conn_op_tcp_cork);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
634 }
635 #endif
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
636
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
637 return ret_ok;
9a294ab @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1673 5dc97367-9…
alobbs authored
638
639 out:
640 cherokee_iocache_entry_unref (&io_entry);
641 return ret;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
642 }
643
644
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
645 ret_t
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
646 cherokee_handler_file_init (cherokee_handler_file_t *fhdl)
647 {
648 ret_t ret;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
649 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
650
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
651 /* OPTIONS request
652 */
653 if (unlikely (HANDLER_CONN(fhdl)->header.method == http_options)) {
654 return ret_ok;
655 }
656
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
657 /* Build the local file path
658 */
7a3e417 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1611 5dc97367-9…
alobbs authored
659 cherokee_buffer_add_buffer (&conn->local_directory, &conn->request);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
660 ret = cherokee_handler_file_custom_init (fhdl, &conn->local_directory);
661
662 /* Undo the local directory
663 */
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
664 cherokee_buffer_drop_ending (&conn->local_directory, conn->request.len);
1e660eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1479 5dc97367-9…
alobbs authored
665 return ret;
666 }
667
668
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
669 ret_t
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
670 cherokee_handler_file_add_headers (cherokee_handler_file_t *fhdl,
671 cherokee_buffer_t *buffer)
672 {
673 ret_t ret;
c8b1afa @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@527 5dc97367-97…
alobbs authored
674 char bufstr[DTM_SIZE_GMTTM_STR];
651edbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
alobbs authored
675 struct tm modified_tm;
9db754d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@771 5dc97367-97…
alobbs authored
676 size_t szlen = 0;
677 off_t content_length = 0;
678 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
679
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
680 /* OPTIONS request
681 */
682 if (unlikely (HANDLER_CONN(fhdl)->header.method == http_options)) {
683 cherokee_buffer_add_str (buffer, "Content-Length: 0"CRLF);
684 cherokee_handler_add_header_options (HANDLER(fhdl), buffer);
685 return ret_ok;
686 }
687
688 /* Regular request
689 */
651edbd @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
alobbs authored
690 memset (&modified_tm, 0, sizeof(struct tm));
691
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
692 /* ETag: "<etag>"
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
693 */
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
694 if (conn->header.version >= http_version_11) {
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
695 /* ETag: "%lx= FMT_OFFSET_HEX" CRLF
c1c3d1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@550 5dc97367-97…
alobbs authored
696 */
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
697 cherokee_buffer_add_str (buffer, "ETag: \"");
c1c3d1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@550 5dc97367-97…
alobbs authored
698 cherokee_buffer_add_ullong16(buffer, (cullong_t) fhdl->info->st_mtime);
699 cherokee_buffer_add_str (buffer, "=");
700 cherokee_buffer_add_ullong16(buffer, (cullong_t) fhdl->info->st_size);
0c4c1d0 @alobbs Fixes ETag header syntax. Fixes http://bugs.cherokee-project.com/1120
alobbs authored
701 cherokee_buffer_add_str (buffer, "\"" CRLF);
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
702 }
703
704 /* Last-Modified:
705 */
706 cherokee_gmtime (&fhdl->info->st_mtime, &modified_tm);
707
c8b1afa @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@527 5dc97367-97…
alobbs authored
708 szlen = cherokee_dtm_gmttm2str(bufstr, DTM_SIZE_GMTTM_STR, &modified_tm);
709
710 cherokee_buffer_add_str(buffer, "Last-Modified: ");
711 cherokee_buffer_add (buffer, bufstr, szlen);
712 cherokee_buffer_add_str(buffer, CRLF);
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
713
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
714 /* Add MIME related headers:
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
715 * "Content-Type:" and "Cache-Control: max-age="
716 */
717 if (fhdl->mime != NULL) {
718 cuint_t maxage;
337832a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1375 5dc97367-9…
alobbs authored
719 cherokee_buffer_t *mime = NULL;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
720
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
721 cherokee_mime_entry_get_type (fhdl->mime, &mime);
337832a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1375 5dc97367-9…
alobbs authored
722 cherokee_buffer_add_str (buffer, "Content-Type: ");
723 cherokee_buffer_add_buffer (buffer, mime);
724 cherokee_buffer_add_str (buffer, CRLF);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
725
726 ret = cherokee_mime_entry_get_maxage (fhdl->mime, &maxage);
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
727 if (ret == ret_ok) {
bba8964 @alobbs The Cache-Control header was being duplicated whenever a configuration
alobbs authored
728 /* Set the expiration if there wasn't a
729 * previous val. connection.c will render it.
147554c Added HTTP header Expires: to support max-age for HTTP/1.0 connection…
ADF authored
730 */
bba8964 @alobbs The Cache-Control header was being duplicated whenever a configuration
alobbs authored
731 if (conn->expiration == cherokee_expiration_none) {
732 conn->expiration = cherokee_expiration_time;
402eb35 @alobbs Fixes an issue related to the 'max-age' property of the Content-Type
alobbs authored
733 conn->expiration_time = maxage;
147554c Added HTTP header Expires: to support max-age for HTTP/1.0 connection…
ADF authored
734 }
48cae3a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@358 5dc97367-97…
alobbs authored
735 }
736 }
737
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
738 /* If it's replying "304 Not Modified", we're done here
739 */
740 if (fhdl->not_modified) {
741 /* The handler will manage this special reply
742 */
5409294 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2705 5dc97367-9…
alobbs authored
743 HANDLER(fhdl)->support |= hsupport_error;
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
744
745 conn->error_code = http_not_modified;
746 return ret_ok;
747 }
748
749
4d96114 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@2646 5dc97367-9…
skarcha authored
750 if (cherokee_connection_should_include_length(conn)) {
c6dc1b3 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@2647 5dc97367-9…
skarcha authored
751
752 HANDLER(fhdl)->support |= hsupport_length;
753
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
754 /* Content Length
755 */
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
756 content_length = conn->range_end - conn->range_start + 1;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
757 if (unlikely (content_length < 0)) {
4d96114 @skarcha git-svn-id: svn://cherokee-project.com/cherokee/trunk@2646 5dc97367-9…
skarcha authored
758 content_length = 0;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
759 }
760
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
761 if (conn->error_code == http_partial_content) {
c1c3d1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@550 5dc97367-97…
alobbs authored
762 /*
763 * "Content-Range: bytes " FMT_OFFSET "-" FMT_OFFSET
764 * "/" FMT_OFFSET CRLF
765 */
766 cherokee_buffer_add_str (buffer, "Content-Range: bytes ");
767 cherokee_buffer_add_ullong10(buffer, (cullong_t)conn->range_start);
768 cherokee_buffer_add_str (buffer, "-");
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
769 cherokee_buffer_add_ullong10(buffer, (cullong_t)(conn->range_end));
c1c3d1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@550 5dc97367-97…
alobbs authored
770 cherokee_buffer_add_str (buffer, "/");
771 cherokee_buffer_add_ullong10(buffer, (cullong_t)fhdl->info->st_size);
772 cherokee_buffer_add_str (buffer, CRLF);
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
773 }
c8b1afa @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@527 5dc97367-97…
alobbs authored
774
c1c3d1a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@550 5dc97367-97…
alobbs authored
775 /*
776 * "Content-Length: " FMT_OFFSET CRLF
777 */
778 cherokee_buffer_add_str (buffer, "Content-Length: ");
779 cherokee_buffer_add_ullong10(buffer, (cullong_t) content_length);
780 cherokee_buffer_add_str (buffer, CRLF);
16f58af @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@349 5dc97367-97…
alobbs authored
781 }
782
783 return ret_ok;
784 }
785
786
787 ret_t
7c793e0 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@529 5dc97367-97…
alobbs authored
788 cherokee_handler_file_step (cherokee_handler_file_t *fhdl, cherokee_buffer_t *buffer)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
789 {
790 off_t total;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
791 size_t size;
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
792 cherokee_connection_t *conn = HANDLER_CONN(fhdl);
793
15285bc @alobbs Works out the OPTIONS support. Now it is handled by the handlers
alobbs authored
794 /* OPTIONS request
795 */
796 if (unlikely (HANDLER_CONN(fhdl)->header.method == http_options)) {
797 return ret_eof;
798 }
799
981205c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@408 5dc97367-97…
alobbs authored
800 #ifdef WITH_SENDFILE
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
801 if (fhdl->using_sendfile) {
802 ret_t ret;
803 ssize_t sent;
0f8d506 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2790 5dc97367-9…
alobbs authored
804 off_t to_send;
805
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
806 to_send = conn->range_end - fhdl->offset + 1;
0f8d506 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2790 5dc97367-9…
alobbs authored
807 if ((conn->limit_bps > 0) &&
808 (conn->limit_bps < to_send))
809 {
810 to_send = conn->limit_bps;
811 }
812
813 ret = cherokee_socket_sendfile (&conn->socket, /* cherokee_socket_t *socket */
814 fhdl->fd, /* int fd */
815 to_send, /* size_t size */
816 &fhdl->offset, /* off_t *offset */
817 &sent); /* ssize_t *sent */
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
818
4eec0fb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1754 5dc97367-9…
alobbs authored
819 /* cherokee_handler_file_init() activated the TCP_CORK
820 * flags. Then the response header was sent. Now, the
821 * first chunk of the file with sendfile(), so it's
822 * time to turn off the TCP_CORK flag again.
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
823 */
c69896a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@639 5dc97367-97…
alobbs authored
824 if (conn->options & conn_op_tcp_cork) {
825 cherokee_connection_set_cork (conn, false);
4eec0fb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1754 5dc97367-9…
alobbs authored
826 BIT_UNSET (conn->options, conn_op_tcp_cork);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
827 }
828
050676e @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@348 5dc97367-97…
alobbs authored
829 if (ret == ret_no_sys) {
830 fhdl->using_sendfile = false;
831 goto exit_sendfile;
832 }
833
267be32 @alobbs Bug-fix: Some events were not forwarded properly - not big deal.
alobbs authored
834 if (ret != ret_ok) {
81679d0 handler_*.c, space / code style cleanups
ADF authored
835 return ret;
267be32 @alobbs Bug-fix: Some events were not forwarded properly - not big deal.
alobbs authored
836 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
837
838 /* This connection is not using the cherokee_connection_send() method,
839 * so we have to update the connection traffic counter here.
840 */
841 cherokee_connection_tx_add (conn, sent);
842
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
843 if (fhdl->offset >= conn->range_end) {
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
844 return ret_eof;
845 }
846
847 return ret_ok_and_sent;
848 }
849
850 exit_sendfile:
851 #endif
852 /* Check the amount to read
853 */
e33b1b3 @alobbs Re-implements how a local file is read. The previous code was filling
alobbs authored
854 size = MIN (DEFAULT_READ_SIZE, (conn->range_end - fhdl->offset + 1));
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
855
e2af228 @alobbs Fixes a regression around the encoding process. Some static files were
alobbs authored
856 /* Ensure there's enough memory
857 */
dc35467 @alobbs Fixes an out-by-one bug. Thanks a million to Martin Szulecki for
alobbs authored
858 cherokee_buffer_ensure_size (buffer, size + 1);
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
859
860 /* Read
861 */
02ad45c @alobbs Mind EINTR
alobbs authored
862 do {
863 total = read (fhdl->fd, buffer->buf, size);
864 } while ((total == -1) && (errno == EINTR));
865
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
866 switch (total) {
867 case 0:
868 return ret_eof;
869 case -1:
870 return ret_error;
871 default:
872 buffer->len = total;
d14253d @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3196 5dc97367-9…
alobbs authored
873 buffer->buf[buffer->len] = '\0';
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
874 fhdl->offset += total;
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
875 }
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
876
877 /* Maybe it was the last file chunk
878 */
9134084 @alobbs Fixes Range management while serving static files. Patch by Antonio
alobbs authored
879 if (fhdl->offset >= conn->range_end) {
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
880 return ret_eof_have_data;
881 }
882
883 return ret_ok;
884 }
885
3bcf63c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2852 5dc97367-9…
alobbs authored
886 ret_t
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
887 cherokee_handler_file_seek (cherokee_handler_file_t *hdl,
3bcf63c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2852 5dc97367-9…
alobbs authored
888 off_t start)
889 {
890 cherokee_connection_t *conn = HANDLER_CONN(hdl);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
891
3bcf63c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2852 5dc97367-9…
alobbs authored
892 conn->range_start = start;
893 hdl->offset = start;
894
895 return ret_ok;
896 }
Something went wrong with that request. Please try again.