Package proxy :: Package redirect :: Module rhnRedirect :: Class RedirectHandler
[hide private]
[frames] | no frames]

Class RedirectHandler

source code


Spacewalk Proxy SSL Redirect specific handler code called by rhnApache.

Workflow is: Client -> Apache:Broker -> Squid -> Apache:Redirect -> Satellite

Redirect handler get all request for localhost:80 and they come from Broker handler through Squid, which hadle caching. Redirect module transform destination url to parent or http proxy. Depend on what we have in CFG.

Instance Methods [hide private]
 
__init__(self, req)
init with http request object
source code
 
_initConnectionVariables(self, _req)
set connection variables...
source code
 
handler(self)
Main handler for all requests pumped through this server.
source code
 
_handleServerResponse(self, status)
Here, we'll override the default behavior for handling server responses so that we can adequately handle 302's.
source code
 
__redirectToNextLocation(self, loopProtection=False)
This function will perform a redirection to the next location, as specified in the last response's "Location" header.
source code
 
__redirectToNextLocationNoRetry(self, loopProtection=False)
This function will perform a redirection to the next location, as specified in the last response's "Location" header.
source code
 
__redirectFailover(self)
This routine resends the original request back to the satellite/hosted system if a redirect to a 3rd party failed.
source code
Static Methods [hide private]
Method Details [hide private]

__init__(self, req)
(Constructor)

source code 

init with http request object

Overrides: rhnShared.SharedHandler.__init__
(inherited documentation)

_initConnectionVariables(self, _req)

source code 
set connection variables
NOTE: self.{caChain,rhnParent,httpProxy*} are initialized
      in SharedHandler

_handleServerResponse(self, status)

source code 

Here, we'll override the default behavior for handling server responses so that we can adequately handle 302's.

We will follow redirects unless it is redirect to (re)login page. In which case we change protocol to https and return redirect to user.

Overrides: rhnShared.SharedHandler._handleServerResponse

__redirectToNextLocation(self, loopProtection=False)

source code 
This function will perform a redirection to the next location, as
specified in the last response's "Location" header. This function will
return an actual HTTP response status code.  If successful, it will
return apache.HTTP_OK, not apache.OK.  If unsuccessful, this function
will retry a configurable number of times, as defined in
CFG.NETWORK_RETRIES.  The following codes define "success".

  HTTP_OK
  HTTP_PARTIAL_CONTENT
  HTTP_MOVED_TEMPORARILY
  HTTP_MOVED_PERMANENTLY

Upon successful completion of this function, the responseContext
should be populated with the response.

Arguments:

loopProtection - If True, this function will insert a special
               header into the new request that tells the RHN
               server not to issue another redirect to us, in case
               that's where we end up being redirected.

Return:

This function may return any valid HTTP_* response code.  See
__redirectToNextLocationNoRetry for more info.

__redirectToNextLocationNoRetry(self, loopProtection=False)

source code 
This function will perform a redirection to the next location, as
specified in the last response's "Location" header. This function will
return an actual HTTP response status code.  If successful, it will
return apache.HTTP_OK, not apache.OK.  If unsuccessful, this function
will simply return; no retries will be performed.  The following error
codes can be returned:

HTTP_OK,HTTP_PARTIAL_CONTENT - Redirect successful.
HTTP_MOVED_TEMPORARILY     - Redirect was redirected again by 3rd party.
HTTP_MOVED_PERMANENTLY     - Redirect was redirected again by 3rd party.
HTTP_INTERNAL_SERVER_ERROR - Error extracting redirect information
HTTP_SERVICE_UNAVAILABLE   - Could not connect to 3rd party server,
                             connection was reset, or a read error
                             occurred during communication.
HTTP_*                     - Any other HTTP status code may also be
                             returned.

Upon successful completion of this function, a new responseContext
will be created and pushed onto the stack.

__redirectFailover(self)

source code 

This routine resends the original request back to the satellite/hosted system if a redirect to a 3rd party failed. To prevent redirection loops from occurring, an "X-RHN-Redirect: 0" header is passed along with the request. This function will return apache.HTTP_OK if everything succeeded, otherwise it will return an appropriate HTTP error code.