/usr/lib/perl5/APR/URI.pm is in libapache2-mod-perl2 2.0.8+httpd24-r1449661-6ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | #
# /*
# * *********** WARNING **************
# * This file generated by ModPerl::WrapXS/0.01
# * Any changes made here will be lost
# * ***********************************
# * 01: lib/ModPerl/Code.pm:709
# * 02: lib/ModPerl/WrapXS.pm:633
# * 03: lib/ModPerl/WrapXS.pm:1182
# * 04: Makefile.PL:427
# * 05: Makefile.PL:329
# * 06: Makefile.PL:58
# */
#
package APR::URI;
use strict;
use warnings FATAL => 'all';
use APR ();
use APR::XSLoader ();
our $VERSION = '0.009000';
APR::XSLoader::load __PACKAGE__;
1;
__END__
=head1 NAME
APR::URI - Perl API for URI manipulations
=head1 Synopsis
use APR::URI ();
my $url = 'http://user:pass@example.com:80/foo?bar#item5';
# parse and break the url into components
my $parsed = APR::URI->parse($r->pool, $url);
print $parsed->scheme;
print $parsed->user;
print $parsed->password;
print $parsed->hostname;
print $parsed->port;
print $parsed->path;
print $parsed->rpath;
print $parsed->query;
print $parsed->fragment;
# reconstruct the url, after changing some components and completely
# removing other
$parsed->scheme($new_scheme);
$parsed->user(undef);
$parsed->password(undef);
$parsed->hostname($new_hostname);
$parsed->port($new_port);
$parsed->path($new_path);
$parsed->query(undef);
$parsed->fragment(undef);
print $parsed->unparse;
# get the password field too (by default it's not revealed)
use APR::Const -compile => qw(URI_UNP_REVEALPASSWORD);
print $parsed->unparse(APR::Const::URI_UNP_REVEALPASSWORD);
# what the default port for the ftp protocol?
my $ftp_port = APR::URI::port_of_scheme("ftp");
=head1 Description
C<APR::URI> allows you to parse URI strings, manipulate each of the
URI elements and deparse them back into URIs.
All C<APR::URI> object accessors accept a string or an C<undef> value
as an argument. Same goes for return value. It's important to
distinguish between an empty string and C<undef>. For example let's
say your code was:
my $uri = 'http://example.com/foo?bar#item5';
my $parsed = APR::URI->parse($r->pool, $uri);
Now you no longer want to the query and fragment components in the
final url. If you do:
$parsed->fragment('');
$parsed->query('');
followed by:
my $new_uri = parsed->unparse;
the resulting URI will be:
http://example.com/foo?#
which is probably not something that you've expected. In order to get
rid of the separators, you must completely unset the fields you don't
want to see. So, if you do:
$parsed->fragment(undef);
$parsed->query(undef);
followed by:
my $new_uri = parsed->unparse;
the resulting URI will be:
http://example.com/foo
As mentioned earlier the same goes for return values, so continuing
this example:
my $new_fragment = $parsed->fragment();
my $new_query = $parsed->query();
Both values now contain C<undef>, therefore you must be careful when
using the return values, when you use them, as you may get warnings.
Also make sure you read through C<L<the unparse()
section|/C_unparse_>> as various optional flags affect how the
deparsed URI is rendered.
=head1 API
C<APR::URI> provides the following functions and/or methods:
=head2 C<fragment>
Get/set trailing "#fragment" string
$oldval = $parsed->fragment($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<hostinfo>
Get/set combined C<[user[:password]@]host[:port]>
$oldval = $parsed->hostinfo($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
The C<hostinfo> value is set automatically when
C<L<parse()|/C_parse_>> is called.
It's not updated if any of the individual fields is modified.
It's not used when C<L<unparse()|/C_unparse_>> is called.
=head2 C<hostname>
Get/set hostname
$oldval = $parsed->hostname($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<password>
Get/set password (as in http://user:password@host:port/)
$oldval = $parsed->password($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<parse>
Parse the URI string into URI components
$parsed = APR::URI->parse($pool, $uri);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object or class|docs::2.0::api::APR::URI>> )
=item arg1: C<$pool> ( string )
( C<L<APR::Pool object|docs::2.0::api::APR::Pool>> )
=item arg2: C<$uri> ( string )
The URI to parse
=item ret: C<$parsed>
( C<L<APR::URI object or class|docs::2.0::api::APR::URI>> )
The parsed URI object
=item since: 2.0.00
=back
After parsing, if a component existed but was an empty string
(e.g. empty query I<http://hostname/path?>) -- the corresponding
accessor will return an empty string. If a component didn't exist
(e.g. no query part I<http://hostname/path>) -- the corresponding
accessor will return C<undef>.
=head2 C<path>
Get/set the request path
$oldval = $parsed->path($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
C<"/"> if only C<scheme://host>
=item since: 2.0.00
=back
=head2 C<rpath>
Gets the C<L<path|/C_path_>> minus the
C<L<path_info|docs::2.0::api::Apache2::RequestRec/C_path_info_>>
$rpath = $parsed->rpath();
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
The path minus the I<path_info>
=item since: 2.0.00
=back
=head2 C<port>
Get/set port number
$oldval = $parsed->port($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( number or string or undef )
=item ret: C<$oldval> ( string or undef )
If the port component didn't appear in the parsed URI, APR internally
calls C<L<port_of_scheme()|/C_port_of_scheme_>> to find out the port
number for the given C<L<scheme()|/C_scheme_>>.
=item since: 2.0.00
=back
=head2 C<port_of_scheme>
Return the default port for a given scheme. The recognized schemes
are http, ftp, https, gopher, wais, nntp, snews and prospero.
$port = APR::URI::port_of_scheme($scheme);
=over 4
=item obj: C<$scheme> ( string )
The scheme string
=item ret: C<$port> (integer)
The default port for this scheme
=item since: 2.0.00
=back
=head2 C<query>
Get/set the query string (the part starting after C<'?'> and all the
way till the end or the C<'#fragment'> part if the latter exists).
$oldval = $parsed->query($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<scheme>
Get/set the protocol scheme ("http", "ftp", ...)
$oldval = $parsed->scheme($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<user>
Get/set user name (as in http://user:password@host:port/)
$oldval = $parsed->user($newval);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$newval> ( string or undef )
=item ret: C<$oldval> ( string or undef )
=item since: 2.0.00
=back
=head2 C<unparse>
Unparse the URI components back into a URI string
$new_uri = $parsed->unparse();
$new_uri = $parsed->unparse($flags);
=over 4
=item obj: C<$parsed>
( C<L<APR::URI object|docs::2.0::api::APR::URI>> )
=item opt arg1: C<$flags> ( L<the APR::Const :uri
constants|docs::2.0::api::APR::Const/C__uri_> )
By default the constant C<APR::Const::URI_UNP_OMITPASSWORD> is passed.
If you need to pass more than one flag use unary C<|>, e.g.:
$flags = APR::Const::URI_UNP_OMITUSER|APR::Const::URI_UNP_OMITPASSWORD;
The valid C<flags> constants are listed next
=item ret: C<$new_uri> ( string )
=item since: 2.0.00
=back
Valid C<flags> constants:
To import all URI constants you could do:
use APR::Const -compile => qw(:uri);
but there is a significant amount of them, most irrelevant to this
method. Therefore you probably don't want to do that. Instead specify
explicitly the ones that you need. All the relevant to this method
constants start with C<APR::URI_UNP_>.
And the available constants are:
=over 4
=item C<APR::Const::URI_UNP_OMITSITEPART>
Don't show C<L<scheme|/C_scheme_>>, C<L<user|/C_user_>>,
C<L<password|/C_password_>>, C<L<hostname|/C_hostname_>> and
C<L<port|/C_port_>> components (i.e. if you want only the relative
URI)
=item C<APR::Const::URI_UNP_OMITUSER>
Hide the C<L<user|/C_user_>> component
=item C<APR::Const::URI_UNP_OMITPASSWORD>
Hide the C<L<password|/C_password_>> component (the default)
=item C<APR::Const::URI_UNP_REVEALPASSWORD>
Reveal the C<L<password|/C_password_>> component
=item C<APR::Const::URI_UNP_OMITPATHINFO>
Don't show C<L<path|/C_path_>>, C<L<query|/C_query_>> and
C<L<fragment|/C_fragment_>> components
=item C<APR::Const::URI_UNP_OMITQUERY>
Don't show C<L<query|/C_query_>> and C<L<fragment|/C_fragment_>>
components
=back
Notice that some flags overlap.
If the optional C<$flags> argument is passed and contains no
C<APR::Const::URI_UNP_OMITPASSWORD> and no C<APR::Const::URI_UNP_REVEALPASSWORD> --
the C<L<password|/C_password_>> part will be rendered as a literal
C<"XXXXXXXX"> string.
If the C<L<port|/C_port_>> number matches the
C<L<port_of_scheme()|/C_port_of_scheme_>>, the unparsed URI won't
include it and there is no flag to force that C<L<port|/C_port_>> to
appear. If the C<L<port|/C_port_>> number is non-standard it will show
up in the unparsed string.
Examples:
Starting with the parsed URL:
use APR::URI ();
my $url = 'http://user:pass@example.com:80/foo?bar#item5';
my $parsed = APR::URI->parse($r->pool, $url);
deparse it back including and excluding parts, using different values
for the optional C<flags> argument:
=over 4
=item *
Show all but the C<L<password|/C_password_>> fields:
print $parsed->unparse;
Prints:
http://user@example.com/foo?bar#item5
Notice that the C<L<port|/C_port_>> field is gone too, since it was a
default C<L<port|/C_port_of_scheme_>> for C<L<scheme|/C_scheme_>>
C<http://>.
=item *
Include the C<L<password|/C_password_>> field (by default it's not revealed)
use APR::Const -compile => qw(URI_UNP_REVEALPASSWORD);
print $parsed->unparse(APR::Const::URI_UNP_REVEALPASSWORD);
Prints:
http://user:pass@example.com/foo?bar#item5
=item *
Show all fields but the last three, C<L<path|/C_path_>>,
C<L<query|/C_query_>> and C<L<fragment|/C_fragment_>>:
use APR::Const -compile => qw(URI_UNP_REVEALPASSWORD
APR::Const::URI_UNP_OMITPATHINFO);
print $parsed->unparse(
APR::Const::URI_UNP_REVEALPASSWORD|URI_UNP_OMITPATHINFO);
Prints:
http://user:pass@example.com
=back
=head1 See Also
C<L<Apache2::URI|docs::2.0::api::Apache2::URI>>, L<mod_perl 2.0
documentation|docs::2.0::index>.
=head1 Copyright
mod_perl 2.0 and its core modules are copyrighted under
The Apache Software License, Version 2.0.
=head1 Authors
L<The mod_perl development team and numerous
contributors|about::contributors::people>.
=cut
|