6 #include "stat_cache.h"
9 #include "configfile.h"
13 #include <sys/types.h>
28 #include "sys-socket.h"
30 int http_response_write_header(server
*srv
, connection
*con
) {
38 if (con
->request
.http_version
== HTTP_VERSION_1_1
) {
39 buffer_copy_string_len(b
, CONST_STR_LEN("HTTP/1.1 "));
41 buffer_copy_string_len(b
, CONST_STR_LEN("HTTP/1.0 "));
43 buffer_append_int(b
, con
->http_status
);
44 buffer_append_string_len(b
, CONST_STR_LEN(" "));
45 buffer_append_string(b
, get_http_status_name(con
->http_status
));
47 /* disable keep-alive if requested */
48 if (con
->request_count
> con
->conf
.max_keep_alive_requests
|| 0 == con
->conf
.max_keep_alive_idle
) {
51 con
->keep_alive_idle
= con
->conf
.max_keep_alive_idle
;
54 if (con
->request
.http_version
!= HTTP_VERSION_1_1
|| con
->keep_alive
== 0) {
55 if (con
->keep_alive
) {
56 response_header_overwrite(srv
, con
, CONST_STR_LEN("Connection"), CONST_STR_LEN("keep-alive"));
58 response_header_overwrite(srv
, con
, CONST_STR_LEN("Connection"), CONST_STR_LEN("close"));
62 if (con
->response
.transfer_encoding
& HTTP_TRANSFER_ENCODING_CHUNKED
) {
63 response_header_overwrite(srv
, con
, CONST_STR_LEN("Transfer-Encoding"), CONST_STR_LEN("chunked"));
68 for (i
= 0; i
< con
->response
.headers
->used
; i
++) {
71 ds
= (data_string
*)con
->response
.headers
->data
[i
];
73 if (!buffer_is_empty(ds
->value
) && !buffer_is_empty(ds
->key
) &&
74 0 != strncasecmp(ds
->key
->ptr
, CONST_STR_LEN("X-LIGHTTPD-")) &&
75 0 != strncasecmp(ds
->key
->ptr
, CONST_STR_LEN("X-Sendfile"))) {
76 if (0 == strcasecmp(ds
->key
->ptr
, "Date")) have_date
= 1;
77 if (0 == strcasecmp(ds
->key
->ptr
, "Server")) have_server
= 1;
78 if (0 == strcasecmp(ds
->key
->ptr
, "Content-Encoding") && 304 == con
->http_status
) continue;
80 buffer_append_string_len(b
, CONST_STR_LEN("\r\n"));
81 buffer_append_string_buffer(b
, ds
->key
);
82 buffer_append_string_len(b
, CONST_STR_LEN(": "));
85 * the value might contain newlines, encode them with at least one white-space
87 buffer_append_string_encoded(b
, CONST_BUF_LEN(ds
->value
), ENCODING_HTTP_HEADER
);
89 buffer_append_string_buffer(b
, ds
->value
);
95 /* HTTP/1.1 requires a Date: header */
96 buffer_append_string_len(b
, CONST_STR_LEN("\r\nDate: "));
98 /* cache the generated timestamp */
99 if (srv
->cur_ts
!= srv
->last_generated_date_ts
) {
100 buffer_string_prepare_copy(srv
->ts_date_str
, 255);
102 buffer_append_strftime(srv
->ts_date_str
, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(srv
->cur_ts
)));
104 srv
->last_generated_date_ts
= srv
->cur_ts
;
107 buffer_append_string_buffer(b
, srv
->ts_date_str
);
111 if (!buffer_string_is_empty(con
->conf
.server_tag
)) {
112 buffer_append_string_len(b
, CONST_STR_LEN("\r\nServer: "));
113 buffer_append_string_encoded(b
, CONST_BUF_LEN(con
->conf
.server_tag
), ENCODING_HTTP_HEADER
);
117 buffer_append_string_len(b
, CONST_STR_LEN("\r\n\r\n"));
119 con
->bytes_header
= buffer_string_length(b
);
121 if (con
->conf
.log_response_header
) {
122 log_error_write(srv
, __FILE__
, __LINE__
, "sSb", "Response-Header:", "\n", b
);
125 chunkqueue_prepend_buffer(con
->write_queue
, b
);
132 static void https_add_ssl_entries(connection
*con
) {
139 SSL_get_verify_result(con
->ssl
) != X509_V_OK
140 || !(xs
= SSL_get_peer_certificate(con
->ssl
))
145 xn
= X509_get_subject_name(xs
);
146 for (i
= 0, nentries
= X509_NAME_entry_count(xn
); i
< nentries
; ++i
) {
151 if (!(xe
= X509_NAME_get_entry(xn
, i
))) {
154 xobjnid
= OBJ_obj2nid((ASN1_OBJECT
*)X509_NAME_ENTRY_get_object(xe
));
155 xobjsn
= OBJ_nid2sn(xobjnid
);
160 if (NULL
== (envds
= (data_string
*)array_get_unused_element(con
->environment
, TYPE_STRING
))) {
161 envds
= data_string_init();
163 buffer_copy_string_len(envds
->key
, CONST_STR_LEN("SSL_CLIENT_S_DN_"));
164 buffer_append_string(envds
->key
, xobjsn
);
165 buffer_copy_string_len(
167 (const char *)X509_NAME_ENTRY_get_data(xe
)->data
,
168 X509_NAME_ENTRY_get_data(xe
)->length
170 /* pick one of the exported values as "REMOTE_USER", for example
171 * ssl.verifyclient.username = "SSL_CLIENT_S_DN_UID" or "SSL_CLIENT_S_DN_emailAddress"
173 if (buffer_is_equal(con
->conf
.ssl_verifyclient_username
, envds
->key
)) {
175 if (NULL
== (ds
= (data_string
*)array_get_element(con
->environment
, "REMOTE_USER"))) {
176 if (NULL
== (ds
= (data_string
*)array_get_unused_element(con
->environment
, TYPE_STRING
))) {
177 ds
= data_string_init();
179 buffer_copy_string(ds
->key
, "REMOTE_USER");
180 array_insert_unique(con
->environment
, (data_unset
*)ds
);
182 buffer_copy_buffer(ds
->value
, envds
->value
);
184 array_insert_unique(con
->environment
, (data_unset
*)envds
);
186 if (con
->conf
.ssl_verifyclient_export_cert
) {
188 if (NULL
!= (bio
= BIO_new(BIO_s_mem()))) {
192 PEM_write_bio_X509(bio
, xs
);
193 n
= BIO_pending(bio
);
195 if (NULL
== (envds
= (data_string
*)array_get_unused_element(con
->environment
, TYPE_STRING
))) {
196 envds
= data_string_init();
199 buffer_copy_string_len(envds
->key
, CONST_STR_LEN("SSL_CLIENT_CERT"));
200 buffer_string_prepare_copy(envds
->value
, n
);
201 BIO_read(bio
, envds
->value
->ptr
, n
);
203 buffer_commit(envds
->value
, n
);
204 array_insert_unique(con
->environment
, (data_unset
*)envds
);
212 handler_t
http_response_prepare(server
*srv
, connection
*con
) {
215 /* looks like someone has already done a decision */
216 if (con
->mode
== DIRECT
&&
217 (con
->http_status
!= 0 && con
->http_status
!= 200)) {
218 /* remove a packets in the queue */
219 if (con
->file_finished
== 0) {
220 chunkqueue_reset(con
->write_queue
);
223 return HANDLER_FINISHED
;
226 /* no decision yet, build conf->filename */
227 if (con
->mode
== DIRECT
&& buffer_is_empty(con
->physical
.path
)) {
230 /* we only come here when we have the parse the full request again
232 * a HANDLER_COMEBACK from mod_rewrite and mod_fastcgi might be a
233 * problem here as mod_setenv might get called multiple times
235 * fastcgi-auth might lead to a COMEBACK too
236 * fastcgi again dead server too
238 * mod_compress might add headers twice too
242 config_cond_cache_reset(srv
, con
);
243 config_setup_connection(srv
, con
); /* Perhaps this could be removed at other places. */
245 if (con
->conf
.log_condition_handling
) {
246 log_error_write(srv
, __FILE__
, __LINE__
, "s", "run condition");
253 * - uri.path (secure)
259 * Name according to RFC 2396
266 * (scheme)://(authority)(path)?(query)#fragment
271 /* initial scheme value. can be overwritten for example by mod_extforward later */
272 if (con
->srv_socket
->is_ssl
) {
273 buffer_copy_string_len(con
->uri
.scheme
, CONST_STR_LEN("https"));
275 buffer_copy_string_len(con
->uri
.scheme
, CONST_STR_LEN("http"));
277 buffer_copy_buffer(con
->uri
.authority
, con
->request
.http_host
);
278 buffer_to_lower(con
->uri
.authority
);
280 /** their might be a fragment which has to be cut away */
281 if (NULL
!= (qstr
= strchr(con
->request
.uri
->ptr
, '#'))) {
282 buffer_string_set_length(con
->request
.uri
, qstr
- con
->request
.uri
->ptr
);
285 /** extract query string from request.uri */
286 if (NULL
!= (qstr
= strchr(con
->request
.uri
->ptr
, '?'))) {
287 buffer_copy_string (con
->uri
.query
, qstr
+ 1);
288 buffer_copy_string_len(con
->uri
.path_raw
, con
->request
.uri
->ptr
, qstr
- con
->request
.uri
->ptr
);
290 buffer_reset (con
->uri
.query
);
291 buffer_copy_buffer(con
->uri
.path_raw
, con
->request
.uri
);
294 /* decode url to path
296 * - decode url-encodings (e.g. %20 -> ' ')
297 * - remove path-modifiers (e.g. /../)
300 if (con
->request
.http_method
== HTTP_METHOD_OPTIONS
&&
301 con
->uri
.path_raw
->ptr
[0] == '*' && con
->uri
.path_raw
->ptr
[1] == '\0') {
303 buffer_copy_buffer(con
->uri
.path
, con
->uri
.path_raw
);
305 buffer_copy_buffer(srv
->tmp_buf
, con
->uri
.path_raw
);
306 buffer_urldecode_path(srv
->tmp_buf
);
307 buffer_path_simplify(con
->uri
.path
, srv
->tmp_buf
);
310 con
->conditional_is_valid
[COMP_SERVER_SOCKET
] = 1; /* SERVERsocket */
311 con
->conditional_is_valid
[COMP_HTTP_SCHEME
] = 1; /* Scheme: */
312 con
->conditional_is_valid
[COMP_HTTP_HOST
] = 1; /* Host: */
313 con
->conditional_is_valid
[COMP_HTTP_REMOTE_IP
] = 1; /* Client-IP */
314 con
->conditional_is_valid
[COMP_HTTP_REFERER
] = 1; /* Referer: */
315 con
->conditional_is_valid
[COMP_HTTP_USER_AGENT
] = /* User-Agent: */
316 con
->conditional_is_valid
[COMP_HTTP_LANGUAGE
] = 1; /* Accept-Language: */
317 con
->conditional_is_valid
[COMP_HTTP_COOKIE
] = 1; /* Cookie: */
318 con
->conditional_is_valid
[COMP_HTTP_REQUEST_METHOD
] = 1; /* REQUEST_METHOD */
319 con
->conditional_is_valid
[COMP_HTTP_URL
] = 1; /* HTTPurl */
320 con
->conditional_is_valid
[COMP_HTTP_QUERY_STRING
] = 1; /* HTTPqs */
321 config_patch_connection(srv
, con
);
324 if (con
->srv_socket
->is_ssl
&& con
->conf
.ssl_verifyclient
) {
325 https_add_ssl_entries(con
);
329 /* do we have to downgrade to 1.0 ? */
330 if (!con
->conf
.allow_http11
) {
331 con
->request
.http_version
= HTTP_VERSION_1_0
;
334 if (con
->conf
.log_request_handling
) {
335 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- splitting Request-URI");
336 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Request-URI : ", con
->request
.uri
);
337 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI-scheme : ", con
->uri
.scheme
);
338 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI-authority : ", con
->uri
.authority
);
339 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI-path (raw) : ", con
->uri
.path_raw
);
340 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI-path (clean): ", con
->uri
.path
);
341 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI-query : ", con
->uri
.query
);
344 /* con->conf.max_request_size is in kBytes */
345 if (0 != con
->conf
.max_request_size
&&
346 (off_t
)con
->request
.content_length
> ((off_t
)con
->conf
.max_request_size
<< 10)) {
347 log_error_write(srv
, __FILE__
, __LINE__
, "sos",
348 "request-size too long:", (off_t
) con
->request
.content_length
, "-> 413");
350 con
->http_status
= 413;
351 con
->file_finished
= 1;
353 return HANDLER_FINISHED
;
361 * - based on the raw URL
365 switch(r
= plugins_call_handle_uri_raw(srv
, con
)) {
368 case HANDLER_FINISHED
:
369 case HANDLER_COMEBACK
:
370 case HANDLER_WAIT_FOR_EVENT
:
374 log_error_write(srv
, __FILE__
, __LINE__
, "sd", "handle_uri_raw: unknown return value", r
);
382 * - based on the clean URL
386 switch(r
= plugins_call_handle_uri_clean(srv
, con
)) {
389 case HANDLER_FINISHED
:
390 case HANDLER_COMEBACK
:
391 case HANDLER_WAIT_FOR_EVENT
:
395 log_error_write(srv
, __FILE__
, __LINE__
, "");
399 if (con
->request
.http_method
== HTTP_METHOD_OPTIONS
&&
400 con
->uri
.path
->ptr
[0] == '*' && con
->uri
.path_raw
->ptr
[1] == '\0') {
401 /* option requests are handled directly without checking of the path */
403 response_header_insert(srv
, con
, CONST_STR_LEN("Allow"), CONST_STR_LEN("OPTIONS, GET, HEAD, POST"));
405 con
->http_status
= 200;
406 con
->file_finished
= 1;
408 return HANDLER_FINISHED
;
415 * logical filename (URI) becomes a physical filename here
425 * ... ISREG() -> ok, go on
426 * ... ISDIR() -> index-file -> redirect
436 * SEARCH DOCUMENT ROOT
441 buffer_copy_buffer(con
->physical
.doc_root
, con
->conf
.document_root
);
442 buffer_copy_buffer(con
->physical
.rel_path
, con
->uri
.path
);
444 #if defined(__WIN32) || defined(__CYGWIN__)
445 /* strip dots from the end and spaces
447 * windows/dos handle those filenames as the same file
449 * foo == foo. == foo..... == "foo... " == "foo.. ./"
451 * This will affect in some cases PATHINFO
453 * on native windows we could prepend the filename with \\?\ to circumvent
454 * this behaviour. I have no idea how to push this through cygwin
458 if (con
->physical
.rel_path
->used
> 1) {
459 buffer
*b
= con
->physical
.rel_path
;
460 size_t len
= buffer_string_length(b
);
462 /* strip trailing " /" or "./" once */
464 b
->ptr
[len
- 1] == '/' &&
465 (b
->ptr
[len
- 2] == ' ' || b
->ptr
[len
- 2] == '.')) {
468 /* strip all trailing " " and "." */
469 while (len
> 0 && ( ' ' == b
->ptr
[len
-1] || '.' == b
->ptr
[len
-1] ) ) --len
;
470 buffer_string_set_length(b
, len
);
474 if (con
->conf
.log_request_handling
) {
475 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- before doc_root");
476 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Doc-Root :", con
->physical
.doc_root
);
477 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Rel-Path :", con
->physical
.rel_path
);
478 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
480 /* the docroot plugin should set the doc_root and might also set the physical.path
481 * for us (all vhost-plugins are supposed to set the doc_root)
483 switch(r
= plugins_call_handle_docroot(srv
, con
)) {
486 case HANDLER_FINISHED
:
487 case HANDLER_COMEBACK
:
488 case HANDLER_WAIT_FOR_EVENT
:
492 log_error_write(srv
, __FILE__
, __LINE__
, "");
496 /* MacOS X and Windows can't distiguish between upper and lower-case
498 * convert to lower-case
500 if (con
->conf
.force_lowercase_filenames
) {
501 buffer_to_lower(con
->physical
.rel_path
);
504 /* the docroot plugins might set the servername, if they don't we take http-host */
505 if (buffer_string_is_empty(con
->server_name
)) {
506 buffer_copy_buffer(con
->server_name
, con
->uri
.authority
);
510 * create physical filename
511 * -> physical.path = docroot + rel_path
515 buffer_copy_buffer(con
->physical
.basedir
, con
->physical
.doc_root
);
516 buffer_copy_buffer(con
->physical
.path
, con
->physical
.doc_root
);
517 buffer_append_slash(con
->physical
.path
);
518 if (!buffer_string_is_empty(con
->physical
.rel_path
) &&
519 con
->physical
.rel_path
->ptr
[0] == '/') {
520 buffer_append_string_len(con
->physical
.path
, con
->physical
.rel_path
->ptr
+ 1, buffer_string_length(con
->physical
.rel_path
) - 1);
522 buffer_append_string_buffer(con
->physical
.path
, con
->physical
.rel_path
);
525 if (con
->conf
.log_request_handling
) {
526 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- after doc_root");
527 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Doc-Root :", con
->physical
.doc_root
);
528 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Rel-Path :", con
->physical
.rel_path
);
529 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
532 switch(r
= plugins_call_handle_physical(srv
, con
)) {
535 case HANDLER_FINISHED
:
536 case HANDLER_COMEBACK
:
537 case HANDLER_WAIT_FOR_EVENT
:
541 log_error_write(srv
, __FILE__
, __LINE__
, "");
545 if (con
->conf
.log_request_handling
) {
546 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- logical -> physical");
547 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Doc-Root :", con
->physical
.doc_root
);
548 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Basedir :", con
->physical
.basedir
);
549 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Rel-Path :", con
->physical
.rel_path
);
550 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
555 * Noone catched away the file from normal path of execution yet (like mod_access)
557 * Go on and check of the file exists at all
560 if (con
->mode
== DIRECT
) {
562 char *pathinfo
= NULL
;
564 stat_cache_entry
*sce
= NULL
;
566 if (con
->conf
.log_request_handling
) {
567 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- handling physical path");
568 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
571 if (HANDLER_ERROR
!= stat_cache_get_entry(srv
, con
, con
->physical
.path
, &sce
)) {
574 if (con
->conf
.log_request_handling
) {
575 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- file found");
576 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
579 if ((sce
->is_symlink
!= 0) && !con
->conf
.follow_symlink
) {
580 con
->http_status
= 403;
582 if (con
->conf
.log_request_handling
) {
583 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- access denied due symlink restriction");
584 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
587 buffer_reset(con
->physical
.path
);
588 return HANDLER_FINISHED
;
591 if (S_ISDIR(sce
->st
.st_mode
)) {
592 if (con
->uri
.path
->ptr
[buffer_string_length(con
->uri
.path
) - 1] != '/') {
593 /* redirect to .../ */
595 http_response_redirect_to_directory(srv
, con
);
597 return HANDLER_FINISHED
;
600 } else if (!S_ISREG(sce
->st
.st_mode
) && !sce
->is_symlink
) {
602 } else if (!S_ISREG(sce
->st
.st_mode
)) {
604 /* any special handling of non-reg files ?*/
611 con
->http_status
= 403;
613 if (con
->conf
.log_request_handling
) {
614 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- access denied");
615 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
618 buffer_reset(con
->physical
.path
);
619 return HANDLER_FINISHED
;
621 /* file name to be read was too long. return 404 */
623 con
->http_status
= 404;
625 if (con
->conf
.log_request_handling
) {
626 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- file not found");
627 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
630 buffer_reset(con
->physical
.path
);
631 return HANDLER_FINISHED
;
636 /* we have no idea what happend. let's tell the user so. */
637 con
->http_status
= 500;
638 buffer_reset(con
->physical
.path
);
640 log_error_write(srv
, __FILE__
, __LINE__
, "ssbsb",
641 "file not found ... or so: ", strerror(errno
),
643 "->", con
->physical
.path
);
645 return HANDLER_FINISHED
;
648 /* not found, perhaps PATHINFO */
650 buffer_copy_buffer(srv
->tmp_buf
, con
->physical
.path
);
654 buffer_copy_string_len(con
->physical
.path
, srv
->tmp_buf
->ptr
, slash
- srv
->tmp_buf
->ptr
);
656 buffer_copy_buffer(con
->physical
.path
, srv
->tmp_buf
);
659 if (HANDLER_ERROR
!= stat_cache_get_entry(srv
, con
, con
->physical
.path
, &sce
)) {
660 found
= S_ISREG(sce
->st
.st_mode
);
664 if (pathinfo
!= NULL
) {
667 slash
= strrchr(srv
->tmp_buf
->ptr
, '/');
669 if (pathinfo
!= NULL
) {
674 if (slash
) pathinfo
= slash
;
675 } while ((found
== 0) && (slash
!= NULL
) && ((size_t)(slash
- srv
->tmp_buf
->ptr
) > (buffer_string_length(con
->physical
.basedir
) - 1)));
678 /* no it really doesn't exists */
679 con
->http_status
= 404;
681 if (con
->conf
.log_file_not_found
) {
682 log_error_write(srv
, __FILE__
, __LINE__
, "sbsb",
683 "file not found:", con
->uri
.path
,
684 "->", con
->physical
.path
);
687 buffer_reset(con
->physical
.path
);
689 return HANDLER_FINISHED
;
693 if ((sce
->is_symlink
!= 0) && !con
->conf
.follow_symlink
) {
694 con
->http_status
= 403;
696 if (con
->conf
.log_request_handling
) {
697 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- access denied due symlink restriction");
698 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
701 buffer_reset(con
->physical
.path
);
702 return HANDLER_FINISHED
;
706 /* we have a PATHINFO */
708 size_t len
= strlen(pathinfo
), reqlen
;
709 if (con
->conf
.force_lowercase_filenames
710 && len
<= (reqlen
= buffer_string_length(con
->request
.uri
))
711 && 0 == strncasecmp(con
->request
.uri
->ptr
+ reqlen
- len
, pathinfo
, len
)) {
712 /* attempt to preserve case-insensitive PATH_INFO
713 * (works in common case where mod_alias, mod_magnet, and other modules
714 * have not modified the PATH_INFO portion of request URI, or did so
715 * with exactly the PATH_INFO desired) */
716 buffer_copy_string_len(con
->request
.pathinfo
, con
->request
.uri
->ptr
+ reqlen
- len
, len
);
718 buffer_copy_string_len(con
->request
.pathinfo
, pathinfo
, len
);
725 buffer_string_set_length(con
->uri
.path
, buffer_string_length(con
->uri
.path
) - len
);
728 if (con
->conf
.log_request_handling
) {
729 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- after pathinfo check");
730 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
731 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "URI :", con
->uri
.path
);
732 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Pathinfo :", con
->request
.pathinfo
);
736 if (con
->conf
.log_request_handling
) {
737 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- handling subrequest");
738 log_error_write(srv
, __FILE__
, __LINE__
, "sb", "Path :", con
->physical
.path
);
741 /* call the handlers */
742 switch(r
= plugins_call_handle_subrequest_start(srv
, con
)) {
744 /* request was not handled */
746 case HANDLER_FINISHED
:
748 if (con
->conf
.log_request_handling
) {
749 log_error_write(srv
, __FILE__
, __LINE__
, "s", "-- subrequest finished");
752 /* something strange happend */
756 /* if we are still here, no one wanted the file, status 403 is ok I think */
758 if (con
->mode
== DIRECT
&& con
->http_status
== 0) {
759 switch (con
->request
.http_method
) {
760 case HTTP_METHOD_OPTIONS
:
761 con
->http_status
= 200;
764 con
->http_status
= 403;
767 return HANDLER_FINISHED
;
772 switch(r
= plugins_call_handle_subrequest(srv
, con
)) {
774 /* request was not handled, looks like we are done */
775 return HANDLER_FINISHED
;
776 case HANDLER_FINISHED
:
777 /* request is finished */
779 /* something strange happend */
784 return HANDLER_COMEBACK
;