1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #include "req.h"
37
38 #include "../util/pblock.h"
39
40
41
42 static inline
void request_depth(Request *rq,
int *prestarted,
int *pinternal)
43 {
44
45 while (rq->orig_rq != rq) {
46 if (rq->rq_attr.req_restarted)
47 (*prestarted)++;
48 if (rq->rq_attr.internal_req)
49 (*pinternal)++;
50 rq = rq->orig_rq;
51 }
52 }
53
54
55
56 NSAPI_PUBLIC void request_get_base_uri(Request *rq,
const char **pbase,
57 int *plen)
58 {
59
60
61
62
63
64
65
66 if (rq) {
67 const char *uri = pblock_findkeyval(pb_key_uri, rq->reqpb);
68 if (uri) {
69 int len = strlen(uri);
70 const char *path_info = pblock_findkeyval(pb_key_path_info, rq->vars);
71 if (path_info) {
72 int suffixlen = strlen(path_info);
73 if (len > suffixlen)
74 len -= suffixlen;
75 }
76
77 do { len--; }
while (len >
0 && uri[len] !=
'/');
78
79 if (len >
0) {
80 *pbase = uri;
81 *plen = len +
1;
82 return;
83 }
84 }
85 }
86
87 *pbase =
"/";
88 *plen =
1;
89 }
90
91
92
93 NSAPI_PUBLIC int request_is_internal(Request *rq)
94 {
95 return (rq->rq_attr.internal_req ==
1);
96 }
97
98
99
100
101 NSAPI_PUBLIC PRBool request_is_restarted(Request *rq)
102 {
103 return (rq->rq_attr.req_restarted ==
1);
104 }
105
106
107
108
109 NSAPI_PUBLIC PRBool request_is_default_type_set(
const Request *rq)
110 {
111 return (rq->rq_attr.default_type_set ==
1);
112 }
113
114
115
116
117 NSAPI_PUBLIC void request_has_default_type(Request *rq)
118 {
119 rq->rq_attr.default_type_set =
1;
120 }
121