line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODE: INLINE |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
static U32 uxs_hashval; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
MODULE = URI::XS PACKAGE = URI::XS |
6
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BOOT { |
9
|
26
|
50
|
|
|
|
|
Stash stash(__PACKAGE__); |
10
|
13
|
|
|
|
|
|
PERL_HASH(uxs_hashval, "URI::XS", 7); |
11
|
|
|
|
|
|
|
|
12
|
78
|
50
|
|
|
|
|
xs::exp::create_constants(stash, { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{"ALLOW_SUFFIX_REFERENCE", URI::Flags::allow_suffix_reference}, |
14
|
|
|
|
|
|
|
{"QUERY_PARAM_SEMICOLON", URI::Flags::query_param_semicolon}, |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
// deprecated names |
17
|
|
|
|
|
|
|
{"ALLOW_LEADING_AUTHORITY", URI::Flags::allow_suffix_reference}, |
18
|
|
|
|
|
|
|
{"PARAM_DELIM_SEMICOLON", URI::Flags::query_param_semicolon}, |
19
|
65
|
50
|
|
|
|
|
}); |
20
|
13
|
50
|
|
|
|
|
xs::exp::autoexport(stash); |
|
|
50
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
URI* new (SV* CLASS, string url = string(), int flags = 0) { |
24
|
190
|
|
|
|
|
|
PROTO = CLASS; |
25
|
95
|
50
|
|
|
|
|
RETVAL = make_backref(url, flags); |
26
|
95
|
50
|
|
|
|
|
} |
27
|
95
|
50
|
|
|
|
|
|
28
|
|
|
|
|
|
|
string URI::url (SV* newval = NULL, int flags = 0) { |
29
|
59
|
50
|
|
|
|
|
if (newval) { |
30
|
0
|
0
|
|
|
|
|
THIS->assign(SvOK(newval) ? xs::in(newval) : "", flags); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
32
|
|
|
|
|
|
|
} |
33
|
59
|
50
|
|
|
|
|
RETVAL = THIS->to_string(); |
|
|
50
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
string URI::scheme (SV* newval = NULL) : ALIAS(proto=1, protocol=2) { |
37
|
79
|
100
|
|
|
|
|
if (newval) { |
38
|
12
|
50
|
|
|
|
|
THIS->scheme(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
39
|
7
|
|
|
|
|
|
XSRETURN_UNDEF; |
40
|
|
|
|
|
|
|
} |
41
|
67
|
50
|
|
|
|
|
RETVAL = THIS->scheme(); |
42
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
string URI::user_info (SV* newval = NULL) { |
46
|
59
|
50
|
|
|
|
|
if (newval) { |
47
|
0
|
0
|
|
|
|
|
THIS->user_info(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
49
|
|
|
|
|
|
|
} |
50
|
59
|
50
|
|
|
|
|
RETVAL = THIS->user_info(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
string URI::host (SV* newval = NULL) { |
54
|
67
|
100
|
|
|
|
|
if (newval) { |
55
|
3
|
50
|
|
|
|
|
THIS->host(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
56
|
3
|
|
|
|
|
|
XSRETURN_UNDEF; |
57
|
|
|
|
|
|
|
} |
58
|
64
|
50
|
|
|
|
|
RETVAL = THIS->host(); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
int URI::port (SV* newval = NULL) { |
62
|
19
|
100
|
|
|
|
|
if (newval) { |
63
|
2
|
50
|
|
|
|
|
THIS->port(SvIV(newval)); |
|
|
0
|
|
|
|
|
|
64
|
19
|
|
|
|
|
|
XSRETURN_UNDEF; |
65
|
|
|
|
|
|
|
} |
66
|
17
|
|
|
|
|
|
RETVAL = THIS->port(); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
string URI::path (SV* newval = NULL) { |
70
|
65
|
100
|
|
|
|
|
if (newval) { |
71
|
2
|
50
|
|
|
|
|
THIS->path(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
72
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
73
|
|
|
|
|
|
|
} |
74
|
63
|
50
|
|
|
|
|
RETVAL = THIS->path(); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
string URI::query_string (SV* newval = NULL) { |
78
|
75
|
100
|
|
|
|
|
if (newval) { |
79
|
4
|
50
|
|
|
|
|
THIS->query_string(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
80
|
4
|
|
|
|
|
|
XSRETURN_UNDEF; |
81
|
|
|
|
|
|
|
} |
82
|
71
|
50
|
|
|
|
|
RETVAL = THIS->query_string(); |
|
|
50
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
string URI::raw_query (SV* newval = NULL) { |
86
|
1
|
50
|
|
|
|
|
if (newval) { |
87
|
0
|
0
|
|
|
|
|
THIS->raw_query(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
89
|
|
|
|
|
|
|
} |
90
|
1
|
50
|
|
|
|
|
RETVAL = THIS->raw_query(); |
|
|
50
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Ref URI::query (...) { |
94
|
7
|
100
|
|
|
|
|
if (items > 1) { |
95
|
2
|
50
|
|
|
|
|
add_query_args(THIS, MARK+2, items-1, true); |
96
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
97
|
|
|
|
|
|
|
} |
98
|
5
|
50
|
|
|
|
|
auto data = data_get(ST(0)); |
99
|
5
|
50
|
|
|
|
|
RETVAL = data->query_hash(THIS); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
void URI::add_query (...) { |
103
|
3
|
|
|
|
|
|
add_query_args(THIS, MARK+2, items-1); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
string URI::param (string_view name, SV* val = NULL) : ALIAS(multiparam = 1) { |
107
|
17
|
100
|
|
|
|
|
if (val) { |
108
|
1
|
50
|
|
|
|
|
add_param(THIS, string(name), val, true); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
109
|
1
|
|
|
|
|
|
XSRETURN_UNDEF; |
110
|
|
|
|
|
|
|
} |
111
|
16
|
100
|
|
|
|
|
if (ix == 0) { // param method |
112
|
13
|
50
|
|
|
|
|
auto it = THIS->query().find(name); |
|
|
50
|
|
|
|
|
|
113
|
13
|
50
|
|
|
|
|
if (it == THIS->query().cend()) XSRETURN_UNDEF; |
|
|
100
|
|
|
|
|
|
114
|
12
|
50
|
|
|
|
|
RETVAL = it->second; |
115
|
|
|
|
|
|
|
} else { // multiparam method |
116
|
3
|
50
|
|
|
|
|
size_t nvals = THIS->query().count(name); |
|
|
50
|
|
|
|
|
|
117
|
3
|
|
|
|
|
|
switch (nvals) { |
118
|
|
|
|
|
|
|
case 0: |
119
|
3
|
|
|
|
|
|
XSRETURN_EMPTY; break; |
120
|
|
|
|
|
|
|
case 1: |
121
|
1
|
50
|
|
|
|
|
RETVAL = THIS->query().find(name)->second; break; |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
122
|
|
|
|
|
|
|
default: |
123
|
2
|
|
|
|
|
|
SP -= items; |
124
|
2
|
50
|
|
|
|
|
EXTEND(SP, (int)nvals); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
125
|
2
|
50
|
|
|
|
|
const auto& query = THIS->query(); |
126
|
2
|
50
|
|
|
|
|
auto pair = query.equal_range(name); |
127
|
6
|
100
|
|
|
|
|
for (auto it = pair.first; it != pair.second; ++it) mPUSHp(it->second.data(), it->second.length()); |
|
|
50
|
|
|
|
|
|
128
|
2
|
|
|
|
|
|
XSRETURN(nvals); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
int URI::nparam () { |
134
|
1
|
50
|
|
|
|
|
RETVAL = THIS->query().size(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
size_t URI::remove_param (string name) { |
138
|
0
|
0
|
|
|
|
|
RETVAL = THIS->query().erase(name); |
|
|
0
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
string URI::fragment (SV* newval = NULL) : ALIAS(hash=1) { |
142
|
122
|
100
|
|
|
|
|
if (newval) { |
143
|
2
|
50
|
|
|
|
|
THIS->fragment(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
144
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
145
|
|
|
|
|
|
|
} |
146
|
120
|
50
|
|
|
|
|
RETVAL = THIS->fragment(); |
147
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
string URI::location (SV* newval = NULL) { |
151
|
8
|
100
|
|
|
|
|
if (newval) { |
152
|
2
|
50
|
|
|
|
|
THIS->location(SvOK(newval) ? xs::in(newval) : ""); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
153
|
2
|
|
|
|
|
|
XSRETURN_UNDEF; |
154
|
|
|
|
|
|
|
} |
155
|
6
|
50
|
|
|
|
|
RETVAL = THIS->location(); |
|
|
50
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
63
|
|
|
|
|
|
uint16_t URI::explicit_port () |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
uint16_t URI::default_port () |
161
|
|
|
|
|
|
|
|
162
|
2
|
50
|
|
|
|
|
string URI::explicit_location () |
|
|
50
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
string URI::relative () : ALIAS(rel=1) { |
165
|
2
|
50
|
|
|
|
|
RETVAL = THIS->relative(); |
|
|
50
|
|
|
|
|
|
166
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
string URI::to_string (...) : ALIAS(as_string=1) { |
170
|
242
|
50
|
|
|
|
|
RETVAL = THIS->to_string(); |
|
|
50
|
|
|
|
|
|
171
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
13
|
|
|
|
|
|
bool URI::secure () |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
void URI::set (Sv source, int flags = 0) : ALIAS(assign=1) { |
177
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ix); |
178
|
15
|
100
|
|
|
|
|
if (source.is_string()) THIS->assign(xs::in(source), flags); |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
179
|
4
|
50
|
|
|
|
|
else THIS->assign(*xs::in>(source)); |
|
|
100
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
bool URI::equals (Sv other, ...) { |
183
|
30
|
50
|
|
|
|
|
if (other.is_string()) RETVAL = THIS->to_string() == xs::in(other); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
184
|
|
|
|
|
|
|
else { |
185
|
0
|
0
|
|
|
|
|
Object obj = other; |
186
|
0
|
0
|
|
|
|
|
if (obj && obj.stash().isa("URI::XS")) RETVAL = THIS->equals(*xs::in(obj)); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
else RETVAL = false; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
URI* URI::clone () { |
192
|
4
|
|
|
|
|
|
PROTO = Object(ST(0)).stash(); |
193
|
2
|
50
|
|
|
|
|
if (dynamic_cast(THIS)) RETVAL = URI::create(*THIS); |
|
|
50
|
|
|
|
|
|
194
|
2
|
50
|
|
|
|
|
else RETVAL = new URI(*THIS); |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
195
|
1
|
50
|
|
|
|
|
} |
|
|
50
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
void URI::path_segments (...) { |
198
|
8
|
100
|
|
|
|
|
if (items > 1) { |
199
|
6
|
|
|
|
|
|
std::vector list; |
200
|
3
|
50
|
|
|
|
|
list.reserve(items-1); |
201
|
10
|
100
|
|
|
|
|
for (I32 i = 1; i < items; ++i) list.push_back(xs::in(ST(i))); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
202
|
3
|
50
|
|
|
|
|
THIS->path_segments(list.cbegin(), list.cend()); |
203
|
3
|
|
|
|
|
|
XSRETURN_EMPTY; |
204
|
|
|
|
|
|
|
} |
205
|
13
|
50
|
|
|
|
|
const std::vector list = THIS->path_segments(); |
206
|
5
|
50
|
|
|
|
|
EXTEND(SP, (int)list.size()); |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
207
|
11
|
100
|
|
|
|
|
for (auto it = list.begin(); it != list.end(); ++it) mPUSHp(it->data(), it->length()); |
|
|
50
|
|
|
|
|
|
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
bool URI::to_bool (...) { |
211
|
14
|
50
|
|
|
|
|
RETVAL = THIS->scheme().length() || THIS->host().length() || THIS->path().length() || THIS->query_string().length() || |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
212
|
7
|
|
|
|
|
|
THIS->fragment().length(); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
string URI::user (SV* newval = NULL) { |
216
|
0
|
0
|
|
|
|
|
if (newval) { |
217
|
0
|
0
|
|
|
|
|
THIS->user(xs::in(newval)); |
|
|
0
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
219
|
|
|
|
|
|
|
} |
220
|
0
|
0
|
|
|
|
|
RETVAL = THIS->user(); |
|
|
0
|
|
|
|
|
|
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
string URI::password (SV* newval = NULL) { |
224
|
0
|
0
|
|
|
|
|
if (newval) { |
225
|
0
|
0
|
|
|
|
|
THIS->password(xs::in(newval)); |
|
|
0
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
XSRETURN_UNDEF; |
227
|
|
|
|
|
|
|
} |
228
|
0
|
0
|
|
|
|
|
RETVAL = THIS->password(); |
|
|
0
|
|
|
|
|
|
229
|
|
|
|
|
|
|
} |