Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 109 lines (90 sloc) 2.638 kb
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
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
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
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 */
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
24
25 #include "common-internal.h"
26 #include "rule_method.h"
27 #include "plugin_loader.h"
28 #include "connection-protected.h"
29 #include "util.h"
30 #include "thread.h"
31 #include "server-protected.h"
32
33 #define ENTRIES "rule,method"
34
35 PLUGIN_INFO_RULE_EASIEST_INIT(method);
36
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
37 static ret_t
38 configure (cherokee_rule_method_t *rule,
39 cherokee_config_node_t *conf,
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
40 cherokee_virtual_server_t *vsrv)
41 {
42 ret_t ret;
43 cherokee_buffer_t *tmp = NULL;
44
45 UNUSED(vsrv);
46
47 ret = cherokee_config_node_read (conf, "method", &tmp);
48 if (ret != ret_ok) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
49 LOG_CRITICAL (CHEROKEE_ERROR_RULE_NO_PROPERTY,
50 RULE(rule)->priority, "method");
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
51 return ret_error;
52 }
53
54 ret = cherokee_http_string_to_method (tmp, &rule->method);
55 if (ret != ret_ok) {
165f0ad @alobbs Merges the 'newerrors' branch (r3613:HEAD). It implements a new
alobbs authored
56 LOG_CRITICAL (CHEROKEE_ERROR_RULE_METHOD_UNKNOWN, tmp->buf);
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
57 return ret;
58 }
59
60 return ret_ok;
61 }
62
63 static ret_t
64 _free (void *p)
65 {
1e47304 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2701 5dc97367-9…
alobbs authored
66 UNUSED(p);
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
67 return ret_ok;
68 }
69
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
70 static ret_t
4071d6a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3288 5dc97367-9…
alobbs authored
71 match (cherokee_rule_method_t *rule,
72 cherokee_connection_t *conn,
73 cherokee_config_entry_t *ret_conf)
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
74 {
4071d6a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@3288 5dc97367-9…
alobbs authored
75 UNUSED(ret_conf);
76
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
77 if (conn->header.method == rule->method) {
78 TRACE(ENTRIES, "Match method: %d\n", rule->method);
79 return ret_ok;
80 }
81
2f17d15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2345 5dc97367-9…
alobbs authored
82 TRACE(ENTRIES, "Didn't match. Conn method=%d, Rule method=%d\n",
83 conn->header.method, rule->method);
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
84 return ret_not_found;
85 }
86
87 ret_t
88 cherokee_rule_method_new (cherokee_rule_method_t **rule)
89 {
90 CHEROKEE_NEW_STRUCT (n, rule_method);
91
92 /* Parent class constructor
93 */
94 cherokee_rule_init_base (RULE(n), PLUGIN_INFO_PTR(method));
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
95
4f72c15 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2300 5dc97367-9…
alobbs authored
96 /* Virtual methods
97 */
98 RULE(n)->match = (rule_func_match_t) match;
99 RULE(n)->configure = (rule_func_configure_t) configure;
100 MODULE(n)->free = (module_func_free_t) _free;
101
102 /* Properties
103 */
104 n->method = http_unknown;
105
106 *rule = n;
107 return ret_ok;
108 }
Something went wrong with that request. Please try again.