本文整理汇总了C#中OpenSim.Framework.Servers.HttpServer.OSHttpResponse.Send方法的典型用法代码示例。如果您正苦于以下问题:C# OSHttpResponse.Send方法的具体用法?C# OSHttpResponse.Send怎么用?C# OSHttpResponse.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Framework.Servers.HttpServer.OSHttpResponse
的用法示例。
在下文中一共展示了OSHttpResponse.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoHTTPGruntWork
internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata)
{
OSHttpResponse response
= new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);
byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex));
}
finally
{
//response.OutputStream.Close();
try
{
response.OutputStream.Flush();
response.Send();
//if (!response.KeepAlive && response.ReuseContext)
// response.FreeContext();
}
catch (Exception e)
{
m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e));
}
PollServiceArgs.RequestsHandled++;
}
}
示例2: DoHTTPGruntWork
internal void DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
{
//m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
int responsecode = (int)responsedata["int_response_code"];
string responseString = (string)responsedata["str_response_string"];
string contentType = (string)responsedata["content_type"];
if (responsedata.ContainsKey("error_status_text"))
{
response.StatusDescription = (string)responsedata["error_status_text"];
}
if (responsedata.ContainsKey("http_protocol_version"))
{
response.ProtocolVersion = (string)responsedata["http_protocol_version"];
}
if (responsedata.ContainsKey("keepalive"))
{
bool keepalive = (bool)responsedata["keepalive"];
response.KeepAlive = keepalive;
}
if (responsedata.ContainsKey("reusecontext"))
response.ReuseContext = (bool) responsedata["reusecontext"];
// Cross-Origin Resource Sharing with simple requests
if (responsedata.ContainsKey("access_control_allow_origin"))
response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]);
//Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this
//and should check for NullReferenceExceptions
if (string.IsNullOrEmpty(contentType))
{
contentType = "text/html";
}
// The client ignores anything but 200 here for web login, so ensure that this is 200 for that
response.StatusCode = responsecode;
if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
{
response.RedirectLocation = (string)responsedata["str_redirect_location"];
response.StatusCode = responsecode;
}
response.AddHeader("Content-Type", contentType);
byte[] buffer;
if (!(contentType.Contains("image")
|| contentType.Contains("x-shockwave-flash")
|| contentType.Contains("application/x-oar")
|| contentType.Contains("application/vnd.ll.mesh")))
{
// Text
buffer = Encoding.UTF8.GetBytes(responseString);
}
else
{
// Binary!
buffer = Convert.FromBase64String(responseString);
}
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
m_log.Warn("[HTTPD]: Error - " + ex.Message);
}
finally
{
//response.OutputStream.Close();
try
{
response.OutputStream.Flush();
response.Send();
//if (!response.KeepAlive && response.ReuseContext)
// response.FreeContext();
}
catch (SocketException e)
{
// This has to be here to prevent a Linux/Mono crash
m_log.WarnFormat("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e);
}
catch (IOException e)
{
m_log.Warn("[BASE HTTP SERVER]: XmlRpcRequest issue: " + e.Message);
}
}
//.........这里部分代码省略.........
示例3: HandleAgentRequest
/// <summary>
/// A specific agent handler was provided. Such a handler is expecetd to have an
/// intimate, and highly specific relationship with the client. Consequently,
/// nothing is done here.
/// </summary>
/// <param name="handler"></param>
/// <param name="request"></param>
/// <param name="response"></param>
private bool HandleAgentRequest(IHttpAgentHandler handler, OSHttpRequest request, OSHttpResponse response)
{
// In the case of REST, then handler is responsible for ALL aspects of
// the request/response handling. Nothing is done here, not even encoding.
try
{
return handler.Handle(request, response);
}
catch (Exception e)
{
// If the handler did in fact close the stream, then this will blow
// chunks. So that that doesn't disturb anybody we throw away any
// and all exceptions raised. We've done our best to release the
// client.
try
{
m_log.Warn("[HTTP-AGENT]: Error - " + e.Message);
response.SendChunked = false;
response.KeepAlive = true;
response.StatusCode = (int)OSHttpStatusCode.ServerErrorInternalError;
//response.OutputStream.Close();
try
{
response.Send();
//response.FreeContext();
}
catch (SocketException f)
{
// This has to be here to prevent a Linux/Mono crash
m_log.WarnFormat(
"[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", f);
}
}
catch(Exception)
{
}
}
// Indicate that the request has been "handled"
return true;
}
示例4: HandleRequest
// public void ConvertIHttpClientContextToOSHttp(object stateinfo)
// {
// HttpServerContextObj objstate = (HttpServerContextObj)stateinfo;
// OSHttpRequest request = objstate.oreq;
// OSHttpResponse resp = objstate.oresp;
// HandleRequest(request,resp);
// }
/// <summary>
/// This methods is the start of incoming HTTP request handling.
/// </summary>
/// <param name="request"></param>
/// <param name="response"></param>
public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response)
{
if (request.HttpMethod == String.Empty) // Can't handle empty requests, not wasting a thread
{
try
{
byte[] buffer500 = SendHTML500(response);
response.Body.Write(buffer500,0,buffer500.Length);
response.Body.Close();
}
catch
{
}
return;
}
string requestMethod = request.HttpMethod;
string uriString = request.RawUrl;
int requestStartTick = Environment.TickCount;
// Will be adjusted later on.
int requestEndTick = requestStartTick;
IRequestHandler requestHandler = null;
try
{
// OpenSim.Framework.WebUtil.OSHeaderRequestID
// if (request.Headers["opensim-request-id"] != null)
// reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]);
//m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl);
Culture.SetCurrentCulture();
// // This is the REST agent interface. We require an agent to properly identify
// // itself. If the REST handler recognizes the prefix it will attempt to
// // satisfy the request. If it is not recognizable, and no damage has occurred
// // the request can be passed through to the other handlers. This is a low
// // probability event; if a request is matched it is normally expected to be
// // handled
// IHttpAgentHandler agentHandler;
//
// if (TryGetAgentHandler(request, response, out agentHandler))
// {
// if (HandleAgentRequest(agentHandler, request, response))
// {
// requestEndTick = Environment.TickCount;
// return;
// }
// }
//response.KeepAlive = true;
response.SendChunked = false;
string path = request.RawUrl;
string handlerKey = GetHandlerKey(request.HttpMethod, path);
byte[] buffer = null;
if (TryGetStreamHandler(handlerKey, out requestHandler))
{
if (DebugLevel >= 3)
LogIncomingToStreamHandler(request, requestHandler);
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
if (requestHandler is IStreamedRequestHandler)
{
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
buffer = streamedRequestHandler.Handle(path, request.InputStream, request, response);
}
else if (requestHandler is IGenericHTTPHandler)
{
//m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
Stream requestStream = request.InputStream;
Encoding encoding = Encoding.UTF8;
StreamReader reader = new StreamReader(requestStream, encoding);
string requestBody = reader.ReadToEnd();
reader.Close();
//.........这里部分代码省略.........
示例5: Engine
public void Engine()
{
OSHttpRequest req = null;
while (true)
{
try
{
// dequeue an OSHttpRequest from OSHttpServer's
// request queue
req = _queue.Dequeue();
// get a copy of the list of registered handlers
List<OSHttpHandler> handlers = _server.OSHttpHandlers;
// prune list and have it sorted from most
// specific to least specific
handlers = MatchHandlers(req, handlers);
// process req: we try each handler in turn until
// we are either out of handlers or get back a
// Pass or Done
OSHttpHandlerResult rc = OSHttpHandlerResult.Unprocessed;
foreach (OSHttpHandler h in handlers)
{
rc = h.Process(req);
// Pass: handler did not process the request,
// try next handler
if (OSHttpHandlerResult.Pass == rc) continue;
// Handled: handler has processed the request
if (OSHttpHandlerResult.Done == rc) break;
// hmm, something went wrong
throw new Exception(String.Format("[{0}] got unexpected OSHttpHandlerResult {1}", EngineID, rc));
}
if (OSHttpHandlerResult.Unprocessed == rc)
{
_log.InfoFormat("[{0}] OSHttpHandler: no handler registered for {1}", EngineID, req);
// set up response header
OSHttpResponse resp = new OSHttpResponse(req);
resp.StatusCode = (int)OSHttpStatusCode.ClientErrorNotFound;
resp.StatusDescription = String.Format("no handler on call for {0}", req);
resp.ContentType = "text/html";
// add explanatory message
StreamWriter body = new StreamWriter(resp.Body);
body.WriteLine("<html>");
body.WriteLine("<header><title>Ooops...</title><header>");
body.WriteLine(String.Format("<body><p>{0}</p></body>", resp.StatusDescription));
body.WriteLine("</html>");
body.Flush();
// and ship it back
resp.Send();
}
}
catch (Exception e)
{
_log.DebugFormat("[{0}] OSHttpHandler problem: {1}", EngineID, e.ToString());
_log.ErrorFormat("[{0}] OSHttpHandler problem: {1}", EngineID, e.Message);
}
}
}
示例6: ProcessGetTexture
private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
//m_log.DebugFormat("[GETTEXTURE]: called in {0}", m_scene.RegionInfo.RegionName);
// Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
string textureStr = query.GetOne("texture_id");
string format = query.GetOne("format");
if (m_assetService == null)
{
m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service");
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
return null;
}
UUID textureID;
if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID))
{
string[] formats;
if (format != null && format != string.Empty)
{
formats = new string[1] { format.ToLower() };
}
else
{
formats = WebUtil.GetPreferredImageTypes(httpRequest.Headers.Get("Accept"));
if (formats.Length == 0)
formats = new string[1] { DefaultFormat }; // default
}
// OK, we have an array with preferred formats, possibly with only one entry
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
foreach (string f in formats)
{
if (FetchTexture(httpRequest, httpResponse, textureID, f))
break;
}
}
else
{
m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url);
}
httpResponse.Send();
return null;
}
示例7: Process
/// <summary>
/// Invoked by OSHttpRequestPump.
/// </summary>
public override OSHttpHandlerResult Process(OSHttpRequest request)
{
XmlRpcResponse xmlRpcResponse;
string responseString;
// check whether we are interested in this request
if (!XmlRpcMethodMatch(request)) return OSHttpHandlerResult.Pass;
OSHttpResponse resp = new OSHttpResponse(request);
try
{
// reified XmlRpcRequest must still be on the whiteboard
XmlRpcRequest xmlRpcRequest = request.Whiteboard["xmlrequest"] as XmlRpcRequest;
xmlRpcResponse = _handler(xmlRpcRequest);
responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
resp.ContentType = "text/xml";
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
resp.SendChunked = false;
resp.ContentLength = buffer.Length;
resp.ContentEncoding = Encoding.UTF8;
resp.Body.Write(buffer, 0, buffer.Length);
resp.Body.Flush();
resp.Send();
}
catch (Exception ex)
{
_log.WarnFormat("[OSHttpXmlRpcHandler]: Error: {0}", ex.Message);
return OSHttpHandlerResult.Pass;
}
return OSHttpHandlerResult.Done;
}
示例8: HandleXmlRpcRequests
//.........这里部分代码省略.........
xmlRpcResponse = new XmlRpcResponse();
// Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
xmlRpcResponse.SetFault(-32603, errorMessage);
}
// if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here
response.KeepAlive = keepAlive;
}
else
{
xmlRpcResponse = new XmlRpcResponse();
// Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
xmlRpcResponse.SetFault(
XmlRpcErrorCodes.SERVER_ERROR_METHOD,
String.Format("Requested method [{0}] not found", methodName));
}
responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
}
else
{
//HandleLLSDRequests(request, response);
response.ContentType = "text/plain";
response.StatusCode = 404;
response.StatusDescription = "Not Found";
response.ProtocolVersion = "HTTP/1.0";
byte[] buf = Encoding.UTF8.GetBytes("Not found");
response.KeepAlive = false;
m_log.ErrorFormat("[BASE HTTP SERVER]: Handler not found for http request {0}", request.RawUrl);
response.SendChunked = false;
response.ContentLength64 = buf.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buf, 0, buf.Length);
}
catch (Exception ex)
{
m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
}
finally
{
try
{
response.Send();
//response.FreeContext();
}
catch (SocketException e)
{
// This has to be here to prevent a Linux/Mono crash
m_log.WarnFormat("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e);
}
catch (IOException e)
{
m_log.Warn("[BASE HTTP SERVER]: XmlRpcRequest issue: " + e.Message);
}
}
return;
//responseString = "Error";
}
}
示例9: ProcessGetTexture
private byte[] ProcessGetTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
// TODO: Change this to a config option
const string REDIRECT_URL = null;
// Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
string textureStr = query.GetOne("texture_id");
if (m_assetService == null)
{
m_log.Error("[GETTEXTURE]: Cannot fetch texture " + textureStr + " without an asset service");
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
return null;
}
UUID textureID;
if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID))
{
//m_log.DebugFormat("[GETTEXTURE]: {0}", textureID);
AssetBase texture;
if (!String.IsNullOrEmpty(REDIRECT_URL))
{
// Only try to fetch locally cached textures. Misses are redirected
texture = m_assetService.GetCached(textureID.ToString());
if (texture != null)
{
if (texture.Type != (sbyte)AssetType.Texture)
{
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
httpResponse.Send();
return null;
}
SendTexture(httpRequest, httpResponse, texture);
}
else
{
string textureUrl = REDIRECT_URL + textureID.ToString();
m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
httpResponse.RedirectLocation = textureUrl;
}
}
else
{
// Fetch locally or remotely. Misses return a 404
texture = m_assetService.Get(textureID.ToString());
if (texture != null)
{
if (texture.Type != (sbyte)AssetType.Texture)
{
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
httpResponse.Send();
return null;
}
SendTexture(httpRequest, httpResponse, texture);
}
else
{
m_log.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
}
}
}
else
{
m_log.Warn("[GETTEXTURE]: Failed to parse a texture_id from GetTexture request: " + httpRequest.Url);
}
httpResponse.Send();
return null;
}
示例10: SendHTML404
public void SendHTML404(OSHttpResponse response, string host)
{
// I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
//MSIE doesn't allow for 400 pages to show... so we send 200 for now
response.StatusCode = 200;
//response.StatusCode = 400;
response.AddHeader("Content-type", "text/html");
string responseString = GetHTTP404(host);
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.ToString());
}
finally
{
//response.OutputStream.Close();
try
{
response.Send();
//response.FreeContext();
}
catch (SocketException e)
{
// This has to be here to prevent a Linux/Mono crash
m_log.WarnFormat("[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e);
}
}
}
示例11: HandleVoxelChunkReq
string HandleVoxelChunkReq(string request, string path, string param,
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
// Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
int X, Y,Z=0;
if (!int.TryParse(query.GetOne("x"), out X) ||
!int.TryParse(query.GetOne("y"), out Y))
{
httpResponse.StatusCode = 404;
httpResponse.Send();
return null;
}
if (X < 0 ||
X > m_scene.Voxels.Width / VoxelChannel.CHUNK_SIZE_X ||
Y < 0 ||
Y > m_scene.Voxels.Length / VoxelChannel.CHUNK_SIZE_Y ||
Z < 0 ||
Z > m_scene.Voxels.Height / VoxelChannel.CHUNK_SIZE_Z)
{
httpResponse.StatusCode = 404;
httpResponse.Send();
return null;
}
SendChunk(httpRequest, httpResponse, X, Y);
httpResponse.Send();
return null;
}
示例12: ProcessGetDisplayName
/// <summary>
/// Get the user's display name, currently not used?
/// </summary>
/// <param name="mDhttpMethod"></param>
/// <param name="agentID"></param>
/// <returns></returns>
private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
//I've never seen this come in, so for now... do nothing
NameValueCollection query = HttpUtility.ParseQueryString (httpRequest.Url.Query);
string[] ids = query.GetValues ("ids");
string username = query.GetOne ("username");
OSDMap map = new OSDMap ();
OSDArray agents = new OSDArray ();
OSDArray bad_ids = new OSDArray ();
OSDArray bad_usernames = new OSDArray ();
if (ids != null)
{
foreach (string id in ids)
{
UserAccount account = m_userService.GetUserAccount (UUID.Zero, UUID.Parse (id));
if (account != null)
{
IUserProfileInfo info = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector> ().GetUserProfile (UUID.Parse (id));
if (info != null)
PackUserInfo (info, account, ref agents);
else
bad_ids.Add (id);
}
}
}
//TODO: usernames
map["agents"] = agents;
map["bad_ids"] = bad_ids;
map["bad_usernames"] = bad_usernames;
byte[] m = OSDParser.SerializeLLSDXmlBytes (map);
httpResponse.Body.Write (m, 0, m.Length);
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
httpResponse.Send ();
return null;
}
示例13: ProcessGetDisplayName
/// <summary>
/// Get the user's display name, currently not used?
/// </summary>
/// <param name = "mDhttpMethod"></param>
/// <param name = "agentID"></param>
/// <returns></returns>
private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest,
OSHttpResponse httpResponse)
{
//I've never seen this come in, so for now... do nothing
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
string[] ids = query.GetValues("ids");
string username = query.GetOne("username");
OSDMap map = new OSDMap();
OSDArray agents = new OSDArray();
OSDArray bad_ids = new OSDArray();
OSDArray bad_usernames = new OSDArray();
if (ids != null)
{
foreach (string id in ids)
{
UserAccount account = m_userService.GetUserAccount(UUID.Zero, UUID.Parse(id));
if (account != null)
{
IUserProfileInfo info =
DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
if (info != null)
PackUserInfo(info, account, ref agents);
else
PackUserInfo(info, account, ref agents);
//else //Technically is right, but needs to be packed no matter what for OS based grids
// bad_ids.Add (id);
}
}
}
else if (username != null)
{
UserAccount account = m_userService.GetUserAccount(UUID.Zero, username.Replace('.', ' '));
if (account != null)
{
IUserProfileInfo info =
DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
if (info != null)
PackUserInfo(info, account, ref agents);
else
bad_usernames.Add(username);
}
}
map["agents"] = agents;
map["bad_ids"] = bad_ids;
map["bad_usernames"] = bad_usernames;
byte[] m = OSDParser.SerializeLLSDXmlBytes(map);
httpResponse.Body.Write(m, 0, m.Length);
httpResponse.StatusCode = (int) HttpStatusCode.OK;
httpResponse.Send();
return null;
}
示例14: SendHTML500
public void SendHTML500(OSHttpResponse response)
{
// I know this statuscode is dumb, but the client doesn't respond to 404s and 500s
response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
response.AddHeader("Content-type", "text/html");
string responseString = GetHTTP500();
byte[] buffer = Encoding.UTF8.GetBytes(responseString);
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
response.ContentEncoding = Encoding.UTF8;
try
{
response.OutputStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
m_log.Warn("[BASE HTTP SERVER]: Error - " + ex.Message);
}
finally
{
//response.OutputStream.Close();
try
{
response.Send();
//response.FreeContext();
}
catch (SocketException e)
{
// This has to be here to prevent a Linux/Mono crash
m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e);
}
}
}
示例15: ProcessAvatarPickerSearch
private byte[] ProcessAvatarPickerSearch(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
{
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
string amt = query.GetOne("page-size");
string name = query.GetOne("names");
List<UserAccount> accounts = m_service.Registry.RequestModuleInterface<IUserAccountService>().GetUserAccounts(UUID.Zero, name);
if (accounts == null)
accounts = new List<UserAccount>(0);
OSDMap body = new OSDMap();
OSDArray array = new OSDArray();
foreach (UserAccount account in accounts)
{
OSDMap map = new OSDMap();
map["agent_id"] = account.PrincipalID;
IUserProfileInfo profileInfo = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
map["display_name"] = (profileInfo == null || profileInfo.DisplayName == "") ? account.Name : profileInfo.DisplayName;
map["username"] = account.Name;
array.Add(map);
}
body["agents"] = array;
byte[] m = OSDParser.SerializeLLSDXmlBytes(body);
httpResponse.Body.Write(m, 0, m.Length);
httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
httpResponse.Send();
return null;
}