Issue Details (XML | Word | Printable)

Key: MODPYTHON-141
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
mod_python

Allow handlers to trigger proxying of requests.

Created: 03/Mar/06 06:52 PM   Updated: 11/Apr/07 11:32 AM
Component/s: core
Affects Version/s: 3.3.x
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Resolution Date: 07/Mar/06 09:36 AM


 Description  « Hide
The req.proxyreq and req.uri attributes are not currently modifiable. If they were modifable, it would be possible for a mod_python handler to trigger proxying of a request to some remote site. For example:

import posixpath

from mod_python import apache

def fixuphandler(req):

  if req.proxyreq:
    return apache.DECLINED

  normalised_uri = posixpath.normpath(req.uri)

  if normalised_uri:
    if normalised_uri != '/' and req.uri[-1] == '/':
      normalised_uri += '/'

  length = len(req.filename)
  length -= len(req.hlist.directory) - 1
  length += len(req.path_info or '')

  baseurl = normalised_uri[:-length]
  path = normalised_uri[len(baseurl):]

  req.proxyreq = apache.PROXYREQ_REVERSE
  req.uri = 'http://www.dscpl.com.au' + path
  req.filename = 'proxy:%s' % req.uri
  req.handler = 'proxy-server'

  return apache.OK

See further discussion on mailing list:

  http://www.modpython.org/pipermail/mod_python/2006-March/020500.html
  http://www.modpython.org/pipermail/mod_python/2006-March/020502.html
  http://www.modpython.org/pipermail/mod_python/2006-March/020503.html
  http://www.modpython.org/pipermail/mod_python/2006-March/020507.html

Patches are include in the last of these emails rather than being attached here.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.