﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12432	After setting encoding in view, request.REQUEST is not deleted	Xia Kai(夏恺)	nobody	"=== Steps to repeat this bug ===

{{{
#!python
>>> str = ""msg=%28%D0%A1%C3%B7%C9%B3%29""     # GBK encoded URL.
>>> from django.core.handlers.wsgi import WSGIRequest
>>> fakeenv = {'QUERY_STRING': str, 'REQUEST_METHOD': 'GET'}
>>> request = WSGIRequest(fakeenv)
>>> request.encoding        # This would return nothing, meaning no encoding is set yet.
>>> request.GET['msg']    
u'(\u0421\xf7\u0273)'
>>> request.REQUEST['msg']
u'(\u0421\xf7\u0273)'       # This is not correctly decoded, which is accepted, because no encoding is given.
>>> request.encoding = ""GBK""# Set encoding
>>> request.GET['msg']  
u'(\u5c0f\u6885\u6c99)'     # GET is deleted and regenerated, so it's decoded correctly.
>>> request.REQUEST['msg']
u'(\u0421\xf7\u0273)'       # This is not acceptable, for we have provided the correct encoding.
}}}

=== Affected Code ===
The problem is, in the definition of HTTPRequest class, a _set_encoding method is provided, which would delete GET and POST after view function have provided encoding information. When the view function ask for GET and POST again, they would be re-generated. However, both modpython and wsgi request class added a shortcut dictionary named REQUEST, which is not deleted upon encoding change.

IMHO, design decision would be required as to whether to add request.REQUEST into the base HTTPRequest class and modify the _set_encoding function, or to override default _set_encoding method in both modpython and wsgi request class."	Bug	closed	HTTP handling	dev	Normal	wontfix	encoding request.REQUEST http	xiaket@…	Accepted	0	0	0	0	0	0
