| 1 | package URI::Coralize; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use URI (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | our $VERSION = '0.01'; | |||||||||
| 9 | 2 | $VERSION = eval $VERSION; | |||||||||
| 10 | |||||||||||
| 11 | 5 | ▶ | sub URI::coralize { | ||||||||
|
Subroutine
coralize: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||
| 12 | 5 | my ($uri) = @_; | |||||||||
| 13 | |||||||||||
| 14 | # CoralCDN doesn't proxy secure requests and simply redirects to the | ||||||||||
| 15 | # requested resource. | ||||||||||
| 16 | 5 | ▶ | return $uri if 'http' ne $uri->scheme; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | 4 | my $host = eval { $uri->host }; | |||||||||
| 19 | 4 | ▶ | return $uri unless $host; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | # Don't coralize the coralized. | ||||||||||
| 22 | 4 | ▶ | return $uri if $host =~ m[ (?:^ | \.) nyud.net $]x; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 3 | my $new = $uri->clone; | |||||||||
| 25 | |||||||||||
| 26 | 3 | ▶ | if (80 != $uri->port) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 1 | $host .= '.' . $uri->port; | |||||||||
| 28 | 1 | $new->port(undef); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 3 | $host .= '.nyud.net'; | |||||||||
| 32 | |||||||||||
| 33 | 3 | $new->host($host); | |||||||||
| 34 | |||||||||||
| 35 | 3 | return $new; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | 2 | 1; | |||||||||
| 40 | |||||||||||
| 41 | __END__ | ||||||||||