* Extracted request-response handling

adam
lbsa71 2007-03-16 20:46:53 +00:00
parent 3147def23f
commit 59e7586558
1 changed files with 119 additions and 112 deletions

View File

@ -168,7 +168,32 @@ namespace OpenSim.GridServers
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
if(request.MethodName == "login_to_simulator")
{
XmlRpcResponse response = ProcessRequest(request);
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");
writer.WriteLine("Content-type: text/xml");
writer.WriteLine();
XmlTextWriter responseWriter = new XmlTextWriter(writer);
XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
responseWriter.Close();
}
else
{
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
writer.WriteLine();
}
}
}
private XmlRpcResponse ProcessRequest(XmlRpcRequest request)
{
XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
string passwd;
@ -203,9 +228,6 @@ namespace OpenSim.GridServers
passwd = "notfound";
}
XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
Hashtable responseData = (Hashtable)response.Value;
if( !Authenticate(first, last, passwd))
{
responseData["reason"] = "key";
@ -277,22 +299,7 @@ namespace OpenSim.GridServers
((LocalGridBase)this._gridServer).AddNewSession(_login);
}
}
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");
writer.WriteLine("Content-type: text/xml");
writer.WriteLine();
XmlTextWriter responseWriter = new XmlTextWriter(writer);
XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
responseWriter.Close();
}
else
{
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
writer.WriteLine();
}
}
return response;
}
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )