I have a project on Django 1.3 + piston for API. This is the code of GET handler:
listen_resource = Resource( ListenHandler )
urlpatterns = patterns('',
url( r'^listen/(?P<expression>.*)$', listen_resource ),
)
class ListenHandler(BaseHandler):
def read( self, request, expression ):
retval = {}
print expression
try:
j_data = simplejson.loads(expression)
...
The Get request usually is a JSON formatted string like this:
/api/listen/%7B%22act%22:%221%22,%22login%22:%22Terminal_001%22,%22passw%22:%2211223344%22,%22body%22:%22%7B%5C%22date%5C%22:%5C%222011-09-14%2016:34:26%5C%22,%5C%22link%5C%22:%5C%220%5C%22%7D%22%7D
when I print it:
print expression
while running project by Eclipse IDE on development server, the 开发者_如何学JAVAresult is :
{"act":"1","login":"Terminal_001","passw":"11223344","body":"{\"date\":\"2011-09-13 16:59:31\",\"link\":\"0\"}"}
and I can create object from this Json formatted string:
j_data = simplejson.loads(expression)
But while running project on Apache server + mod_wsgi, the result is :
{"act":"1","login":"Terminal_001","passw":"11223344","body":"{/"date/":/"2011-09-13 17:46:42/",/"link/":/"0/"}"}
the Backslashes are replaced by slash and operation simplejson.loads(expression)
is raising exception :
<type 'exceptions.ValueError'>
('Expecting , delimiter: line 1 column 64 (char 64)',)
In Apache server conf file I added this line AllowEncodedSlashes On
please help to solve this issue.
I solved it by updating apache, problem was in this bug https://issues.apache.org/bugzilla/show_bug.cgi?id=35256
精彩评论