Ticket #13876: 13876.diff

File 13876.diff, 1.5 KB (added by Horst Gutmann, 14 years ago)
  • docs/ref/request-response.txt

    diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
    index 2c874a1..2118d82 100644
    a b file-like object::  
    407407    >>> response.write("<p>Here's the text of the Web page.</p>")
    408408    >>> response.write("<p>Here's another paragraph.</p>")
    409409
    410 You can add and delete headers using dictionary syntax::
    411 
    412     >>> response = HttpResponse()
    413     >>> response['X-DJANGO'] = "It's the best."
    414     >>> del response['X-PHP']
    415     >>> response['X-DJANGO']
    416     "It's the best."
    417 
    418 Note that ``del`` doesn't raise ``KeyError`` if the header doesn't exist.
    419 
    420410Passing iterators
    421411~~~~~~~~~~~~~~~~~
    422412
    To set a header in your response, just treat it like a dictionary::  
    436426    >>> response = HttpResponse()
    437427    >>> response['Cache-Control'] = 'no-cache'
    438428
    439 .. versionadded:: 1.1
    440 
    441429HTTP headers cannot contain newlines. An attempt to set a header containing a
    442430newline character (CR or LF) will raise ``BadHeaderError``
    443431
     432Since you can treat the response object like a dictionary when it comes to
     433headers, you can also delete headers using ``del``::
     434
     435    >>> response = HttpResponse()
     436    >>> response['X-DJANGO'] = "It's the best."
     437    >>> del response['X-DJANGO']
     438
     439Note that ``del`` doesn't raise ``KeyError`` if the header doesn't exist.
     440
     441.. versionadded:: 1.1
     442
    444443Telling the browser to treat the response as a file attachment
    445444~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    446445
Back to Top