diff options
| author | Tom Christie | 2012-10-17 22:39:07 +0100 | 
|---|---|---|
| committer | Tom Christie | 2012-10-17 22:39:07 +0100 | 
| commit | fb56f215ae50da0aebe99e05036ece259fd3e6f1 (patch) | |
| tree | 1566a18e4b4ad03a094c2c630b57d1530a9245d7 /docs/api-guide | |
| parent | 4231995fbd80e45991975ab81d9e570a9f4b72d0 (diff) | |
| download | django-rest-framework-fb56f215ae50da0aebe99e05036ece259fd3e6f1.tar.bz2 | |
Added `media_type` to `.parse()` - Consistency with renderer API.
Diffstat (limited to 'docs/api-guide')
| -rw-r--r-- | docs/api-guide/parsers.md | 10 | 
1 files changed, 8 insertions, 2 deletions
| diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md index 70abad9b..18a5872c 100644 --- a/docs/api-guide/parsers.md +++ b/docs/api-guide/parsers.md @@ -101,6 +101,12 @@ The arguments passed to `.parse()` are:  A stream-like object representing the body of the request. +### media_type + +Optional.  If provided, this is the media type of the incoming request. + +Depending on the request's `Content-Type:` header, this may be more specific than the renderer's `media_type` attribute, and may include media type parameters.  For example `"text/plain; charset=utf-8"`. +  ### parser_context  Optional.  If supplied, this argument will be a dictionary containing any additional context that may be required to parse the request content. @@ -118,7 +124,7 @@ The following is an example plaintext parser that will populate the `request.DAT      media_type = 'text/plain' -    def parse(self, stream, parser_context=None): +    def parse(self, stream, media_type=None, parser_context=None):          """          Simply return a string representing the body of the request.          """ @@ -135,7 +141,7 @@ For example:          A naive raw file upload parser.          """ -        def parse(self, stream, parser_context): +        def parse(self, stream, media_type=None, parser_context=None):              content = stream.read()              name = 'example.dat'              content_type = 'application/octet-stream' | 
