Sun, 07 Dec 2025 17:50:52 +0100
add missing source file
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * * THE BSD LICENSE * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the nor the names of its contributors may be * used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Open Web Server frame/req.cpp #include "req.h" #include "../util/pblock.h" /* ---------------------------- request_depth ----------------------------- */ static inline void request_depth(Request *rq, int *prestarted, int *pinternal) { // Calculate the depth of the rq->orig_rq linked list while (rq->orig_rq != rq) { if (rq->rq_attr.req_restarted) (*prestarted)++; if (rq->rq_attr.internal_req) (*pinternal)++; rq = rq->orig_rq; } } /* ------------------------- request_get_base_uri ------------------------- */ NSAPI_PUBLIC void request_get_base_uri(Request *rq, const char **pbase, int *plen) { // URI Base URI // ------------------- --------- // /index.html / // /foo/bar/ /foo/bar/ // /foo/bar/index.html /foo/bar/ // /cgi-bin/foo.pl/bar /cgi-bin/ if (rq) { const char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb); if (uri) { int len = strlen(uri); const char *path_info = pblock_findkeyval(pb_key_path_info, rq->vars); if (path_info) { int suffixlen = strlen(path_info); if (len > suffixlen) len -= suffixlen; } do { len--; } while (len > 0 && uri[len] != '/'); if (len > 0) { *pbase = uri; *plen = len + 1; return; } } } *pbase = "/"; *plen = 1; } /* ------------------------- request_is_internal -------------------------- */ NSAPI_PUBLIC int request_is_internal(Request *rq) { return (rq->rq_attr.internal_req == 1); } /* ------------------------- request_is_restarted ------------------------- */ NSAPI_PUBLIC PRBool request_is_restarted(Request *rq) { return (rq->rq_attr.req_restarted == 1); } /* --------------------- request_is_default_type_set ---------------------- */ NSAPI_PUBLIC PRBool request_is_default_type_set(const Request *rq) { return (rq->rq_attr.default_type_set == 1); } /* ----------------------- request_has_default_type ----------------------- */ NSAPI_PUBLIC void request_has_default_type(Request *rq) { rq->rq_attr.default_type_set = 1; }