Changeset 11216

Show
Ignore:
Timestamp:
08/17/08 17:14:37 (5 months ago)
Author:
/C=ES/O=Warp Networks S.L./CN=juruen@…
Message:

+ Bugfix. Create redirection URLs using client headers and guessing checking

the protocol (HTTP or HTTPS)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/common/libebox/src/EBox/CGI/Base.pm

    r10308 r11216  
    305305 
    306306        if ((defined($self->{redirect})) && (!defined($self->{error}))) { 
    307                 my $request = Apache2::RequestUtil->request(); 
    308                 my $headersIn = $request->headers_in();  
    309                 my $localAddr = $request->connection()->local_ip(); 
    310                 my $portStr = ''; 
    311                 # If the connection comes from a Proxy, redirects with the Proxy IP address 
    312                 if ( exists $headersIn->{Via} and exists $headersIn->{'X-Forwarded-Host'}) { 
    313                     $localAddr = $headersIn->{'X-Forwarded-Host'}; 
    314                 } else { 
    315                     my $apachePort = EBox::Global->getInstance(1)->modInstance('apache')->port(); 
    316                     if ( $apachePort != 443 ) { 
    317                         $portStr = ":$apachePort"; 
    318                     } 
    319                 } 
    320                 print($self->cgi()->redirect("https://${localAddr}${portStr}/ebox/" . $self->{redirect})); 
    321                 EBox::debug("redirect: " . $self->{redirect}); 
     307                my $request = Apache2::RequestUtil->request(); 
     308                my $headers = $request->headers_in(); 
     309                my $via = $headers->{'Via'};  
     310                my $host= $headers->{'Host'}; 
     311                my $fwhost = $headers->{'X-Forwaded-Host'}; 
     312                # If the connection comes from a Proxy,  
     313                # redirects with the Proxy IP address 
     314                if (defined($via) and defined($fwhost)) { 
     315                        $host = $fwhost;  
     316                } 
     317                my $protocol;  
     318                if ($request->->subprocess_env('https')) { 
     319                        $protocol = 'https'; 
     320                } else { 
     321                        $protocol = 'http'; 
     322                } 
     323                my $url = "$protocol://${host}/ebox/" . $self->{redirect}; 
     324                print($self->cgi()->redirect($url)); 
    322325                return; 
    323326        }  
     
    325328         
    326329 
    327         try  {  
     330        try  { $url 
    328331          settextdomain('ebox'); 
    329332          $self->_print