diff -r 99a34860c105 -r d938228c382e src/server/daemon/httprequest.c --- a/src/server/daemon/httprequest.c Wed Nov 02 19:19:01 2022 +0100 +++ b/src/server/daemon/httprequest.c Sun Nov 06 15:53:32 2022 +0100 @@ -64,27 +64,27 @@ free(req); } -sstr_t http_request_get_abspath(HTTPRequest *req) { - sstr_t uri = req->uri; +cxmutstr http_request_get_abspath(HTTPRequest *req) { + cxmutstr uri = req->uri; int i = 0; if(uri.ptr[0] == '/') { return uri; - } else if(sstrprefix(uri, S("http://"))) { + } else if(cx_strprefix(cx_strcast(uri), (cxstring)CX_STR("http://"))) { i = 7; - } else if(sstrprefix(uri, S("https://"))) { + } else if(cx_strprefix(cx_strcast(uri), (cxstring)CX_STR("https://"))) { i = 8; - } else if(!sstrcmp(uri, S("*"))) { + } else if(!cx_strcmp(cx_strcast(uri), (cxstring)CX_STR("*"))) { return uri; } for(;isn.pool = pool; - sn->allocator = util_pool_allocator(pool); sn->sn.client = pblock_create_pool(sn->sn.pool, 8); if(!sn->sn.client) { @@ -198,7 +197,7 @@ // Pass request line as "clf-request" // remove \r\n - sstr_t clfreq = request->request_line; + cxmutstr clfreq = request->request_line; while(clfreq.length > 0 && clfreq.ptr[clfreq.length - 1] < 33) { clfreq.length--; } @@ -225,9 +224,9 @@ request->httpv.length, rq->rq.reqpb); - if(!sstrcmp(request->httpv, S("HTTP/1.1"))) { + if(!cx_strcmp(cx_strcast(request->httpv), (cxstring)CX_STR("HTTP/1.1"))) { rq->rq.protv_num = PROTOCOL_VERSION_HTTP11; - } else if(!sstrcmp(request->httpv, S("HTTP/1.0"))) { + } else if(!cx_strcmp(cx_strcast(request->httpv), (cxstring)CX_STR("HTTP/1.0"))) { rq->rq.protv_num = PROTOCOL_VERSION_HTTP10; } else { // invalid protocol version - abort @@ -244,7 +243,7 @@ * get absolute path and query of the request uri */ // TODO: check for '#' #72 - sstr_t absPath = http_request_get_abspath(request); + cxmutstr absPath = http_request_get_abspath(request); if(!absPath.ptr) { // TODO: error msg return 1; @@ -253,7 +252,7 @@ return 1; } - sstr_t query; + cxmutstr query; query.length = 0; for(int i=0;iuri.length;i++) { @@ -277,7 +276,7 @@ } // Get abs_path part of request URI, and canonicalize the path - sstr_t orig_path = absPath; + cxmutstr orig_path = absPath; absPath.ptr = util_canonicalize_uri( pool, absPath.ptr, @@ -371,7 +370,7 @@ rq->port = request->connection->listener->port; if(rq->host) { - VirtualServer *vs = ucx_map_cstr_get(sn->config->host_vs, rq->host); + VirtualServer *vs = cxMapGet(sn->config->host_vs, cx_hash_key_str(rq->host)); if(vs) { rq->vs = vs; } else { @@ -454,7 +453,7 @@ -void header_add(HeaderArray *hd, sstr_t name, sstr_t value) { +void header_add(HeaderArray *hd, cxmutstr name, cxmutstr value) { while(hd->len >= hd->alloc) { if(hd->next == NULL) { HeaderArray *block = malloc(sizeof(HeaderArray)); @@ -648,9 +647,8 @@ void request_free_resources(NSAPISession *sn, NSAPIRequest *rq) { if(!rq->resources) return; - UcxMapIterator i = ucx_map_iterator(rq->resources); - ResourceData *resource; - UCX_MAP_FOREACH(key, resource, i) { + CxIterator i = cxMapIteratorValues(rq->resources); + cx_foreach(ResourceData *, resource, i) { resourcepool_free(&sn->sn, &rq->rq, resource); } } @@ -737,7 +735,7 @@ // if no function has set the ppath var, translate it to docroot if(ret == REQ_NOACTION && ppath == NULL) { - sstr_t docroot = rq->vs->document_root; + cxmutstr docroot = rq->vs->document_root; if(docroot.length < 1) { log_ereport( LOG_WARN, @@ -753,12 +751,12 @@ docroot.length--; } - sstr_t uri = sstr(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); + cxmutstr uri = cx_str(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); - sstr_t translated; + cxmutstr translated; translated.length = docroot.length + uri.length; translated.ptr = alloca(translated.length + 1); - translated = sstrncat(translated, 2, docroot, uri); + translated = cx_strncat(translated, 2, docroot, uri); pblock_kvinsert( pb_key_ppath, @@ -766,8 +764,8 @@ translated.length, rq->rq.vars); */ - sstr_t uri = sstr(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); - request_set_path(docroot, uri, rq->rq.vars); + cxstring uri = cx_str(pblock_findkeyval(pb_key_uri, rq->rq.reqpb)); + request_set_path(cx_strcast(docroot), uri, rq->rq.vars); } // TODO: remove ppath @@ -868,13 +866,13 @@ * 'internal/directory' so that 'index-common' can serve the content. * Otherwise we set the content type to text/plain */ - sstr_t path = sstr(pblock_findkeyval(pb_key_ppath, rq->rq.vars)); - sstr_t ct; + cxstring path = cx_str(pblock_findkeyval(pb_key_ppath, rq->rq.vars)); + cxstring ct; if(path.ptr[path.length - 1] == '/') { // directory - ct = sstrn("internal/directory", 18); + ct = (cxstring)CX_STR("internal/directory"); } else { - ct = sstrn("text/plain", 10); + ct = (cxstring)CX_STR("text/plain"); } pblock_kvinsert(pb_key_content_type, ct.ptr, ct.length, rq->rq.srvhdrs); @@ -911,7 +909,7 @@ rq->rq.srvhdrs); } // compare types - if(!contenttype_match(sstr(dtp), sstr(content_type))) { + if(!contenttype_match(cx_str(dtp), cx_str(content_type))) { continue; } } @@ -1079,7 +1077,7 @@ char *poolname = pblock_findkeyval(pb_key_pool, d->param); if(poolname) { - threadpool_t *pool = get_threadpool(sstr(poolname)); + threadpool_t *pool = get_threadpool(cx_str(poolname)); if(pool && pool != sn->currentpool) { // execute directive in different thread pool return nsapi_exec_tp(d, sn, rq, pool); @@ -1212,35 +1210,35 @@ * of types (also with wildcard support) * (type1|type2*) */ -int contenttype_match(sstr_t cmp, sstr_t ctype) { +int contenttype_match(cxstring cmp, cxstring ctype) { if(cmp.ptr[0] != '(') { if(cmp.ptr[0] == '*') { cmp.ptr++; cmp.length--; - return sstrsuffix(ctype, cmp); + return cx_strsuffix(ctype, cmp); } else if(cmp.ptr[cmp.length-1] == '*') { cmp.length--; - return sstrprefix(ctype, cmp); + return cx_strprefix(ctype, cmp); } else { - return !sstrcmp(cmp, ctype); + return !cx_strcmp(cmp, ctype); } } else if(cmp.ptr[0] == 0) { log_ereport(LOG_WARN, "Skipped service saf with empty type parameter"); return 0; } - cmp = sstrsubsl(cmp, 1, cmp.length - 2); + cmp = cx_strsubsl(cmp, 1, cmp.length - 2); int begin = 0; for(int i=0;i