问题描述
- Django 接入微信post方法时报错
-
code 400, message Bad request syntax ('x00xb3x02x00x0cx00QUERY_STRINGWx00signature=a78c2ca4ca9a2594bf54fdda6727e9bf1151229a×tamp=1457662563&nonce=755200386x0ex00REQUEST_METHODx04x00POSTx0cx00CONTENT_TYPEx08x00text/xmlx0ex00CONTENT_LENGTHx03x00318x0bx00REQUEST_URIfx00/wechat_access?signature=a78c2ca4ca9a2594bf54fdda6727e9bf1151229a×tamp=1457662563&nonce=755200386tx00PATH_INFOx0ex00/wechat_accessrx00DOCUMENT_ROOTx15x00/usr/share/nginx/htmlx0fx00SERVER_PROTOCOLx08x00HTTP/1.0x0cx00UWSGI_SCHEMEx04x00httpx0bx00REMOTE_ADDRx0ex00182.254.86.156x0bx00REMOTE_PORTx05x0042845x0bx00SERVER_PORTx02x0080x0bx00SERVER_NAMEx0bx00bfy.sozi.itx0cx00UWSGI_SCHEMEx04x00httpx0fx00SERVER_SOFTWAREx0bx00nginx/1.4.6x0fx00HTTP_USER_AGENTx0bx00Mozilla/4.0x0bx00HTTP_ACCEPTx03x00*/*tx00HTTP_HOSTx0bx00bfy.sozi.itx0bx00HTTP_PRAGMAx08x00no-cachex13x00HTTP_CONTENT_LENGTHx03x00318x11x00HTTP_CONTENT_TYPEx08x00text/xml<![CDATA[gh_f24247160fad]]>')
Exception happened during processing of request from ('127.0.0.1', 34316)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 129, in init
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 649, in init
self.handle()
File "/usr/lib/python2.7/wsgiref/simple_server.py", line 117, in handle
if not self.parse_request(): # An error code has been sent, just exit
File "/usr/lib/python2.7/BaseHTTPServer.py", line 286, in parse_request
self.send_error(400, "Bad request syntax (%r)" % requestline)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 368, in send_error
self.send_response(code, message)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 385, in send_response
self.log_request(code)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 422, in log_request
self.requestline, str(code), str(size))
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 136, in log_message
msg = "[%s] %sn" % (self.log_date_time_string(), format % args)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 2: ordinal not in range(128)
解决方案
注意微信服务器上的设置,URL最后的/存不存在