Changeset 1731 for cherokee/trunk/cherokee/handler_nn.c
- Timestamp:
- 08/05/08 13:03:59 (5 months ago)
- Files:
-
- cherokee/trunk/cherokee/handler_nn.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/handler_nn.c
r1614 r1731 37 37 #include "plugin_loader.h" 38 38 #include "connection.h" 39 #include "handler_common.h"40 #include "handler_redir.h"41 39 #include "levenshtein_distance.h" 42 40 #include "handler_error.h" 43 41 44 42 ret_t 45 cherokee_handler_nn_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) 43 cherokee_handler_nn_configure (cherokee_config_node_t *conf, 44 cherokee_server_t *srv, 45 cherokee_module_props_t **_props) 46 46 { 47 return cherokee_handler_common_configure (conf, srv, _props); 47 UNUSED(conf); 48 UNUSED(srv); 49 UNUSED(_props); 50 51 return ret_ok; 48 52 } 49 53 … … 64 68 int dis; 65 69 66 if (!strncmp (entry->d_name, ".", 1)) continue;67 if (!strncmp (entry->d_name, "..", 2)) continue;70 if (!strncmp (entry->d_name, ".", 1)) continue; 71 if (!strncmp (entry->d_name, "..", 2)) continue; 68 72 69 73 dis = distance ((char *)request, entry->d_name); … … 85 89 86 90 static ret_t 87 get_nearest_name ( 88 cherokee_connection_t *conn, 89 cherokee_buffer_t *local_dir, 90 cherokee_buffer_t *request, 91 cherokee_buffer_t *output) 91 get_nearest_name (cherokee_connection_t *conn, 92 cherokee_buffer_t *local_dir, 93 cherokee_buffer_t *request, 94 cherokee_buffer_t *output) 92 95 { 96 ret_t ret; 93 97 char *rest; 94 ret_t ret = ret_ok;95 98 cherokee_thread_t *thread = CONN_THREAD(conn); 96 cherokee_buffer_t *req = THREAD_TMP_BUF1(thread);/* Request w/o last word */99 cherokee_buffer_t *req = THREAD_TMP_BUF1(thread); 97 100 98 101 /* Build the local request path … … 111 114 */ 112 115 ret = get_nearest_from_directory (req->buf, rest, output); 113 114 116 if (unlikely (ret != ret_ok)) { 115 117 return ret_error; … … 124 126 125 127 ret_t 126 cherokee_handler_nn_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_props_t *props) 128 cherokee_handler_nn_new (cherokee_handler_t **hdl, 129 cherokee_connection_t *conn, 130 cherokee_module_props_t *props) 127 131 { 128 ret_t ret; 129 struct stat info; 130 int stat_ret; 131 cherokee_connection_t *conn = CONN(cnt); 132 ret_t ret; 132 133 133 cherokee_buffer_add (&conn->local_directory, conn->request.buf, conn->request.len);134 stat_ret = stat (conn->local_directory.buf, &info);135 cherokee_buffer_drop_ending (&conn->local_directory, conn->request.len);136 137 /* Maybe the file/dir exists138 */139 if (stat_ret == 0) {140 return cherokee_handler_common_new (hdl, cnt, props);141 }142 143 /* It doesn't exists, let's redirect it..144 */145 134 cherokee_buffer_clean (&conn->redirect); 146 135 … … 148 137 if (unlikely (ret != ret_ok)) { 149 138 conn->error_code = http_not_found; 150 return ret_error;139 return cherokee_handler_error_new (hdl, conn, props); 151 140 } 152 141