Please sign in to comment.
Respond to Flash uploads with header Content-Type: application/json
Uploading files via Flash for Windows uses an Accept header of text/* and there's no way to override it. @expose('json') insists on returning a Content-Type of application/json. TurboGears2 can't cope with returning a Content-Type that doesn't match the Accept header. It doesn't throw a 403 Not Acceptable response, it dies with a 500 error. This logic was buried in controller code so extending wasn't a viable option. We decided to just return text/plain. Pylons 0.10 happily responds with application/json despite it not matching the Accept text/* header from Flash. To simplify things, we're taking advantage of this flexibility and returning application/json even though Flash didn't explicitly request it. This works fine but if we want to ensure we're returning acceptable headers at all times, we should improve the expose decorator rather than handling it in every controller that uses a Flash uploader. This also removes the need for the helper best_json_content_type, which relied on a mimeparse function that was removed in Paste 1.7.3.
- Loading branch information...
Showing with 11 additions and 95 deletions.