diff options
| author | Tom Christie | 2012-10-08 12:17:43 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-08 12:17:43 +0100 |
| commit | f4d4d54e030addf64efe68f387b934262a3c173b (patch) | |
| tree | 8ae0cbd9b33447b71ddff4c5b5dde78e43aa5236 /docs/topics/browserhacks.md | |
| parent | 6b6c945d4e71bb70cb76c85cc675cc252a6ede2b (diff) | |
| download | django-rest-framework-f4d4d54e030addf64efe68f387b934262a3c173b.tar.bz2 | |
Adding migration and changelog docs
Diffstat (limited to 'docs/topics/browserhacks.md')
| -rw-r--r-- | docs/topics/browserhacks.md | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/topics/browserhacks.md b/docs/topics/browserhacks.md new file mode 100644 index 00000000..96cb1388 --- /dev/null +++ b/docs/topics/browserhacks.md @@ -0,0 +1,43 @@ +# Browser hacks + +> "There are two noncontroversial uses for overloaded POST. The first is to *simulate* HTTP's uniform interface for clients like web browsers that don't support PUT or DELETE" +> +> — [RESTful Web Services](1), Leonard Richardson & Sam Ruby. + +## Browser based PUT, DELETE, etc... + +**TODO: Preamble.** Note that this is the same strategy as is used in [Ruby on Rails](2). + +For example, given the following form: + + <form action="/news-items/5" method="POST"> + <input type="hidden" name="_method" value="DELETE"> + </form> + +`request.method` would return `"DELETE"`. + +## Browser based submission of non-form content + +Browser-based submission of content types other than form are supported by using form fields named `_content` and `_content_type`: + +For example, given the following form: + + <form action="/news-items/5" method="PUT"> + <input type="hidden" name="_content_type" value="application/json"> + <input name="_content" value="{'count': 1}"> + </form> + +`request.content_type` would return `"application/json"`, and `request.content` would return `"{'count': 1}"` + +## URL based accept headers + +## URL based format suffixes + +## Doesn't HTML5 support PUT and DELETE forms? + +Nope. It was at one point intended to support `PUT` and `DELETE` forms, but was later [dropped from the spec](3). There remains [ongoing discussion](4) about adding support for `PUT` and `DELETE`, as well as how to support content types other than form-encoded data. + +[1]: http://www.amazon.com/Restful-Web-Services-Leonard-Richardson/dp/0596529260 +[2]: http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work +[3]: http://www.w3.org/TR/html5-diff/#changes-2010-06-24 +[4]: http://amundsen.com/examples/put-delete-forms/ |
