我使用Django 1.6并发生以下错误:
Exception happened during processing of request from ('server ip ', 54687)
Traceback (most recent call last):
File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/Python2.7.5/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 126, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/local/Python2.7.5/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/simple_server.py", line 124, in handle
handler.run(self.server.get_app())
File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/handlers.py", line 92, in run
self.close()
File "/usr/local/Python2.7.5/lib/python2.7/wsgiref/simple_server.py", line 33, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
我从客户端程序设置cookie。为什么会这样?
创建cookie是Unity代码的客户端C#。
Dictionary<string,string> headers = www.responseHeaders;
foreach (KeyValuePair<string,string> kvPair in headers)
{
if (kvPair.Key.ToLower ().Equals ("set-cookie"))
{
string stHeader = "";
string stJoint = "";
string[] astCookie = kvPair.Value.Split (
new string[] {"; "}, System.StringSplitOptions.None);
foreach (string stCookie in astCookie)
{
if (!stCookie.Substring (0, 5).Equals ("path="))
{
stHeader += stJoint + stCookie;
stJoint = "; ";
}
}
if (stHeader.Length > 0)
{
this.hsHeader ["Cookie"] = stHeader;
}
else
{
this.hsHeader.Clear ();
}
}
}
我这样设置
WWW www = new WWW (openURL, null, this.hsHeader);
我认为服务器方面很好。 因为,从浏览器运行正常。
stHeader就像这样
csrftoken=2YiHLunt9QzqIavUbxfhp2sPVU22g3Vv; expires=Sat, 09-Apr-2016 00:11:19 GMT; Max-Age=31449600