Mon, 26 Dec 2016 16:46:55 +0100
adds support for ssl cert chain files and improves ssl error handling
1 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
4 | * Copyright 2013 Olaf Wintermann. All rights reserved. |
1 | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include <stdio.h> | |
30 | #include <stdlib.h> | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
31 | #include <limits.h> |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
32 | |
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
33 | #include <arpa/inet.h> |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
34 | |
14
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
35 | #include "../public/nsapi.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
36 | #include "../util/pool.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
37 | #include "../util/pblock.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
38 | #include "../util/io.h" |
b8bf95b39952
New source folder layout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
12
diff
changeset
|
39 | #include "../util/util.h" |
1 | 40 | #include "httprequest.h" |
18
73aacbf6e492
Added server.conf parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
41 | #include "config.h" |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
42 | #include "vserver.h" |
19
d680536f8c2f
Added configuration manager
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
43 | #include "httplistener.h" |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
44 | #include "func.h" |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
45 | #include "error.h" |
1 | 46 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
47 | void http_request_init(HTTPRequest *req) { |
1 | 48 | req->connection = NULL; |
49 | req->uri.ptr = NULL; | |
50 | ||
51 | HeaderArray *hd = malloc(sizeof(HeaderArray)); | |
52 | hd->next = NULL; | |
53 | hd->len = 0; | |
54 | hd->headers = calloc(16, sizeof(Header)); | |
55 | hd->alloc = 16; | |
56 | ||
57 | req->headers = hd; | |
102
136a76e293b5
added etag and conditional request implementation from Open Web Server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
58 | |
136a76e293b5
added etag and conditional request implementation from Open Web Server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
59 | req->req_start = time(NULL); |
1 | 60 | } |
61 | ||
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
62 | void http_request_cleanup(HTTPRequest *req) { |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
63 | header_array_free(req->headers); |
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
64 | free(req); |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
65 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
66 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
67 | sstr_t http_request_get_abspath(HTTPRequest *req) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
68 | sstr_t uri = req->uri; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
69 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
70 | int i = 0; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
71 | if(uri.ptr[0] == '/') { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
72 | return uri; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
73 | } else if(sstrprefix(uri, S("http://"))) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
74 | i = 7; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
75 | } else if(sstrprefix(uri, S("https://"))) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
76 | i = 8; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
77 | } else if(!sstrcmp(uri, S("*"))) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
78 | return uri; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
79 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
80 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
81 | for(;i<uri.length;i++) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
82 | if(uri.ptr[i] == '/') { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
83 | return sstrsubs(uri, i); |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
84 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
85 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
86 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
87 | return S("/"); |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
88 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
89 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
90 | int handle_request(HTTPRequest *request, threadpool_t *thrpool) { |
1 | 91 | // handle nsapi request |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
92 | |
1 | 93 | // create pool |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
94 | pool_handle_t *pool = pool_create(); |
1 | 95 | |
96 | // create nsapi data structures | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
97 | NSAPISession *sn = pool_malloc(pool, sizeof(NSAPISession)); |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
98 | if(sn == NULL) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
99 | /* TODO: error */ |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
100 | } |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
101 | NSAPIRequest *rq = pool_malloc(pool, sizeof(NSAPIRequest)); |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
102 | if(rq == NULL) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
103 | /* TODO: error */ |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
104 | } |
102
136a76e293b5
added etag and conditional request implementation from Open Web Server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
105 | rq->rq.req_start = request->req_start; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
106 | rq->phase = NSAPIAuthTrans; |
1 | 107 | |
108 | // fill session structure | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
109 | sn->connection = request->connection; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
110 | sn->netbuf = request->netbuf; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
111 | sn->sn.pool = pool; |
54 | 112 | //sn->sn.csd = stream_new_from_fd(pool, request->connection->fd); |
106
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
113 | //sn->sn.csd = net_stream_from_fd(pool, request->connection->fd); |
110
43a746e905f6
refactored IO system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
106
diff
changeset
|
114 | IOStream *io; |
106
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
115 | if(request->connection->ssl) { |
110
43a746e905f6
refactored IO system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
106
diff
changeset
|
116 | io = sslstream_new(pool, request->connection->ssl); |
106
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
117 | } else { |
110
43a746e905f6
refactored IO system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
106
diff
changeset
|
118 | io = sysstream_new(pool, request->connection->fd); |
106
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
119 | } |
110
43a746e905f6
refactored IO system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
106
diff
changeset
|
120 | sn->sn.csd = httpstream_new(pool, io); |
106
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
121 | |
b122f34ddc80
added minimal ssl support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
102
diff
changeset
|
122 | |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
123 | sn->sn.client = pblock_create_pool(sn->sn.pool, 8); |
1 | 124 | sn->sn.next = NULL; |
125 | sn->sn.fill = 1; | |
126 | sn->sn.subject = NULL; | |
38
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
127 | |
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
128 | // the session needs the current server configuration |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
129 | sn->config = request->connection->listener->cfg; |
1 | 130 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
131 | // add ip to sn->client pblock |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
132 | char ip_str[INET_ADDRSTRLEN]; |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
133 | if(inet_ntop( |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
134 | AF_INET, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
135 | &request->connection->address.sin_addr, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
136 | ip_str, |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
137 | INET_ADDRSTRLEN) != NULL) |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
138 | { |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
139 | pblock_kvinsert(pb_key_ip, ip_str, INET_ADDRSTRLEN, sn->sn.client); |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
140 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
141 | |
1 | 142 | // init NSAPI request structure |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
143 | if(request_initialize(pool, request, rq) != 0) { |
60
feb2f1e115c6
improved logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
144 | log_ereport(LOG_FAILURE, "Cannot initialize request structure"); |
47
ce9790523346
server can change uid
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
46
diff
changeset
|
145 | pool_destroy(pool); |
1 | 146 | return 1; |
147 | } | |
148 | ||
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
149 | // set default virtual server |
19
d680536f8c2f
Added configuration manager
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
150 | rq->vs = request->connection->listener->default_vs.vs; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
151 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
152 | // Pass request line as "clf-request" |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
153 | // remove \r\n |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
154 | sstr_t clfreq = request->request_line; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
155 | while(clfreq.ptr[clfreq.length - 1] < 33) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
156 | clfreq.length--; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
157 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
158 | request->request_line = clfreq; |
1 | 159 | pblock_kvinsert( |
160 | pb_key_clf_request, | |
161 | request->request_line.ptr, | |
162 | request->request_line.length, | |
163 | rq->rq.reqpb); | |
164 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
165 | // Pass method as "method" in reqpb, and also as method_num |
1 | 166 | pblock_kvinsert( |
167 | pb_key_method, | |
168 | request->method.ptr, | |
169 | request->method.length, | |
170 | rq->rq.reqpb); | |
171 | // TODO: method num | |
172 | //rqRq.rq.method_num = rqHdr->GetMethodNumber(); | |
173 | //PR_ASSERT(rqRq.rq.method_num != -1 || iStatus); | |
174 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
175 | // Pass protocol as "protocol" in reqpb, and also in protv_num |
1 | 176 | pblock_kvinsert( |
177 | pb_key_protocol, | |
178 | request->httpv.ptr, | |
179 | request->httpv.length, | |
180 | rq->rq.reqpb); | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
181 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
182 | if(!sstrcmp(request->httpv, S("HTTP/1.1"))) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
183 | rq->rq.protv_num = PROTOCOL_VERSION_HTTP11; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
184 | } else if(!sstrcmp(request->httpv, S("HTTP/1.0"))) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
185 | rq->rq.protv_num = PROTOCOL_VERSION_HTTP10; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
186 | } else { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
187 | // TODO: invalid protocol version - abort |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
188 | } |
1 | 189 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
190 | /* |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
191 | * get absolute path and query of the request uri |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
192 | */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
193 | // TODO: check for '#' |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
194 | sstr_t absPath = http_request_get_abspath(request); |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
195 | if(!absPath.ptr) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
196 | // TODO: error msg |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
197 | return 1; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
198 | } else if(absPath.ptr[0] == '*') { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
199 | // TODO: implement global OPTIONS |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
200 | return 1; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
201 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
202 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
203 | sstr_t query; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
204 | query.length = 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
205 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
206 | for(int i=0;i<request->uri.length;i++) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
207 | if(request->uri.ptr[i] == '?') { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
208 | /* split uri in path and query */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
209 | if(absPath.length > i + 2) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
210 | query.length = absPath.length - i - 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
211 | query.ptr = absPath.ptr + i + 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
212 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
213 | absPath.length = i; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
214 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
215 | // Pass any query as 'query' in reqpb |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
216 | pblock_kvinsert( |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
217 | pb_key_query, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
218 | query.ptr, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
219 | query.length, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
220 | rq->rq.reqpb); |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
221 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
222 | break; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
223 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
224 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
225 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
226 | // Get abs_path part of request URI, and canonicalize the path |
1 | 227 | absPath.ptr = util_canonicalize_uri( |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
228 | pool, |
1 | 229 | absPath.ptr, |
230 | absPath.length, | |
231 | (int*)&absPath.length); | |
232 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
233 | // Decode the abs_path |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
234 | if(util_uri_unescape_strict(absPath.ptr)) { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
235 | // Pass the abs_path as 'uri' in reqpb |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
236 | pblock_kvinsert( |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
237 | pb_key_uri, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
238 | absPath.ptr, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
239 | absPath.length, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
240 | rq->rq.reqpb); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
241 | } else { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
242 | // TODO: log error |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
243 | printf("unescape failed\n"); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
244 | pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
245 | } |
1 | 246 | |
247 | // pass http header to the NSAPI request structure | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
248 | int hlen = request->headers->len; |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
249 | HeaderArray *ha = request->headers; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
250 | for(int i=0;i<=hlen;i++) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
251 | if(i == hlen) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
252 | ha = ha->next; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
253 | if(ha == NULL) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
254 | break; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
255 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
256 | i = 0; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
257 | hlen = ha->len; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
258 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
259 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
260 | Header header = ha->headers[i]; |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
261 | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
262 | if(header.name.ptr[0] < 90) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
263 | header.name.ptr[0] += 32; |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
264 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
265 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
266 | // change to lower case |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
267 | for(int i=0;i<header.name.length;i++) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
268 | if(header.name.ptr[i] > 64 && header.name.ptr[i] < 97) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
269 | header.name.ptr[i] += 32; |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
270 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
271 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
272 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
273 | pblock_nvlinsert( |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
274 | header.name.ptr, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
275 | header.name.length, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
276 | header.value.ptr, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
277 | header.value.length, |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
278 | rq->rq.headers); |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
279 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
280 | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
281 | // get host and port |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
282 | char *hosthdr = pblock_findkeyval(pb_key_host, rq->rq.headers); |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
283 | if(hosthdr) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
284 | char *host = pool_strdup(pool, hosthdr); |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
285 | char *portstr = strchr(host, ':'); |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
286 | if(portstr) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
287 | *portstr = '\0'; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
288 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
289 | rq->host = host; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
290 | } else { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
291 | rq->host = NULL; // TODO: value from listener |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
292 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
293 | rq->port = request->connection->listener->port; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
294 | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
295 | // parse connection header |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
296 | rq->rq.rq_attr.keep_alive = (rq->rq.protv_num >= PROTOCOL_VERSION_HTTP11); |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
297 | char *conn_str = pblock_findkeyval(pb_key_connection, rq->rq.headers); |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
298 | if(conn_str) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
299 | if(!strcasecmp(conn_str, "keep-alive")) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
300 | rq->rq.rq_attr.keep_alive = 1; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
301 | } else if(!strcasecmp(conn_str, "close")) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
302 | rq->rq.rq_attr.keep_alive = 0; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
303 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
304 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
305 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
306 | // check for request body and prepare input buffer |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
307 | char *ctlen_str = pblock_findkeyval(pb_key_content_length, rq->rq.headers); |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
308 | if(ctlen_str) { |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
309 | int ctlen = atoi(ctlen_str); |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
310 | |
115
51d9a15eac98
improves logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
311 | //printf("request body length: %d\n", ctlen); |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
312 | |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
313 | netbuf *nb = request->netbuf; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
314 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
315 | // create new netbuf |
110
43a746e905f6
refactored IO system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
106
diff
changeset
|
316 | HttpStream *net_io = (HttpStream*)httpstream_new(pool, io); |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
317 | net_io->max_read = ctlen; |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
318 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
319 | sn->sn.inbuf = pool_malloc(pool, sizeof(netbuf)); |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
320 | sn->sn.inbuf->sd = net_io; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
321 | sn->sn.inbuf->pos = 0; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
322 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
323 | // prepare buffer |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
324 | int cur_input_len = nb->cursize - nb->pos; |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
325 | |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
326 | if(cur_input_len >= ctlen) { |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
327 | /* |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
328 | * all data is already in the primary input buffer |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
329 | * just link the new netbuf to the primary buffer |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
330 | */ |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
331 | sn->sn.inbuf->maxsize = ctlen; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
332 | sn->sn.inbuf->cursize = ctlen; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
333 | sn->sn.inbuf->inbuf = nb->inbuf + nb->pos; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
334 | } else { |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
335 | sn->sn.inbuf->maxsize = (ctlen > 2048) ? (2048) : (ctlen); |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
336 | sn->sn.inbuf->inbuf = pool_malloc(pool, sn->sn.inbuf->maxsize); |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
337 | |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
338 | if(cur_input_len > 0) { |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
339 | // we have read a part of the request body -> copy to netbuf |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
340 | memcpy(sn->sn.inbuf->inbuf, nb->inbuf+nb->pos, cur_input_len); |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
341 | } |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
342 | |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
343 | sn->sn.inbuf->cursize = cur_input_len; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
344 | } |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
345 | } else { |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
346 | sn->sn.inbuf = NULL; |
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
347 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
348 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
349 | // |
1 | 350 | // Send the request to the NSAPI system |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
351 | // |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
352 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
353 | // compare current and listener thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
354 | threadpool_t *lstp = request->connection->listener->threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
355 | sn->defaultpool = lstp; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
356 | if(lstp == thrpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
357 | sn->currentpool = thrpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
358 | nsapi_handle_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
359 | } else { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
360 | // execute nsapi functions on a different thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
361 | nsapi_change_threadpool(sn, rq, lstp); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
362 | } |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
363 | |
1 | 364 | return 0; |
365 | } | |
366 | ||
367 | ||
368 | ||
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
369 | void header_add(HeaderArray *hd, sstr_t name, sstr_t value) { |
1 | 370 | while(hd->len >= hd->alloc) { |
371 | if(hd->next == NULL) { | |
372 | HeaderArray *block = malloc(sizeof(HeaderArray)); | |
373 | block->next = NULL; | |
374 | block->len = 0; | |
375 | block->headers = calloc(16, sizeof(Header)); | |
376 | block->alloc = 16; | |
377 | hd->next = block; | |
378 | } | |
379 | hd = hd->next; | |
380 | } | |
381 | hd->headers[hd->len].name = name; | |
382 | hd->headers[hd->len].value = value; | |
383 | hd->len++; | |
384 | } | |
385 | ||
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
386 | void header_array_free(HeaderArray *hd) { |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
387 | HeaderArray *next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
388 | while(hd) { |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
389 | next = hd->next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
390 | free(hd->headers); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
391 | free(hd); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
392 | hd = next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
393 | } |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
394 | } |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
395 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
396 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
397 | /* |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
398 | * NSAPI Processing |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
399 | */ |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
400 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
401 | int nsapi_handle_request(NSAPISession *sn, NSAPIRequest *rq) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
402 | int r = REQ_NOACTION; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
403 | do { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
404 | switch(rq->phase) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
405 | case NSAPIAuthTrans: { |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
406 | r = nsapi_authtrans(sn, rq); |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
407 | if(r != REQ_PROCEED) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
408 | break; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
409 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
410 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
411 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
412 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
413 | case NSAPINameTrans: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
414 | //printf(">>> NameTrans\n"); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
415 | r = nsapi_nametrans(sn, rq); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
416 | if(r != REQ_PROCEED) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
417 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
418 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
419 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
420 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
421 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
422 | case NSAPIPathCheck: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
423 | //printf(">>> PathCheck\n"); |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
424 | r = nsapi_pathcheck(sn, rq); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
425 | if(r != REQ_PROCEED) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
426 | break; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
427 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
428 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
429 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
430 | } |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
431 | case NSAPIObjectType: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
432 | //printf(">>> ObjectType\n"); |
10 | 433 | r = nsapi_objecttype(sn, rq); |
434 | if(r != REQ_PROCEED) { | |
435 | break; | |
436 | } | |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
437 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
438 | nsapi_context_next_stage(&rq->context); |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
439 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
440 | case NSAPIService: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
441 | //printf(">>> Service\n"); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
442 | r = nsapi_service(sn, rq); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
443 | if(r != REQ_PROCEED) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
444 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
445 | } |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
446 | rq->phase = NSAPIAddLog; // skip NSAPIError |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
447 | nsapi_context_next_stage(&rq->context); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
448 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
449 | case NSAPIAddLog: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
450 | //printf(">>> AddLog\n"); |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
451 | r = nsapi_addlog(sn, rq); |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
452 | if(r == REQ_PROCESSING) { |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
453 | break; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
454 | } |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
455 | // finish request |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
456 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
457 | break; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
458 | } |
70
4e6e812c1d97
fixed some warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
459 | default: // should not happen, but when it does, finish the req |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
460 | case REQ_FINISH: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
461 | //printf(">>> Finish\n"); |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
462 | //r = nsapi_finish_request(sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
463 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
464 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
465 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
466 | case NSAPIError: { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
467 | //printf(">>> Error\n"); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
468 | r = nsapi_error(sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
469 | if(r == REQ_PROCEED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
470 | // restart the loop to switch to AddLog directive |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
471 | r = REQ_RESTART; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
472 | rq->phase = NSAPIAddLog; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
473 | nsapi_context_next_stage(&rq->context); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
474 | } else { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
475 | /* |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
476 | * an error occured while handling an error |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
477 | * leave loop to finish the request (without AddLog) |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
478 | */ |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
479 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
480 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
481 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
482 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
483 | } |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
484 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
485 | if(r == REQ_ABORTED) { |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
486 | // switch to NSAPIError |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
487 | rq->phase = NSAPIError; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
488 | nsapi_context_next_stage(&rq->context); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
489 | r = REQ_RESTART; |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
490 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
491 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
492 | } while (r == REQ_RESTART); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
493 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
494 | if(r != REQ_PROCESSING) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
495 | r = nsapi_finish_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
496 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
497 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
498 | return r; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
499 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
500 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
501 | int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
502 | if(rq->rq.rq_attr.keep_alive) { |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
503 | SessionHandler *sh = sn->connection->session_handler; |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
504 | sh->keep_alive(sh, sn->connection); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
505 | /* |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
506 | * keep the connection object |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
507 | * the sn->config is referenced by the connection, so we don't |
79
f48cea237ec3
fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
78
diff
changeset
|
508 | * unref it |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
509 | */ |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
510 | } else { |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
511 | connection_destroy(sn->connection); |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
512 | cfg_unref(sn->config); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
513 | } |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
514 | |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
515 | // free all memory |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
516 | free(sn->netbuf->inbuf); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
517 | free(sn->netbuf); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
518 | |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
519 | pool_destroy(sn->sn.pool); |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
520 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
521 | return 0; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
522 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
523 | |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
524 | int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
525 | HTTPObjectConfig *objconf = rq->vs->objects; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
526 | httpd_object *obj = objconf->objects[0]; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
527 | dtable *dt = object_get_dtable(obj, NSAPIAuthTrans); |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
528 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
529 | int ret = rq->context.last_req_code; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
530 | for(int i=NCX_DI(rq);i<dt->ndir;i++) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
531 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
532 | directive *d = dt->dirs[i]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
533 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
534 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
535 | |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
536 | if(ret != REQ_NOACTION) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
537 | /* |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
538 | * if a saf is still processing, we need to save the context, to |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
539 | * process this object at a later time |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
540 | */ |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
541 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
542 | // save nsapi context |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
543 | // add +1 to start next round with next function |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
544 | rq->context.dtable_index = i + 1; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
545 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
546 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
547 | return ret; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
548 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
549 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
550 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
551 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
552 | return REQ_PROCEED; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
553 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
554 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
555 | int nsapi_nametrans(NSAPISession *sn, NSAPIRequest *rq) { |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
556 | HTTPObjectConfig *objconf = rq->vs->objects; |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
557 | //printf("nsapi_nametrans\n"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
558 | httpd_objset *objset = objset_create(sn->sn.pool); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
559 | rq->rq.os = objset; |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
560 | // first object in objconf is the default object TODO: make sure it is |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
561 | objset_add_object(sn->sn.pool, objset, objconf->objects[0]); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
562 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
563 | httpd_object *obj = objset->obj[0]; // nametrans only in default object |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
564 | dtable *dt = object_get_dtable(obj, NSAPINameTrans); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
565 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
566 | // execute directives |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
567 | int ret = rq->context.last_req_code; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
568 | char *name = NULL; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
569 | char *ppath = NULL; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
570 | for(int i=NCX_DI(rq);i<dt->ndir;i++) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
571 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
572 | directive *d = dt->dirs[i]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
573 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
574 | } |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
575 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
576 | // check for name or ppath |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
577 | name = pblock_findkeyval(pb_key_name, rq->rq.vars); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
578 | ppath = pblock_findkeyval(pb_key_ppath, rq->rq.vars); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
579 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
580 | // add additional objects to the objset |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
581 | if(add_objects(objconf, objset, sn, rq, name, ppath) == REQ_ABORTED) { |
115
51d9a15eac98
improves logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
582 | log_ereport(LOG_FAILURE, "add_objects failed"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
583 | return REQ_ABORTED; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
584 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
585 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
586 | if(ret != REQ_NOACTION) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
587 | /* |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
588 | * if a saf is still processing, we need to save the context, to |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
589 | * process this object at a later time |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
590 | */ |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
591 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
592 | // save nsapi context |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
593 | // add +1 to start next round with next function |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
594 | rq->context.dtable_index = i + 1; |
117
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
595 | } else if(ret == REQ_PROCEED) { |
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
596 | char *pp = pblock_findkeyval(pb_key_ppath, rq->rq.vars); |
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
597 | pblock_kvinsert(pb_key_path, pp, strlen(pp), rq->rq.vars); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
598 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
599 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
600 | return ret; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
601 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
602 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
603 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
604 | // if no function has set the ppath var, translate it to docroot |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
605 | if(ret == REQ_NOACTION && ppath == NULL) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
606 | sstr_t docroot = rq->vs->document_root; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
607 | if(docroot.length < 1) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
608 | printf("docroot too short\n"); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
609 | return REQ_ABORTED; /* docroot too short */ |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
610 | } |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
611 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
612 | // if there is a trailing '/', remove it |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
613 | /* |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
614 | if(docroot.ptr[docroot.length - 1] == '/') { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
615 | docroot.length--; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
616 | } |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
617 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
618 | sstr_t uri = sstr(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
619 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
620 | sstr_t translated; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
621 | translated.length = docroot.length + uri.length; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
622 | translated.ptr = alloca(translated.length + 1); |
91 | 623 | translated = sstrncat(translated, 2, docroot, uri); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
624 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
625 | pblock_kvinsert( |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
626 | pb_key_ppath, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
627 | translated.ptr, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
628 | translated.length, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
629 | rq->rq.vars); |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
630 | */ |
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
631 | sstr_t uri = sstr(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); |
116
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
632 | request_set_path(docroot, uri, rq->rq.vars); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
633 | } |
116
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
634 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
635 | // TODO: remove ppath |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
636 | char *pp = pblock_findkeyval(pb_key_ppath, rq->rq.vars); |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
637 | pblock_kvinsert(pb_key_path, pp, strlen(pp), rq->rq.vars); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
638 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
639 | return REQ_PROCEED; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
640 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
641 | |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
642 | int nsapi_pathcheck(NSAPISession *sn, NSAPIRequest *rq) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
643 | //printf("nsapi_pathcheck\n"); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
644 | httpd_objset *objset = rq->rq.os; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
645 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
646 | if(NCX_OI(rq) == -1) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
647 | NCX_OI(rq) = objset->pos - 1; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
648 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
649 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
650 | int ret = rq->context.last_req_code; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
651 | for(int i=NCX_OI(rq);i>=0;i--) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
652 | httpd_object *obj = objset->obj[i]; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
653 | dtable *dt = object_get_dtable(obj, NSAPIPathCheck); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
654 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
655 | // execute directives |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
656 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
657 | if(ret == REQ_NOACTION || REQ_PROCEED) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
658 | directive *d = dt->dirs[j]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
659 | ret = nsapi_exec(d, sn, rq); |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
660 | } else { |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
661 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
662 | // save nsapi context |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
663 | rq->context.objset_index = i; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
664 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
665 | // add +1 to start next round with next function |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
666 | rq->context.dtable_index = j + 1; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
667 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
668 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
669 | return ret; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
670 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
671 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
672 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
673 | |
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
674 | return REQ_PROCEED; |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
675 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
676 | |
10 | 677 | int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
678 | //printf("nsapi_objecttype\n"); |
10 | 679 | httpd_objset *objset = rq->rq.os; |
680 | ||
681 | if(NCX_OI(rq) == -1) { | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
682 | // object index is undefined -> define correct object index |
10 | 683 | NCX_OI(rq) = objset->pos - 1; |
684 | } | |
685 | ||
686 | int ret = rq->context.last_req_code; | |
687 | for(int i=NCX_OI(rq);i>=0;i--) { | |
688 | httpd_object *obj = objset->obj[i]; | |
689 | dtable *dt = object_get_dtable(obj, NSAPIObjectType); | |
690 | ||
691 | // execute directives | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
692 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
693 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
694 | directive *d = dt->dirs[j]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
695 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
696 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
697 | |
10 | 698 | switch(ret) { |
699 | case REQ_PROCEED: { | |
700 | char *type = pblock_findkeyval( | |
701 | pb_key_content_type, | |
702 | rq->rq.srvhdrs); | |
703 | if(type == NULL) { | |
704 | ret = REQ_NOACTION; | |
705 | break; | |
706 | } | |
707 | return ret; | |
708 | } | |
709 | case REQ_PROCESSING: { | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
710 | // save nsapi context |
10 | 711 | rq->context.objset_index = i; |
712 | ||
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
713 | // add +1 to start next round with next function |
10 | 714 | rq->context.dtable_index = j + 1; |
715 | return ret; | |
716 | } | |
717 | case REQ_NOACTION: { | |
718 | break; | |
719 | } | |
720 | default: { | |
721 | return ret; | |
722 | } | |
723 | } | |
724 | } | |
725 | } | |
726 | ||
727 | /* | |
728 | * No function returned with REQ_PROCEED, but we need a content type. | |
729 | * If the path ends with a '/', we set the content type to | |
730 | * 'internal/directory' so that 'index-common' can serve the content. | |
731 | * Otherwise we set the content type to text/plain | |
732 | */ | |
733 | sstr_t path = sstr(pblock_findkeyval(pb_key_ppath, rq->rq.vars)); | |
734 | sstr_t ct; | |
735 | if(path.ptr[path.length - 1] == '/') { | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
736 | // directory |
10 | 737 | ct = sstrn("internal/directory", 18); |
738 | } else { | |
739 | ct = sstrn("text/plain", 10); | |
740 | } | |
741 | pblock_kvinsert(pb_key_content_type, ct.ptr, ct.length, rq->rq.srvhdrs); | |
742 | ||
743 | return REQ_PROCEED; | |
744 | } | |
745 | ||
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
746 | int nsapi_service(NSAPISession *sn, NSAPIRequest *rq) { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
747 | //printf("nsapi_service\n"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
748 | httpd_objset *objset = rq->rq.os; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
749 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
750 | if(NCX_OI(rq) == -1) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
751 | NCX_OI(rq) = objset->pos - 1; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
752 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
753 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
754 | int ret = rq->context.last_req_code; |
12
34aa8001ea53
Added directory index
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
10
diff
changeset
|
755 | char *content_type = NULL; |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
756 | char *method = NULL; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
757 | for(int i=NCX_OI(rq);i>=0;i--) { |
12
34aa8001ea53
Added directory index
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
10
diff
changeset
|
758 | httpd_object *obj = objset->obj[i]; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
759 | dtable *dt = object_get_dtable(obj, NSAPIService); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
760 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
761 | // execute directives |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
762 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
763 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
764 | directive *d = dt->dirs[j]; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
765 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
766 | // check type parameter |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
767 | char *dtp = pblock_findkeyval(pb_key_type, d->param); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
768 | if(dtp) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
769 | // type parameter for directive |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
770 | if(!content_type) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
771 | content_type = pblock_findkeyval( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
772 | pb_key_content_type, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
773 | rq->rq.srvhdrs); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
774 | } |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
775 | // compare types |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
776 | if(strcmp(dtp, content_type) != 0) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
777 | continue; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
778 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
779 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
780 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
781 | // check method parameter |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
782 | char *dmt = pblock_findkeyval(pb_key_method, d->param); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
783 | if(dmt) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
784 | if(!method) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
785 | method = pblock_findkeyval(pb_key_method, rq->rq.reqpb); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
786 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
787 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
788 | if(!method_match(dmt, method)) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
789 | continue; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
790 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
791 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
792 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
793 | // execute the saf |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
794 | ret = nsapi_exec(d, sn, rq); |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
795 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
796 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
797 | if(ret != REQ_NOACTION) { |
80
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
798 | if(ret == REQ_PROCEED) { |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
799 | /* |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
800 | * flush buffer and add termination if chunked encoding |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
801 | * is enabled |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
802 | */ |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
803 | net_finish(sn->sn.csd); |
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
804 | } else if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
805 | // save nsapi context |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
806 | rq->context.objset_index = i; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
807 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
808 | // add +1 to start next round with next function |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
809 | rq->context.dtable_index = j + 1; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
810 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
811 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
812 | return ret; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
813 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
814 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
815 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
816 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
817 | return ret; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
818 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
819 | |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
820 | int nsapi_error(NSAPISession *sn, NSAPIRequest *rq) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
821 | //printf("nsapi_error\n"); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
822 | httpd_objset *objset = rq->rq.os; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
823 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
824 | if(NCX_OI(rq) == -1) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
825 | NCX_OI(rq) = objset->pos - 1; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
826 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
827 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
828 | int ret = rq->context.last_req_code; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
829 | for(int i=NCX_OI(rq);i>=0;i--) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
830 | httpd_object *obj = objset->obj[i]; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
831 | dtable *dt = object_get_dtable(obj, NSAPIError); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
832 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
833 | // execute directives |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
834 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
835 | if(ret == REQ_NOACTION) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
836 | directive *d = dt->dirs[j]; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
837 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
838 | // check status code parameter |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
839 | char *status = pblock_findkeyval(pb_key_type, d->param); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
840 | if(status) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
841 | int statuscode = atoi(status); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
842 | if(statuscode != rq->rq.status_num) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
843 | continue; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
844 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
845 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
846 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
847 | // execute the saf |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
848 | ret = nsapi_exec(d, sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
849 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
850 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
851 | if(ret == REQ_ABORTED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
852 | // if an error directive fails, we use the default |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
853 | // error handler |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
854 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
855 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
856 | if(ret != REQ_NOACTION) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
857 | if(ret == REQ_PROCEED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
858 | /* |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
859 | * flush buffer and add termination if chunked encoding |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
860 | * is enabled |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
861 | */ |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
862 | net_finish(sn->sn.csd); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
863 | } else if(ret == REQ_PROCESSING) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
864 | // save nsapi context |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
865 | rq->context.objset_index = i; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
866 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
867 | // add +1 to start next round with next function |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
868 | rq->context.dtable_index = j + 1; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
869 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
870 | return ret; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
871 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
872 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
873 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
874 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
875 | if(ret != REQ_PROCEED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
876 | // default error handler |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
877 | nsapi_error_request((Session*)sn, (Request*)rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
878 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
879 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
880 | return ret; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
881 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
882 | |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
883 | int nsapi_addlog(NSAPISession *sn, NSAPIRequest *rq) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
884 | //printf("nsapi_addlog\n"); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
885 | httpd_objset *objset = rq->rq.os; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
886 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
887 | if(NCX_OI(rq) == -1) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
888 | NCX_OI(rq) = objset->pos - 1; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
889 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
890 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
891 | int ret = rq->context.last_req_code; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
892 | for(int i=NCX_OI(rq);i>=0;i--) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
893 | httpd_object *obj = objset->obj[i]; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
894 | dtable *dt = object_get_dtable(obj, NSAPIAddLog); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
895 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
896 | // execute directives |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
897 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
898 | if(ret == REQ_NOACTION) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
899 | directive *d = dt->dirs[j]; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
900 | ret = nsapi_exec(d, sn, rq); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
901 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
902 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
903 | if(ret != REQ_NOACTION) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
904 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
905 | // save nsapi context |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
906 | rq->context.objset_index = i; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
907 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
908 | // add +1 to start next round with next function |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
909 | rq->context.dtable_index = j + 1; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
910 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
911 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
912 | return ret; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
913 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
914 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
915 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
916 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
917 | return REQ_PROCEED; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
918 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
919 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
920 | struct _tpd_data { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
921 | NSAPISession *sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
922 | NSAPIRequest *rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
923 | directive *directive; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
924 | threadpool_t *threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
925 | }; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
926 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
927 | int nsapi_exec(directive *d, NSAPISession *sn, NSAPIRequest *rq) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
928 | // TODO: condition |
83
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
929 | if(d->cond) { |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
930 | if(!condition_evaluate(d->cond, (Session*)sn, (Request*)rq)) { |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
931 | return REQ_NOACTION; |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
932 | } |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
933 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
934 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
935 | char *poolname = pblock_findkeyval(pb_key_pool, d->param); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
936 | if(poolname) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
937 | threadpool_t *pool = get_threadpool(sstr(poolname)); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
938 | if(pool && pool != sn->currentpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
939 | // execute directive in different thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
940 | return nsapi_exec_tp(d, sn, rq, pool); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
941 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
942 | } else if(sn->currentpool != sn->defaultpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
943 | // if no pool is set, use always the default thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
944 | return nsapi_exec_tp(d, sn, rq, sn->defaultpool); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
945 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
946 | |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
947 | return SAF_EXEC(d->func, d->param, (Session*)sn, (Request*)rq); |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
948 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
949 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
950 | int nsapi_exec_tp( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
951 | directive *d, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
952 | NSAPISession *sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
953 | NSAPIRequest *rq, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
954 | threadpool_t *pool) |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
955 | { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
956 | struct _tpd_data *data = malloc(sizeof(struct _tpd_data)); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
957 | if(data == NULL) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
958 | // TODO: set error |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
959 | return REQ_ABORTED; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
960 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
961 | data->sn = sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
962 | data->rq = rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
963 | data->directive = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
964 | data->threadpool = pool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
965 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
966 | sn->currentpool = pool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
967 | threadpool_run(pool, thrpool_exec, data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
968 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
969 | return REQ_PROCESSING; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
970 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
971 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
972 | void nsapi_function_return(Session *session, Request *request, int ret) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
973 | NSAPISession *sn = (NSAPISession*)session; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
974 | NSAPIRequest *rq = (NSAPIRequest*)request; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
975 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
976 | rq->context.last_req_code = ret; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
977 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
978 | if(sn->currentpool != sn->defaultpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
979 | nsapi_change_threadpool(sn, rq, sn->defaultpool); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
980 | } else { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
981 | nsapi_handle_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
982 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
983 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
984 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
985 | void nsapi_change_threadpool( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
986 | NSAPISession *sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
987 | NSAPIRequest *rq, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
988 | threadpool_t *thrpool) |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
989 | { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
990 | struct _tpd_data *data = malloc(sizeof(struct _tpd_data)); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
991 | data->sn = sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
992 | data->rq = rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
993 | data->threadpool = thrpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
994 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
995 | threadpool_run(thrpool, thrpool_change, data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
996 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
997 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
998 | void* thrpool_exec(void *d) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
999 | struct _tpd_data *data = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1000 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1001 | data->sn->currentpool = data->threadpool; |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
1002 | int r = SAF_EXEC( |
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
1003 | data->directive->func, |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1004 | data->directive->param, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1005 | (Session*)data->sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1006 | (Request*)data->rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1007 | |
116
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
1008 | nsapi_function_return((Session*)data->sn, (Request*)data->rq, r); |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1009 | free(data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1010 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1011 | return NULL; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1012 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1013 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1014 | void* thrpool_change(void *d) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1015 | struct _tpd_data *data = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1016 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1017 | data->sn->currentpool = data->threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1018 | nsapi_handle_request(data->sn, data->rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1019 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1020 | free(data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1021 | return NULL; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1022 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1023 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1024 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1025 | /* |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1026 | * checks if the method matches the cmp string |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1027 | * the format of cmp is a single method string or a list of methods |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1028 | * (method1|method2|method3|...) |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1029 | */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1030 | int method_match(char *cmp, char *method) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1031 | if(cmp[0] != '(') { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1032 | /* not a list of methods, so just compare the 2 strings */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1033 | if(!strcmp(cmp, method)) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1034 | return 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1035 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1036 | } else if(cmp[0] == 0) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1037 | /* empty string */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1038 | return 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1039 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1040 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1041 | size_t method_len = strlen(method); |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1042 | size_t last_pos = 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1043 | cmp++; /* skip '(' */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1044 | for(int i=0;cmp[i]!=0;i++) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1045 | char c = cmp[i]; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1046 | if(c == '|' || c == ')') { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1047 | size_t len = i - last_pos; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1048 | if(len == method_len) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1049 | char *cp = cmp + last_pos; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1050 | if(!memcmp(cp, method, len)) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1051 | return 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1052 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1053 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1054 | last_pos = i + 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1055 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1056 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1057 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1058 | return 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1059 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1060 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1061 | /* |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1062 | * adds objects with specific name or path to the httpd_objset |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1063 | */ |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1064 | int add_objects( |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1065 | HTTPObjectConfig *objs, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1066 | httpd_objset *os, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1067 | NSAPISession *sn, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1068 | NSAPIRequest *rq, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1069 | char *name, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1070 | char *path) |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1071 | { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1072 | /* first, add all objects with a matching path */ |
10 | 1073 | /* TODO */ |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1074 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1075 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1076 | /* add object with object with matching name */ |
10 | 1077 | if(name == NULL) { |
1078 | return REQ_PROCEED; | |
1079 | } | |
1080 | ||
1081 | for(int i=0;i<objs->nobj;i++) { | |
1082 | httpd_object *obj = objs->objects[i]; | |
1083 | ||
1084 | if(obj->name && !strcmp(name, obj->name)) { | |
1085 | objset_add_object(sn->sn.pool, os, obj); | |
1086 | } | |
1087 | } | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1088 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1089 | return REQ_PROCEED; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1090 | } |