Ticket #11877: patch_11877.diff

File patch_11877.diff, 1.2 KB (added by arnav, 15 years ago)

patch with changes to documentation including example

  • docs/ref/request-response.txt

    diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
    index 1788e06..0540551 100644
    a b Methods  
    202202
    203203   Example: ``"127.0.0.1:8000"``
    204204
     205   Warning: The ``get_host()`` method fails when the host is behind multiple
     206   proxies. Specific middleware can be used to work around this problem, like so::
     207
     208      class MultipleProxyMiddleware(object):
     209         FORWARDED_FOR_FIELDS = [
     210         'HTTP_X_FORWARDED_FOR',
     211         'HTTP_X_FORWARDED_HOST',
     212         'HTTP_X_FORWARDED_SERVER',
     213         ]
     214         
     215         def process_request(self, request):
     216            """
     217            This middleware rewrites these proxy headers so that only the most
     218            recent proxy is used.
     219            """
     220            for field in self.FORWARDED_FOR_FIELDS:
     221               if field in request.META:
     222                  if ',' in request.META[field]:
     223                     parts = request.META[field].split(',')
     224                     request.META[field] = parts[-1].strip()
     225
     226
    205227.. method:: HttpRequest.get_full_path()
    206228
    207229   Returns the ``path``, plus an appended query string, if applicable.
Back to Top