232 break; |
232 break; |
233 } |
233 } |
234 } |
234 } |
235 |
235 |
236 // Get abs_path part of request URI, and canonicalize the path |
236 // Get abs_path part of request URI, and canonicalize the path |
|
237 sstr_t orig_path = absPath; |
237 absPath.ptr = util_canonicalize_uri( |
238 absPath.ptr = util_canonicalize_uri( |
238 pool, |
239 pool, |
239 absPath.ptr, |
240 absPath.ptr, |
240 absPath.length, |
241 absPath.length, |
241 (int*)&absPath.length); |
242 (int*)&absPath.length); |
|
243 if(!absPath.ptr) { |
|
244 log_ereport( |
|
245 LOG_WARN, |
|
246 "invalid request path: {%.*s}", |
|
247 (int)orig_path.length, |
|
248 orig_path.ptr); |
|
249 pool_destroy(pool); |
|
250 // TODO: 400 bad request |
|
251 return 1; |
|
252 } |
242 |
253 |
243 // Decode the abs_path |
254 // Decode the abs_path |
244 if(util_uri_unescape_strict(absPath.ptr)) { |
255 if(util_uri_unescape_strict(absPath.ptr)) { |
245 // Pass the abs_path as 'uri' in reqpb |
256 // Pass the abs_path as 'uri' in reqpb |
246 pblock_kvinsert( |
257 pblock_kvinsert( |
248 absPath.ptr, |
259 absPath.ptr, |
249 absPath.length, |
260 absPath.length, |
250 rq->rq.reqpb); |
261 rq->rq.reqpb); |
251 } else { |
262 } else { |
252 // TODO: log error |
263 // TODO: log error |
253 log_ereport(LOG_WARN, "uri unescape failed"); |
264 log_ereport( |
|
265 LOG_WARN, |
|
266 "uri unescape failed: {%.*s}", |
|
267 (int)absPath.length, |
|
268 absPath.ptr); |
|
269 // TODO: 400 bad request |
254 pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb); |
270 pblock_kvinsert(pb_key_uri, "/", 1, rq->rq.reqpb); |
255 } |
271 } |
256 |
272 |
257 // pass http header to the NSAPI request structure |
273 // pass http header to the NSAPI request structure |
258 int hlen = request->headers->len; |
274 int hlen = request->headers->len; |