~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/http/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
            current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http',
73
73
                                         self.get_host(), self.path)
74
74
            location = urljoin(current_uri, location)
75
 
        return location
 
75
        return iri_to_uri(location)
76
76
 
77
77
    def is_secure(self):
78
78
        return os.environ.get("HTTPS") == "on"
189
189
        for key, value in dict.items(self):
190
190
            dict.__setitem__(result, copy.deepcopy(key, memo), copy.deepcopy(value, memo))
191
191
        return result
192
 
 
 
192
    
193
193
    def setlist(self, key, list_):
194
194
        self._assert_mutable()
195
195
        key = str_to_unicode(key, self.encoding)
263
263
        cookiedict[key] = c.get(key).value
264
264
    return cookiedict
265
265
 
 
266
class BadHeaderError(ValueError):
 
267
    pass
 
268
 
266
269
class HttpResponse(object):
267
270
    """A basic HTTP response, with content and dictionary-accessed headers."""
268
271
 
303
306
        for value in values:
304
307
            if isinstance(value, unicode):
305
308
                try:
306
 
                    yield value.encode('us-ascii')
 
309
                    value = value.encode('us-ascii')
307
310
                except UnicodeError, e:
308
311
                    e.reason += ', HTTP response headers must be in US-ASCII format'
309
312
                    raise
310
313
            else:
311
 
                yield str(value)
 
314
                value = str(value)
 
315
            if '\n' in value or '\r' in value:
 
316
                raise BadHeaderError("Header values can't contain newlines (got %r)" % (value))
 
317
            yield value
312
318
 
313
319
    def __setitem__(self, header, value):
314
320
        header, value = self._convert_to_ascii(header, value)
398
404
 
399
405
    def __init__(self, redirect_to):
400
406
        HttpResponse.__init__(self)
401
 
        self['Location'] = iri_to_uri(redirect_to)
 
407
        self['Location'] = redirect_to
402
408
 
403
409
class HttpResponsePermanentRedirect(HttpResponse):
404
410
    status_code = 301
405
411
 
406
412
    def __init__(self, redirect_to):
407
413
        HttpResponse.__init__(self)
408
 
        self['Location'] = iri_to_uri(redirect_to)
 
414
        self['Location'] = redirect_to
409
415
 
410
416
class HttpResponseNotModified(HttpResponse):
411
417
    status_code = 304