Thu, 19 Sep 2024 22:17:24 +0200
log event free
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" |
159
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
43 | #include "event.h" |
19
d680536f8c2f
Added configuration manager
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
44 | #include "httplistener.h" |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
45 | #include "func.h" |
44
3da1f7b6847f
added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
46 | #include "error.h" |
1 | 47 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
48 | void http_request_init(HTTPRequest *req) { |
180
98462e878ca7
fixes crash with broken http requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
168
diff
changeset
|
49 | memset(req, 0, sizeof(HTTPRequest)); |
1 | 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 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
67 | cxmutstr http_request_get_abspath(HTTPRequest *req) { |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
68 | cxmutstr uri = req->uri; |
101
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; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
73 | } else if(cx_strprefix(cx_strcast(uri), (cxstring)CX_STR("http://"))) { |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
74 | i = 7; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
75 | } else if(cx_strprefix(cx_strcast(uri), (cxstring)CX_STR("https://"))) { |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
76 | i = 8; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
77 | } else if(!cx_strcmp(cx_strcast(uri), (cxstring)CX_STR("*"))) { |
101
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] == '/') { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
83 | return cx_strsubs_m(uri, i); |
101
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 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
87 | return (cxmutstr){ "/", 1 }; |
101
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 | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
90 | NSAPISession* nsapisession_create(pool_handle_t *pool) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
91 | NSAPISession *sn = pool_malloc(pool, sizeof(NSAPISession)); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
92 | if(!sn) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
93 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
94 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
95 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
96 | ZERO(sn, sizeof(NSAPISession)); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
97 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
98 | sn->sn.pool = pool; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
99 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
100 | sn->sn.client = pblock_create_pool(sn->sn.pool, 8); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
101 | if(!sn->sn.client) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
102 | pool_free(pool, sn); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
103 | return NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
104 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
105 | sn->sn.fill = 1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
106 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
107 | return sn; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
108 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
109 | |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
110 | int nsapisession_setconnection(NSAPISession *sn, Connection *conn, netbuf *inbuf, IOStream **io) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
111 | SessionHandler *sh = conn->session_handler; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
112 | WSBool ssl; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
113 | IOStream *sio = sh->create_iostream(sh, conn, sn->sn.pool, &ssl); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
114 | if(!sio) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
115 | return 1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
116 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
117 | *io = sio; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
118 | IOStream *http = httpstream_new(sn->sn.pool, sio); |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
119 | if(!http) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
120 | return 1; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
121 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
122 | sn->connection = conn; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
123 | sn->netbuf = inbuf; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
124 | sn->sn.csd = http; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
125 | sn->sn.ssl = ssl; |
332
6f82ede01e1c
simplify request input buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
272
diff
changeset
|
126 | sn->sn.inbuf = inbuf; |
6f82ede01e1c
simplify request input buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
272
diff
changeset
|
127 | sn->sn.inbuf->sd = http; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
128 | return 0; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
129 | } |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
130 | |
159
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
131 | int handle_request(HTTPRequest *request, threadpool_t *thrpool, EventHandler *ev) { |
1 | 132 | // handle nsapi request |
154
6394ce09889a
adds set-variable saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
133 | |
1 | 134 | // create pool |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
135 | pool_handle_t *pool = pool_create(); |
544
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
136 | if(!pool) { |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
137 | log_ereport(LOG_FAILURE, "cannot create new memory pool for http request"); |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
138 | return 1; |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
139 | } |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
140 | |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
141 | int ret = nsapi_start_request(request, thrpool, ev, pool); |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
142 | if(ret) { |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
143 | pool_destroy(pool); |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
144 | } |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
145 | return ret; |
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
146 | } |
1 | 147 | |
544
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
148 | int nsapi_start_request(HTTPRequest *request, threadpool_t *thrpool, EventHandler *ev, pool_handle_t *pool) { |
557
e35829a3a6d8
add sessionhandler debug logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
544
diff
changeset
|
149 | log_ereport(LOG_DEBUG, "trace reqid: %016llx nsapi_start_request", (unsigned long long int)request->connection->id); |
e35829a3a6d8
add sessionhandler debug logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
544
diff
changeset
|
150 | |
1 | 151 | // create nsapi data structures |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
152 | NSAPISession *sn = nsapisession_create(pool); |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
153 | if(sn == NULL) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
154 | /* TODO: error */ |
544
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
155 | return 1; |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
156 | } |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
157 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
158 | 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
|
159 | if(rq == NULL) { |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
160 | /* TODO: error */ |
544
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
161 | return 1; |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
162 | } |
141 | 163 | ZERO(rq, sizeof(NSAPIRequest)); |
102
136a76e293b5
added etag and conditional request implementation from Open Web Server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
101
diff
changeset
|
164 | rq->rq.req_start = request->req_start; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
165 | rq->phase = NSAPIAuthTrans; |
1 | 166 | |
167 | // fill session structure | |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
168 | IOStream *io = NULL; |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
169 | if(nsapisession_setconnection(sn, request->connection, request->netbuf, &io)) { |
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
170 | // TODO: error |
544
27684460629f
fix memory leak in case handle_request fails (some illegal requests)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
531
diff
changeset
|
171 | return 1; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
172 | } |
38
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
173 | |
159
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
174 | if(!ev) { |
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
175 | ev = ev_instance(get_default_event_handler()); |
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
176 | } |
9ba9f8befa80
makes EventHandler public
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
154
diff
changeset
|
177 | sn->sn.ev = ev; |
211
2160585200ac
add propfind/proppatch parser and first iteration of the new webdav api
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
193
diff
changeset
|
178 | |
38
d07810b02147
added ldap authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
37
diff
changeset
|
179 | // the session needs the current server configuration |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
180 | sn->config = request->connection->listener->cfg; |
1 | 181 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
182 | // add ip to sn->client pblock |
396
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
183 | if(request->connection->addr_type == CONN_ADDR_IPV4) { |
397
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
184 | char ip_str[INET_ADDRSTRLEN]; |
396
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
185 | if(inet_ntop( |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
186 | AF_INET, |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
187 | &request->connection->address.address_v4.sin_addr, |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
188 | ip_str, |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
189 | INET_ADDRSTRLEN) != NULL) |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
190 | { |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
191 | pblock_kvinsert(pb_key_ip, ip_str, INET_ADDRSTRLEN, sn->sn.client); |
77d81f2bb9f7
add initial ipv6 support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
192 | } |
397
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
193 | } else if(request->connection->addr_type == CONN_ADDR_IPV6) { |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
194 | char ip_str[INET6_ADDRSTRLEN]; |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
195 | if(inet_ntop( |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
196 | AF_INET6, |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
197 | &request->connection->address.address_v6.sin6_addr, |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
198 | ip_str, |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
199 | INET6_ADDRSTRLEN) != NULL) |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
200 | { |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
201 | pblock_kvinsert(pb_key_ip, ip_str, INET6_ADDRSTRLEN, sn->sn.client); |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
202 | } |
9
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
203 | } |
30e51941a673
Added mod_jk dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
8
diff
changeset
|
204 | |
1 | 205 | // init NSAPI request structure |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
206 | if(request_initialize(pool, request, rq) != 0) { |
60
feb2f1e115c6
improved logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
59
diff
changeset
|
207 | log_ereport(LOG_FAILURE, "Cannot initialize request structure"); |
1 | 208 | return 1; |
209 | } | |
210 | ||
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
211 | // set default virtual server |
19
d680536f8c2f
Added configuration manager
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
18
diff
changeset
|
212 | rq->vs = request->connection->listener->default_vs.vs; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
213 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
214 | // Pass request line as "clf-request" |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
215 | // remove \r\n |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
216 | cxmutstr clfreq = request->request_line; |
180
98462e878ca7
fixes crash with broken http requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
168
diff
changeset
|
217 | while(clfreq.length > 0 && clfreq.ptr[clfreq.length - 1] < 33) { |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
218 | clfreq.length--; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
219 | } |
1 | 220 | pblock_kvinsert( |
221 | pb_key_clf_request, | |
180
98462e878ca7
fixes crash with broken http requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
168
diff
changeset
|
222 | clfreq.ptr, |
98462e878ca7
fixes crash with broken http requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
168
diff
changeset
|
223 | clfreq.length, |
1 | 224 | rq->rq.reqpb); |
225 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
226 | // Pass method as "method" in reqpb, and also as method_num |
1 | 227 | pblock_kvinsert( |
228 | pb_key_method, | |
229 | request->method.ptr, | |
230 | request->method.length, | |
231 | rq->rq.reqpb); | |
232 | // TODO: method num | |
233 | //rqRq.rq.method_num = rqHdr->GetMethodNumber(); | |
234 | //PR_ASSERT(rqRq.rq.method_num != -1 || iStatus); | |
235 | ||
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
236 | // Pass protocol as "protocol" in reqpb, and also in protv_num |
1 | 237 | pblock_kvinsert( |
238 | pb_key_protocol, | |
239 | request->httpv.ptr, | |
240 | request->httpv.length, | |
241 | rq->rq.reqpb); | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
242 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
243 | if(!cx_strcmp(cx_strcast(request->httpv), (cxstring)CX_STR("HTTP/1.1"))) { |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
244 | rq->rq.protv_num = PROTOCOL_VERSION_HTTP11; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
245 | } else if(!cx_strcmp(cx_strcast(request->httpv), (cxstring)CX_STR("HTTP/1.0"))) { |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
246 | 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
|
247 | } else { |
136
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
248 | // invalid protocol version - abort |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
249 | log_ereport( |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
250 | LOG_FAILURE, |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
251 | "invalid protocol version: %.*s", |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
252 | (int)request->httpv.length, |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
253 | request->httpv.ptr); |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
254 | return 1; |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
255 | } |
1 | 256 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
257 | /* |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
258 | * 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
|
259 | */ |
261
f2c772336ecd
add some references to issues
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
260 | // TODO: check for '#' #72 |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
261 | cxmutstr absPath = http_request_get_abspath(request); |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
262 | if(!absPath.ptr) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
263 | // TODO: error msg |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
264 | return 1; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
265 | } else if(absPath.ptr[0] == '*') { |
261
f2c772336ecd
add some references to issues
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
235
diff
changeset
|
266 | // TODO: implement global OPTIONS #71 |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
267 | return 1; |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
268 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
269 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
270 | 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
|
271 | if(request->uri.ptr[i] == '?') { |
495
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
272 | cxmutstr query; |
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
273 | query.ptr = NULL; |
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
274 | query.length = 0; |
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
275 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
276 | /* split uri in path and query */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
277 | if(absPath.length > i + 2) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
278 | query.length = absPath.length - i - 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
279 | query.ptr = absPath.ptr + i + 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
280 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
281 | absPath.length = i; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
282 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
283 | // Pass any query as 'query' in reqpb |
495
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
284 | if(query.length > 0) { |
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
285 | pblock_kvinsert( |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
286 | pb_key_query, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
287 | query.ptr, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
288 | query.length, |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
289 | rq->rq.reqpb); |
495
855a915472ff
don't add empty query to rq->reqpb
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
460
diff
changeset
|
290 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
291 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
292 | break; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
293 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
294 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
295 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
296 | // Get abs_path part of request URI, and canonicalize the path |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
297 | cxmutstr orig_path = absPath; |
1 | 298 | absPath.ptr = util_canonicalize_uri( |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
299 | pool, |
1 | 300 | absPath.ptr, |
301 | absPath.length, | |
302 | (int*)&absPath.length); | |
168
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
303 | if(!absPath.ptr) { |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
304 | log_ereport( |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
305 | LOG_WARN, |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
306 | "invalid request path: {%.*s}", |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
307 | (int)orig_path.length, |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
308 | orig_path.ptr); |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
309 | // TODO: 400 bad request |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
310 | return 1; |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
311 | } |
1 | 312 | |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
313 | // Decode the abs_path |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
314 | if(util_uri_unescape_strict(absPath.ptr)) { |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
315 | // 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
|
316 | pblock_kvinsert( |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
317 | pb_key_uri, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
318 | absPath.ptr, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
319 | absPath.length, |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
320 | rq->rq.reqpb); |
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
321 | } else { |
168
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
322 | log_ereport( |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
323 | LOG_WARN, |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
324 | "uri unescape failed: {%.*s}", |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
325 | (int)absPath.length, |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
326 | absPath.ptr); |
5c752979bfd6
fixes crash on broken urls
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
327 | // TODO: 400 bad request |
59
ab25c0a231d0
some fixes and new public APIs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
54
diff
changeset
|
328 | 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
|
329 | } |
1 | 330 | |
331 | // 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
|
332 | int hlen = request->headers->len; |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
333 | HeaderArray *ha = request->headers; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
334 | for(int i=0;i<=hlen;i++) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
335 | if(i == hlen) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
336 | ha = ha->next; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
337 | if(ha == NULL) { |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
338 | break; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
339 | } |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
340 | i = 0; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
341 | hlen = ha->len; |
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
342 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
343 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
344 | Header header = ha->headers[i]; |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
345 | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
346 | 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
|
347 | header.name.ptr[0] += 32; |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
348 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
349 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
350 | // change to lower case |
133
87b405d61f64
improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
351 | for(int j=0;j<header.name.length;j++) { |
87b405d61f64
improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
352 | if(header.name.ptr[j] > 64 && header.name.ptr[j] < 97) { |
87b405d61f64
improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
353 | header.name.ptr[j] += 32; |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
354 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
355 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
356 | |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
357 | pblock_nvlinsert( |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
358 | header.name.ptr, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
359 | header.name.length, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
360 | header.value.ptr, |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
361 | header.value.length, |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
362 | rq->rq.headers); |
7
3c2ed7a7a5fd
request and response header now used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
6
diff
changeset
|
363 | } |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
364 | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
365 | // get host and port |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
366 | 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
|
367 | if(hosthdr) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
368 | char *host = pool_strdup(pool, hosthdr); |
397
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
369 | char *portstr = NULL; |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
370 | if(host[0] != '[') { |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
371 | portstr = strchr(host, ':'); |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
372 | } else { |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
373 | char *v6end = strchr(host, ']'); |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
374 | if(v6end) { |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
375 | portstr = strchr(v6end, ':'); |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
376 | } |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
377 | } |
f202a655f4c2
convert ipv6 addr to string
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
396
diff
changeset
|
378 | |
121
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
379 | if(portstr) { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
380 | *portstr = '\0'; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
381 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
382 | rq->host = host; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
383 | } else { |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
384 | rq->host = NULL; // TODO: value from listener |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
385 | } |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
386 | rq->port = request->connection->listener->port; |
a881dc866e23
adds more CGI stuff
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
117
diff
changeset
|
387 | |
138
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
388 | if(rq->host) { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
389 | VirtualServer *vs = cxMapGet(sn->config->host_vs, cx_hash_key_str(rq->host)); |
138
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
390 | if(vs) { |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
391 | rq->vs = vs; |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
392 | } else { |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
393 | log_ereport( |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
394 | LOG_VERBOSE, |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
395 | "Unkown host '%s': using default virtual server", |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
396 | rq->host); |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
397 | } |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
398 | } |
06619bbd14ef
using host header to select virtual server
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
399 | |
101
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
400 | // parse connection header |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
401 | 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
|
402 | 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
|
403 | if(conn_str) { |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
404 | 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
|
405 | 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
|
406 | } 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
|
407 | 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
|
408 | } |
7fbcdbad0baa
added support for absolute URIs and improved keep alive
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
96
diff
changeset
|
409 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
410 | |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
411 | // check for request body and prepare input buffer |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
412 | 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
|
413 | if(ctlen_str) { |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
414 | int64_t ctlen; |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
415 | if(util_strtoint(ctlen_str, &ctlen)) { |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
416 | netbuf *nb = sn->netbuf; |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
417 | HttpStream *net_io = (HttpStream*)sn->sn.csd; |
354
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
418 | net_io->read_eof = WS_FALSE; |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
419 | |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
420 | // how many bytes are already read and in the buffer |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
421 | int cur_input_available = nb->cursize - nb->pos; |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
422 | |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
423 | if(cur_input_available >= ctlen) { |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
424 | // we have the whole request body in the buffer and |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
425 | // maybe even more |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
426 | // no more read from the socket is necessary to get the body, |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
427 | // therefore disable it |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
428 | net_io->max_read = 0; |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
429 | } else { |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
430 | // read still required to get the complete request body |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
431 | net_io->max_read = ctlen - cur_input_available; |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
432 | } |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
433 | //printf("request body length: %d\n", ctlen); |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
434 | } // else: should we abort? |
8
f4d56bf9de40
Added request body reader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
7
diff
changeset
|
435 | } |
333
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
436 | char *transfer_encoding = pblock_findkeyval(pb_key_transfer_encoding, rq->rq.headers); |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
437 | if(transfer_encoding) { |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
438 | if(!strcmp(transfer_encoding, "chunked")) { |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
439 | netbuf *nb = sn->netbuf; |
449
a28a5ccc894b
improve http listener migration / shutdown of old listener
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
448
diff
changeset
|
440 | // a separate buffer is required for reading chunked transfer enc |
448
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
441 | sn->buffer = pool_malloc(pool, nb->maxsize); |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
442 | if(!sn->buffer) { |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
443 | // TODO: error 500 |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
444 | return 1; |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
445 | } |
449
a28a5ccc894b
improve http listener migration / shutdown of old listener
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
448
diff
changeset
|
446 | |
a28a5ccc894b
improve http listener migration / shutdown of old listener
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
448
diff
changeset
|
447 | // copy remaining bytes from inbuf to the additional buffer |
448
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
448 | if(nb->cursize - nb->pos > 0) { |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
449 | memcpy(sn->buffer, nb->inbuf, nb->cursize); |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
450 | } |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
451 | |
333
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
452 | sn->pos = nb->pos; |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
453 | sn->cursize = nb->cursize; |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
454 | |
449
a28a5ccc894b
improve http listener migration / shutdown of old listener
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
448
diff
changeset
|
455 | // clear inbuf |
448
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
456 | nb->pos = 0; |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
457 | nb->cursize = 0; |
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
458 | |
333
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
459 | if(httpstream_enable_chunked_read(sn->sn.csd, sn->buffer, nb->maxsize, &sn->cursize, &sn->pos)) { |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
460 | // TODO: error 500 |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
461 | return 1; |
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
462 | } |
448
02b003f7560c
use separate buffer for chunked transfer encoding, not inbuf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
415
diff
changeset
|
463 | } // else: TODO: unknown transfer encoding error |
333
bb536d4bc174
first semi-functional implementation of chunked transfer encoding for request bodies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
332
diff
changeset
|
464 | } |
26
37ff8bf54b89
Minimal webdav support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
24
diff
changeset
|
465 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
466 | // |
1 | 467 | // Send the request to the NSAPI system |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
468 | // |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
469 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
470 | // compare current and listener thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
471 | threadpool_t *lstp = request->connection->listener->threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
472 | sn->defaultpool = lstp; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
473 | if(lstp == thrpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
474 | sn->currentpool = thrpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
475 | nsapi_handle_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
476 | } else { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
477 | // execute nsapi functions on a different thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
478 | nsapi_change_threadpool(sn, rq, lstp); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
479 | } |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
480 | |
1 | 481 | return 0; |
482 | } | |
483 | ||
484 | ||
485 | ||
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
486 | void header_add(HeaderArray *hd, cxmutstr name, cxmutstr value) { |
1 | 487 | while(hd->len >= hd->alloc) { |
488 | if(hd->next == NULL) { | |
489 | HeaderArray *block = malloc(sizeof(HeaderArray)); | |
490 | block->next = NULL; | |
491 | block->len = 0; | |
492 | block->headers = calloc(16, sizeof(Header)); | |
493 | block->alloc = 16; | |
494 | hd->next = block; | |
495 | } | |
496 | hd = hd->next; | |
497 | } | |
498 | hd->headers[hd->len].name = name; | |
499 | hd->headers[hd->len].value = value; | |
500 | hd->len++; | |
501 | } | |
502 | ||
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
503 | void header_array_free(HeaderArray *hd) { |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
504 | HeaderArray *next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
505 | while(hd) { |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
506 | next = hd->next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
507 | free(hd->headers); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
508 | free(hd); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
509 | hd = next; |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
510 | } |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
511 | } |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
512 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
513 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
514 | /* |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
515 | * NSAPI Processing |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
516 | */ |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
517 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
518 | int nsapi_handle_request(NSAPISession *sn, NSAPIRequest *rq) { |
558
0e79e17c70e2
improve sessionhandler trace logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
557
diff
changeset
|
519 | log_ereport(LOG_DEBUG, "trace reqid: %016llx nsapi_handle_request %d", (unsigned long long int)sn->connection->id, rq->phase); |
557
e35829a3a6d8
add sessionhandler debug logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
544
diff
changeset
|
520 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
521 | int r = REQ_NOACTION; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
522 | do { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
523 | switch(rq->phase) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
524 | case NSAPIAuthTrans: { |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
525 | r = nsapi_authtrans(sn, rq); |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
526 | if(r != REQ_PROCEED) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
527 | break; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
528 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
529 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
530 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
531 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
532 | case NSAPINameTrans: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
533 | //printf(">>> NameTrans\n"); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
534 | r = nsapi_nametrans(sn, rq); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
535 | if(r != REQ_PROCEED) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
536 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
537 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
538 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
539 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
540 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
541 | case NSAPIPathCheck: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
542 | //printf(">>> PathCheck\n"); |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
543 | r = nsapi_pathcheck(sn, rq); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
544 | if(r != REQ_PROCEED) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
545 | break; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
546 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
547 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
548 | nsapi_context_next_stage(&rq->context); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
549 | } |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
550 | case NSAPIObjectType: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
551 | //printf(">>> ObjectType\n"); |
10 | 552 | r = nsapi_objecttype(sn, rq); |
553 | if(r != REQ_PROCEED) { | |
554 | break; | |
555 | } | |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
556 | rq->phase++; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
557 | nsapi_context_next_stage(&rq->context); |
5
dbc01588686e
Added parser for obj.conf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
3
diff
changeset
|
558 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
559 | case NSAPIService: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
560 | //printf(">>> Service\n"); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
561 | r = nsapi_service(sn, rq); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
562 | if(r != REQ_PROCEED) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
563 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
564 | } |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
565 | rq->phase = NSAPIAddLog; // skip NSAPIError |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
566 | nsapi_context_next_stage(&rq->context); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
567 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
568 | case NSAPIAddLog: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
569 | //printf(">>> AddLog\n"); |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
570 | r = nsapi_addlog(sn, rq); |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
571 | if(r == REQ_PROCESSING) { |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
572 | break; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
573 | } |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
574 | // finish request |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
575 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
576 | break; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
577 | } |
70
4e6e812c1d97
fixed some warnings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
61
diff
changeset
|
578 | 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
|
579 | case REQ_FINISH: { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
580 | //printf(">>> Finish\n"); |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
581 | //r = nsapi_finish_request(sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
582 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
583 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
584 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
585 | case NSAPIError: { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
586 | //printf(">>> Error\n"); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
587 | r = nsapi_error(sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
588 | if(r == REQ_PROCEED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
589 | // 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
|
590 | r = REQ_RESTART; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
591 | rq->phase = NSAPIAddLog; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
592 | nsapi_context_next_stage(&rq->context); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
593 | } else { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
594 | /* |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
595 | * 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
|
596 | * 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
|
597 | */ |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
598 | r = REQ_PROCEED; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
599 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
600 | } |
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 | } |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
603 | |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
604 | if(r == REQ_ABORTED) { |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
605 | // switch to NSAPIError |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
606 | rq->phase = NSAPIError; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
607 | nsapi_context_next_stage(&rq->context); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
608 | r = REQ_RESTART; |
35
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
609 | } |
4417619a9bbd
using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
26
diff
changeset
|
610 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
611 | } while (r == REQ_RESTART); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
612 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
613 | if(r != REQ_PROCESSING) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
614 | r = nsapi_finish_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
615 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
616 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
617 | return r; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
618 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
619 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
620 | int nsapi_finish_request(NSAPISession *sn, NSAPIRequest *rq) { |
460
b9a447b02046
resourcepool_free should remove the resource from the request resource cache
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
449
diff
changeset
|
621 | rq->finished = TRUE; |
272
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
622 | request_free_resources(sn, rq); |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
623 | |
557
e35829a3a6d8
add sessionhandler debug logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
544
diff
changeset
|
624 | log_ereport(LOG_DEBUG, "trace reqid: %016llx nsapi_finish_request", (unsigned long long int)sn->connection->id); |
e35829a3a6d8
add sessionhandler debug logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
544
diff
changeset
|
625 | |
354
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
626 | WSBool read_stream_eof = httpstream_eof(sn->sn.csd); |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
627 | if(!read_stream_eof) { |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
628 | log_ereport(LOG_WARN, "request input stream not closed"); |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
629 | // TODO: clean stream |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
630 | rq->rq.rq_attr.keep_alive = 0; // workaround |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
631 | } |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
632 | if(sn->pos < sn->cursize) { |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
633 | log_ereport(LOG_WARN, "nsapi_finish_request: TODO: remaining bytes in buffer"); |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
634 | // TODO: reuse buffer in next request |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
635 | rq->rq.rq_attr.keep_alive = 0; // workaround |
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
636 | } |
361
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
637 | |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
638 | if(rq->rq.senthdrs) { |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
639 | // flush buffer and add termination if chunked encoding |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
640 | // is enabled |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
641 | net_finish(sn->sn.csd); |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
642 | } else { |
360
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
643 | // why was no response sent? |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
644 | // something must have gone wrong |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
645 | // terminate the session |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
646 | char *clf_req = pblock_findkeyval(pb_key_clf_request, rq->rq.reqpb); |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
647 | log_ereport(LOG_WARN, "nsapi_finish_request: no response header: request: %s", clf_req); |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
648 | rq->rq.rq_attr.keep_alive = 0; |
79ddd772e807
check if service SAFs sent a response, terminate connection in case no response was sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
649 | } |
354
017eda1be105
add missing HttpStream initializations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
339
diff
changeset
|
650 | |
407
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
651 | char *response_content_length = pblock_findkeyval(pb_key_content_length, rq->rq.srvhdrs); |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
652 | int64_t response_ctlen; |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
653 | if(response_content_length && util_strtoint(response_content_length, &response_ctlen)) { |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
654 | int64_t w = httpstream_written(sn->sn.csd); |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
655 | if(w != response_ctlen) { |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
656 | log_ereport(LOG_WARN, "nsapi_finish_request: content-length != number of bytes written"); |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
657 | rq->rq.rq_attr.keep_alive = 0; // fatal io error, we can not safely reuse the connection |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
658 | } |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
659 | } |
78af44222463
close connection if content-length != number of bytes written
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
397
diff
changeset
|
660 | |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
661 | if(rq->rq.rq_attr.keep_alive) { |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
662 | SessionHandler *sh = sn->connection->session_handler; |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
663 | sh->keep_alive(sh, sn->connection); |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
664 | /* |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
665 | * keep the connection object |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
666 | * 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
|
667 | * unref it |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
668 | */ |
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
669 | } else { |
558
0e79e17c70e2
improve sessionhandler trace logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
557
diff
changeset
|
670 | log_ereport(LOG_DEBUG, "trace reqid: %016llx connection: close", (unsigned long long int)sn->connection->id); |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
671 | connection_destroy(sn->connection); |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
672 | } |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
673 | |
78
3578977d29a3
added keep-alive support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
77
diff
changeset
|
674 | // free all memory |
46
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
675 | free(sn->netbuf->inbuf); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
676 | free(sn->netbuf); |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
677 | |
636e05eb48f6
cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
45
diff
changeset
|
678 | pool_destroy(sn->sn.pool); |
114
c3a0f1275d71
fixed keep alive bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
110
diff
changeset
|
679 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
680 | return 0; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
681 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
682 | |
272
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
683 | void request_free_resources(NSAPISession *sn, NSAPIRequest *rq) { |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
684 | if(!rq->resources) return; |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
685 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
686 | CxIterator i = cxMapIteratorValues(rq->resources); |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
687 | cx_foreach(ResourceData *, resource, i) { |
272
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
688 | resourcepool_free(&sn->sn, &rq->rq, resource); |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
689 | } |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
690 | } |
f210681d9dd0
add minimal working implementation for resourcepool_lookup()
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
261
diff
changeset
|
691 | |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
692 | int nsapi_authtrans(NSAPISession *sn, NSAPIRequest *rq) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
693 | HTTPObjectConfig *objconf = rq->vs->objects; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
694 | httpd_object *obj = objconf->objects[0]; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
695 | dtable *dt = object_get_dtable(obj, NSAPIAuthTrans); |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
696 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
697 | int ret = rq->context.last_req_code; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
698 | 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
|
699 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
700 | directive *d = dt->dirs[i]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
701 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
702 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
703 | |
22
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
704 | if(ret != REQ_NOACTION) { |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
705 | /* |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
706 | * 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
|
707 | * process this object at a later time |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
708 | */ |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
709 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
710 | // save nsapi context |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
711 | // 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
|
712 | rq->context.dtable_index = i + 1; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
713 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
714 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
715 | return ret; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
716 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
717 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
718 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
719 | |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
720 | return REQ_PROCEED; |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
721 | } |
adb0bda54e6b
Server can run as daemon
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
21
diff
changeset
|
722 | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
723 | int nsapi_nametrans(NSAPISession *sn, NSAPIRequest *rq) { |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
724 | HTTPObjectConfig *objconf = rq->vs->objects; |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
725 | //printf("nsapi_nametrans\n"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
726 | httpd_objset *objset = objset_create(sn->sn.pool); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
727 | rq->rq.os = objset; |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
728 | // 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
|
729 | 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
|
730 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
731 | 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
|
732 | dtable *dt = object_get_dtable(obj, NSAPINameTrans); |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
733 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
734 | // execute directives |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
735 | int ret = rq->context.last_req_code; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
736 | char *name = NULL; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
737 | char *ppath = NULL; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
738 | 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
|
739 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
740 | directive *d = dt->dirs[i]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
741 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
742 | } |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
743 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
744 | // check for name or ppath |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
745 | name = pblock_findkeyval(pb_key_name, rq->rq.vars); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
746 | ppath = pblock_findkeyval(pb_key_ppath, rq->rq.vars); |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
747 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
748 | // add additional objects to the objset |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
749 | 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
|
750 | log_ereport(LOG_FAILURE, "add_objects failed"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
751 | return REQ_ABORTED; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
752 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
753 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
754 | if(ret != REQ_NOACTION) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
755 | /* |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
756 | * 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
|
757 | * process this object at a later time |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
758 | */ |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
759 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
760 | // save nsapi context |
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
761 | // add +1 to start next round with next function |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
762 | rq->context.dtable_index = i + 1; |
117
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
763 | } else if(ret == REQ_PROCEED) { |
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
764 | char *pp = pblock_findkeyval(pb_key_ppath, rq->rq.vars); |
a94cf2e94492
fixes nametrans
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
765 | 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
|
766 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
767 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
768 | return ret; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
769 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
770 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
771 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
772 | // 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
|
773 | if(ret == REQ_NOACTION && ppath == NULL) { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
774 | cxmutstr docroot = rq->vs->document_root; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
775 | if(docroot.length < 1) { |
136
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
776 | log_ereport( |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
777 | LOG_WARN, |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
778 | "VirtualServer(%.*s) docroot too short", |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
779 | (int)rq->vs->name.length, |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
780 | rq->vs->name.ptr); |
9b48a1427aef
adds simple rewrite saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
781 | return REQ_ABORTED; // docroot too short |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
782 | } |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
783 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
784 | // 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
|
785 | /* |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
786 | if(docroot.ptr[docroot.length - 1] == '/') { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
787 | docroot.length--; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
788 | } |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
789 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
790 | cxmutstr uri = cx_str(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
|
791 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
792 | cxmutstr translated; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
793 | translated.length = docroot.length + uri.length; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
794 | translated.ptr = alloca(translated.length + 1); |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
795 | translated = cx_strncat(translated, 2, docroot, uri); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
796 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
797 | pblock_kvinsert( |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
798 | pb_key_ppath, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
799 | translated.ptr, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
800 | translated.length, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
801 | rq->rq.vars); |
96
0185b13bf41f
added document-root and pfx2dir nametrans safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
95
diff
changeset
|
802 | */ |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
803 | cxstring uri = cx_str(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
804 | request_set_path(cx_strcast(docroot), uri, rq->rq.vars); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
805 | } |
116
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
806 | |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
807 | // TODO: remove ppath |
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
808 | 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
|
809 | 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
|
810 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
811 | return REQ_PROCEED; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
812 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
813 | |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
814 | int nsapi_pathcheck(NSAPISession *sn, NSAPIRequest *rq) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
815 | //printf("nsapi_pathcheck\n"); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
816 | httpd_objset *objset = rq->rq.os; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
817 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
818 | if(NCX_OI(rq) == -1) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
819 | NCX_OI(rq) = objset->pos - 1; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
820 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
821 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
822 | int ret = rq->context.last_req_code; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
823 | for(int i=NCX_OI(rq);i>=0;i--) { |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
824 | httpd_object *obj = objset->obj[i]; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
825 | dtable *dt = object_get_dtable(obj, NSAPIPathCheck); |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
826 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
827 | // execute directives |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
828 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
141 | 829 | if(ret == REQ_NOACTION || ret == REQ_PROCEED) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
830 | directive *d = dt->dirs[j]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
831 | ret = nsapi_exec(d, sn, rq); |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
832 | } else { |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
833 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
834 | // save nsapi context |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
835 | rq->context.objset_index = i; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
836 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
837 | // add +1 to start next round with next function |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
838 | rq->context.dtable_index = j + 1; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
839 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
840 | |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
841 | return ret; |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
842 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
843 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
844 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
845 | |
24
1a7853a4257e
removed some NSPR dependencies
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
23
diff
changeset
|
846 | return REQ_PROCEED; |
23
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
847 | } |
a2c8fc23c90e
Added basic authentication
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
22
diff
changeset
|
848 | |
10 | 849 | int nsapi_objecttype(NSAPISession *sn, NSAPIRequest *rq) { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
850 | //printf("nsapi_objecttype\n"); |
10 | 851 | httpd_objset *objset = rq->rq.os; |
852 | ||
853 | if(NCX_OI(rq) == -1) { | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
854 | // object index is undefined -> define correct object index |
10 | 855 | NCX_OI(rq) = objset->pos - 1; |
856 | } | |
857 | ||
858 | int ret = rq->context.last_req_code; | |
859 | for(int i=NCX_OI(rq);i>=0;i--) { | |
860 | httpd_object *obj = objset->obj[i]; | |
861 | dtable *dt = object_get_dtable(obj, NSAPIObjectType); | |
862 | ||
863 | // execute directives | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
864 | 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
|
865 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
866 | directive *d = dt->dirs[j]; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
867 | ret = nsapi_exec(d, sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
868 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
869 | |
10 | 870 | switch(ret) { |
871 | case REQ_PROCEED: { | |
872 | char *type = pblock_findkeyval( | |
873 | pb_key_content_type, | |
874 | rq->rq.srvhdrs); | |
875 | if(type == NULL) { | |
876 | ret = REQ_NOACTION; | |
877 | break; | |
878 | } | |
879 | return ret; | |
880 | } | |
881 | case REQ_PROCESSING: { | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
882 | // save nsapi context |
10 | 883 | rq->context.objset_index = i; |
884 | ||
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
885 | // add +1 to start next round with next function |
10 | 886 | rq->context.dtable_index = j + 1; |
887 | return ret; | |
888 | } | |
889 | case REQ_NOACTION: { | |
890 | break; | |
891 | } | |
892 | default: { | |
893 | return ret; | |
894 | } | |
895 | } | |
896 | } | |
897 | } | |
898 | ||
899 | /* | |
900 | * No function returned with REQ_PROCEED, but we need a content type. | |
901 | * If the path ends with a '/', we set the content type to | |
902 | * 'internal/directory' so that 'index-common' can serve the content. | |
903 | * Otherwise we set the content type to text/plain | |
904 | */ | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
905 | cxstring path = cx_str(pblock_findkeyval(pb_key_ppath, rq->rq.vars)); |
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
906 | cxstring ct; |
10 | 907 | if(path.ptr[path.length - 1] == '/') { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
908 | // directory |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
909 | ct = (cxstring)CX_STR("internal/directory"); |
10 | 910 | } else { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
911 | ct = (cxstring)CX_STR("text/plain"); |
10 | 912 | } |
913 | pblock_kvinsert(pb_key_content_type, ct.ptr, ct.length, rq->rq.srvhdrs); | |
914 | ||
915 | return REQ_PROCEED; | |
916 | } | |
917 | ||
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
918 | int nsapi_service(NSAPISession *sn, NSAPIRequest *rq) { |
21
627b09ee74e4
New configuration loader
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
20
diff
changeset
|
919 | //printf("nsapi_service\n"); |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
920 | httpd_objset *objset = rq->rq.os; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
921 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
922 | if(NCX_OI(rq) == -1) { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
923 | NCX_OI(rq) = objset->pos - 1; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
924 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
925 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
926 | int ret = rq->context.last_req_code; |
12
34aa8001ea53
Added directory index
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
10
diff
changeset
|
927 | char *content_type = NULL; |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
928 | char *method = NULL; |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
929 | for(int i=NCX_OI(rq);i>=0;i--) { |
12
34aa8001ea53
Added directory index
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
10
diff
changeset
|
930 | httpd_object *obj = objset->obj[i]; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
931 | dtable *dt = object_get_dtable(obj, NSAPIService); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
932 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
933 | // execute directives |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
934 | 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
|
935 | if(ret == REQ_NOACTION) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
936 | directive *d = dt->dirs[j]; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
937 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
938 | // check type parameter |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
939 | 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
|
940 | if(dtp) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
941 | // type parameter for directive |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
942 | if(!content_type) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
943 | content_type = pblock_findkeyval( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
944 | pb_key_content_type, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
945 | rq->rq.srvhdrs); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
946 | } |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
947 | // compare types |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
948 | if(!contenttype_match(cx_str(dtp), cx_str(content_type))) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
949 | continue; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
950 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
951 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
952 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
953 | // check method parameter |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
954 | 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
|
955 | if(dmt) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
956 | if(!method) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
957 | 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
|
958 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
959 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
960 | if(!method_match(dmt, method)) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
961 | continue; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
962 | } |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
963 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
964 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
965 | // execute the saf |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
966 | ret = nsapi_exec(d, sn, rq); |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
967 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
968 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
969 | if(ret != REQ_NOACTION) { |
361
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
970 | if(ret == REQ_PROCEED && !rq->rq.senthdrs) { |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
971 | // a service SAF must send a response |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
972 | // senthdrs == 0 indicators something has gone |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
973 | // wrong |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
974 | protocol_status(&sn->sn, &rq->rq, 500, NULL); |
570026d3a685
make sure the http stream is finished if headers are sent
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
975 | ret = REQ_ABORTED; |
80
0de4a90979e1
fixed chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
79
diff
changeset
|
976 | } else if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
977 | // save nsapi context |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
978 | rq->context.objset_index = i; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
979 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
980 | // add +1 to start next round with next function |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
981 | rq->context.dtable_index = j + 1; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
982 | } |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
983 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
984 | return ret; |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
985 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
986 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
987 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
988 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
989 | return ret; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
990 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
991 | |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
992 | 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
|
993 | //printf("nsapi_error\n"); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
994 | httpd_objset *objset = rq->rq.os; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
995 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
996 | if(NCX_OI(rq) == -1) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
997 | NCX_OI(rq) = objset->pos - 1; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
998 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
999 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1000 | 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
|
1001 | 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
|
1002 | httpd_object *obj = objset->obj[i]; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1003 | 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
|
1004 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1005 | // execute directives |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1006 | 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
|
1007 | if(ret == REQ_NOACTION) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1008 | directive *d = dt->dirs[j]; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1009 | |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1010 | // check status code parameter |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1011 | // Error SAFs can specify, for which status code they should |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1012 | // be executed |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1013 | 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
|
1014 | if(status) { |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1015 | int64_t statuscode = -1; |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1016 | if(!util_strtoint(status, &statuscode)) { |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1017 | log_ereport( |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1018 | LOG_WARN, |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1019 | "nsapi_error: directive '%s' ignored: invalid type parameter: integer status code expected", |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1020 | d->func->name); |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1021 | } else if(statuscode != rq->rq.status_num) { |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1022 | continue; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1023 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1024 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1025 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1026 | // execute the saf |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1027 | ret = nsapi_exec(d, sn, rq); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1028 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1029 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1030 | if(ret == REQ_ABORTED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1031 | // 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
|
1032 | // error handler |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1033 | break; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1034 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1035 | if(ret != REQ_NOACTION) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1036 | if(ret == REQ_PROCEED) { |
339
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1037 | // flush buffer and add termination if chunked encoding |
f4a34b0869c7
replace atoi with util_strtoint
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
333
diff
changeset
|
1038 | // is enabled |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1039 | net_finish(sn->sn.csd); |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1040 | } else if(ret == REQ_PROCESSING) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1041 | // save nsapi context |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1042 | rq->context.objset_index = i; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1043 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1044 | // 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
|
1045 | rq->context.dtable_index = j + 1; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1046 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1047 | return ret; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1048 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1049 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1050 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1051 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1052 | if(ret != REQ_PROCEED) { |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1053 | // default error handler |
235
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
1054 | if(!rq->rq.senthdrs) { |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
1055 | nsapi_error_request((Session*)sn, (Request*)rq); |
4990147c58d0
add handler for http expect header
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
211
diff
changeset
|
1056 | } |
95
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1057 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1058 | |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1059 | return ret; |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1060 | } |
74a81d9e19d0
added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
91
diff
changeset
|
1061 | |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1062 | int nsapi_addlog(NSAPISession *sn, NSAPIRequest *rq) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1063 | //printf("nsapi_addlog\n"); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1064 | httpd_objset *objset = rq->rq.os; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1065 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1066 | if(NCX_OI(rq) == -1) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1067 | NCX_OI(rq) = objset->pos - 1; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1068 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1069 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1070 | int ret = rq->context.last_req_code; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1071 | for(int i=NCX_OI(rq);i>=0;i--) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1072 | httpd_object *obj = objset->obj[i]; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1073 | dtable *dt = object_get_dtable(obj, NSAPIAddLog); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1074 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1075 | // execute directives |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1076 | for(int j=NCX_DI(rq);j<dt->ndir;j++) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1077 | if(ret == REQ_NOACTION) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1078 | directive *d = dt->dirs[j]; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1079 | ret = nsapi_exec(d, sn, rq); |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1080 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1081 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1082 | if(ret != REQ_NOACTION) { |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1083 | if(ret == REQ_PROCESSING) { |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
1084 | // save nsapi context |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1085 | rq->context.objset_index = i; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1086 | |
87
bdec069d2239
fixed pathcheck behavior
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
84
diff
changeset
|
1087 | // add +1 to start next round with next function |
45
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1088 | rq->context.dtable_index = j + 1; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1089 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1090 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1091 | return ret; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1092 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1093 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1094 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1095 | |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1096 | return REQ_PROCEED; |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1097 | } |
a24aa388f02f
added access log
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
1098 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1099 | struct _tpd_data { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1100 | NSAPISession *sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1101 | NSAPIRequest *rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1102 | directive *directive; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1103 | threadpool_t *threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1104 | }; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1105 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1106 | 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
|
1107 | // TODO: condition |
83
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
1108 | if(d->cond) { |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
1109 | if(!condition_evaluate(d->cond, (Session*)sn, (Request*)rq)) { |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
1110 | return REQ_NOACTION; |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
1111 | } |
28433f06d5ee
added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
80
diff
changeset
|
1112 | } |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1113 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1114 | 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
|
1115 | if(poolname) { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1116 | threadpool_t *pool = get_threadpool(cx_str(poolname)); |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1117 | if(pool && pool != sn->currentpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1118 | // execute directive in different thread pool |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1119 | return nsapi_exec_tp(d, sn, rq, pool); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1120 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1121 | } else if(sn->currentpool != sn->defaultpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1122 | // 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
|
1123 | 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
|
1124 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1125 | |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
1126 | 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
|
1127 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1128 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1129 | int nsapi_exec_tp( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1130 | directive *d, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1131 | NSAPISession *sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1132 | NSAPIRequest *rq, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1133 | threadpool_t *pool) |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1134 | { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1135 | 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
|
1136 | if(data == NULL) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1137 | // TODO: set error |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1138 | return REQ_ABORTED; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1139 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1140 | data->sn = sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1141 | data->rq = rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1142 | data->directive = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1143 | data->threadpool = pool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1144 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1145 | sn->currentpool = pool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1146 | threadpool_run(pool, thrpool_exec, data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1147 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1148 | return REQ_PROCESSING; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1149 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1150 | |
531
9b15b1f72bef
change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
495
diff
changeset
|
1151 | void nsapi_saf_return(Session *session, Request *request, int ret) { |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1152 | NSAPISession *sn = (NSAPISession*)session; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1153 | NSAPIRequest *rq = (NSAPIRequest*)request; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1154 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1155 | rq->context.last_req_code = ret; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1156 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1157 | if(sn->currentpool != sn->defaultpool) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1158 | nsapi_change_threadpool(sn, rq, sn->defaultpool); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1159 | } else { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1160 | nsapi_handle_request(sn, rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1161 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1162 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1163 | |
531
9b15b1f72bef
change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
495
diff
changeset
|
1164 | void nsapi_function_return(Session *session, Request *request, int ret) { |
9b15b1f72bef
change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
495
diff
changeset
|
1165 | ev_saf_return(session->ev, session, request, ret); |
9b15b1f72bef
change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
495
diff
changeset
|
1166 | } |
9b15b1f72bef
change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
495
diff
changeset
|
1167 | |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1168 | void nsapi_change_threadpool( |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1169 | NSAPISession *sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1170 | NSAPIRequest *rq, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1171 | threadpool_t *thrpool) |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1172 | { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1173 | 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
|
1174 | data->sn = sn; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1175 | data->rq = rq; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1176 | data->threadpool = thrpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1177 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1178 | threadpool_run(thrpool, thrpool_change, data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1179 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1180 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1181 | void* thrpool_exec(void *d) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1182 | struct _tpd_data *data = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1183 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1184 | data->sn->currentpool = data->threadpool; |
84
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
1185 | int r = SAF_EXEC( |
afd57ce39ec9
added initial java plugin code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
83
diff
changeset
|
1186 | data->directive->func, |
37
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1187 | data->directive->param, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1188 | (Session*)data->sn, |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1189 | (Request*)data->rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1190 | |
116
d7a186cf87f6
adds find-pathinfo saf
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
115
diff
changeset
|
1191 | 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
|
1192 | free(data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1193 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1194 | return NULL; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1195 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1196 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1197 | void* thrpool_change(void *d) { |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1198 | struct _tpd_data *data = d; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1199 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1200 | data->sn->currentpool = data->threadpool; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1201 | nsapi_handle_request(data->sn, data->rq); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1202 | |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1203 | free(data); |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1204 | return NULL; |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1205 | } |
360b9aabe17e
added support for asynchronous safs
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
36
diff
changeset
|
1206 | |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1207 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1208 | /* |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1209 | * checks if the method matches the cmp string |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1210 | * 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
|
1211 | * (method1|method2|method3|...) |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1212 | */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1213 | int method_match(char *cmp, char *method) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1214 | if(cmp[0] != '(') { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1215 | /* 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
|
1216 | if(!strcmp(cmp, method)) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1217 | return 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1218 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1219 | } else if(cmp[0] == 0) { |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1220 | // empty string |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1221 | log_ereport( |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1222 | LOG_WARN, |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1223 | "Skipped service saf with empty method parameter"); |
20
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1224 | return 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1225 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1226 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1227 | size_t method_len = strlen(method); |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1228 | size_t last_pos = 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1229 | cmp++; /* skip '(' */ |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1230 | for(int i=0;cmp[i]!=0;i++) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1231 | char c = cmp[i]; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1232 | if(c == '|' || c == ')') { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1233 | size_t len = i - last_pos; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1234 | if(len == method_len) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1235 | char *cp = cmp + last_pos; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1236 | if(!memcmp(cp, method, len)) { |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1237 | return 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1238 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1239 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1240 | last_pos = i + 1; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1241 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1242 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1243 | |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1244 | return 0; |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1245 | } |
7b235fa88008
Some fixes for mod_jk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
19
diff
changeset
|
1246 | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1247 | /* |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1248 | * checks if the content type matches the cmp string |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1249 | * the format of cmp is a single string with wildcards or a list |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1250 | * of types (also with wildcard support) |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1251 | * (type1|type2*) |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1252 | */ |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1253 | int contenttype_match(cxstring cmp, cxstring ctype) { |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1254 | if(cmp.ptr[0] != '(') { |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1255 | if(cmp.ptr[0] == '*') { |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1256 | cmp.ptr++; |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1257 | cmp.length--; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1258 | return cx_strsuffix(ctype, cmp); |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1259 | } else if(cmp.ptr[cmp.length-1] == '*') { |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1260 | cmp.length--; |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1261 | return cx_strprefix(ctype, cmp); |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1262 | } else { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1263 | return !cx_strcmp(cmp, ctype); |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1264 | } |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1265 | } else if(cmp.ptr[0] == 0) { |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1266 | log_ereport(LOG_WARN, "Skipped service saf with empty type parameter"); |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1267 | return 0; |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1268 | } |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1269 | |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1270 | cmp = cx_strsubsl(cmp, 1, cmp.length - 2); |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1271 | |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1272 | int begin = 0; |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1273 | for(int i=0;i<cmp.length;i++) { |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1274 | if(cmp.ptr[i] == '|') { |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1275 | if(contenttype_match(cx_strsubsl(cmp, begin, i-begin), ctype)) { |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1276 | return 1; |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1277 | } |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1278 | begin = i + 1; |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1279 | } |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1280 | } |
415
d938228c382e
switch from ucx 2 to 3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
411
diff
changeset
|
1281 | return contenttype_match(cx_strsubs(cmp, begin), ctype); |
142
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1282 | } |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1283 | |
55298bc9ed28
adds new a pathcheck saf and improves content type matchin and improves content type matching
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
1284 | /* |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1285 | * 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
|
1286 | */ |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1287 | int add_objects( |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1288 | HTTPObjectConfig *objs, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1289 | httpd_objset *os, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1290 | NSAPISession *sn, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1291 | NSAPIRequest *rq, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1292 | char *name, |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1293 | char *path) |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1294 | { |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1295 | /* first, add all objects with a matching path */ |
10 | 1296 | /* TODO */ |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1297 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1298 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1299 | /* add object with object with matching name */ |
10 | 1300 | if(name == NULL) { |
1301 | return REQ_PROCEED; | |
1302 | } | |
1303 | ||
1304 | for(int i=0;i<objs->nobj;i++) { | |
1305 | httpd_object *obj = objs->objects[i]; | |
1306 | ||
1307 | if(obj->name && !strcmp(name, obj->name)) { | |
1308 | objset_add_object(sn->sn.pool, os, obj); | |
1309 | } | |
1310 | } | |
6
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1311 | |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1312 | return REQ_PROCEED; |
ce8fecc9847d
improved request processing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
5
diff
changeset
|
1313 | } |