当前位置: 首页>>代码示例>>C#>>正文


C# HttpServer.OSHttpResponse类代码示例

本文整理汇总了C#中OpenSim.Framework.Servers.HttpServer.OSHttpResponse的典型用法代码示例。如果您正苦于以下问题:C# OSHttpResponse类的具体用法?C# OSHttpResponse怎么用?C# OSHttpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OSHttpResponse类属于OpenSim.Framework.Servers.HttpServer命名空间,在下文中一共展示了OSHttpResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];

            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();

            Dictionary<string, object> request =
                        WebUtils.ParseQueryString(body);

            if (!request.ContainsKey("METHOD"))
                return result; //No method, no work

            string method = request["METHOD"].ToString();
            switch(method)
            {
                case "inform_neighbors_region_is_up":
                    return InformNeighborsRegionIsUp(request);
                case "inform_neighbors_region_is_down":
                    return InformNeighborsRegionIsDown(request);
                case "inform_neighbors_of_chat_message":
                    return InformNeighborsOfChatMessage(request);
                case "get_neighbors":
                    return GetNeighbors(request);
                default :
                    m_log.Warn("[NeighborHandlers]: Unknown method " + method);
                    break;
            }
            return result;
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:33,代码来源:NeighbourHandlers.cs

示例2: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string result = string.Empty;
            try
            {
                Request request = WifiUtils.CreateRequest(string.Empty, httpRequest);
                Diva.Wifi.Environment env = new Diva.Wifi.Environment(request);

                string resource = GetParam(path);
                //m_log.DebugFormat("[XXX]: resource {0}", resource);
                if (resource.StartsWith("/data/simulators"))
                {
                    result = m_WebApp.Services.ConsoleSimulatorsRequest(env);
                    httpResponse.ContentType = "application/xml";
                }
                else if (resource.StartsWith("/heartbeat"))
                {
                    result = m_WebApp.Services.ConsoleHeartbeat(env);
                    httpResponse.ContentType = "application/xml";
                }
                else
                {
                    result = m_WebApp.Services.ConsoleRequest(env);
                    httpResponse.ContentType = "text/html";
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[CONSOLE HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WifiUtils.StringToBytes(result);
        }
开发者ID:caocao,项目名称:diva-distribution,代码行数:34,代码来源:WifiConsoleHandler.cs

示例3: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();

            //m_log.DebugFormat("[XXX]: query String: {0}", body);

            try
            {
                OSDMap map = WebUtils.GetOSDMap(body);
                if (map != null)
                {
                    return NewMessage(map);
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[GRID HANDLER]: Exception {0}", e);
            }

            return FailureResult();
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:25,代码来源:MessagingServiceInPostHandler.cs

示例4: OKResponse

 private byte[] OKResponse (OSHttpResponse httpResponse)
 {
     httpResponse.AddHeader ("X-Handlers-Provided", m_HandlersType);
     httpResponse.StatusCode = (int)HttpStatusCode.OK;
     httpResponse.StatusDescription = "OK";
     return new byte[0];
 }
开发者ID:NickyPerian,项目名称:Aurora-Sim,代码行数:7,代码来源:HeloHandler.cs

示例5: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            httpResponse.ContentType = "image/jpeg";

//            StreamReader sr = new StreamReader(requestData);
//            string body = sr.ReadToEnd();
//            sr.Close();
//            body = body.Trim();

            try
            {
                lock (m_RequestLock)
                {
                    Dictionary<string, object> request =
                            new Dictionary<string, object>();
                    foreach (string name in httpRequest.QueryString)
                        request[name] = httpRequest.QueryString[name];

                    return SendWorldView(request);
                }
            }
            catch (Exception e)
            {
                m_log.Debug("[WORLDVIEW]: Exception: " + e.ToString());
            }

            return new Byte[0];
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:29,代码来源:WorldViewRequestHandler.cs

示例6: Handle

        public override byte[] Handle(string path, Stream request,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string param = GetParam(path);
            byte[] result = new byte[] {};
            try
            {
                string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries);

                if (p.Length > 0)
                {
                    UUID assetID = UUID.Zero;

                    if (!UUID.TryParse(p[0], out assetID))
                    {
                        m_log.InfoFormat(
                            "[REST]: GET:/presence ignoring request with malformed UUID {0}", p[0]);
                        return result;
                    }

                }
            }
            catch (Exception e)
            {
                m_log.Error(e.ToString());
            }
            return result;
        }
开发者ID:BogusCurry,项目名称:halcyon,代码行数:28,代码来源:XMPPHTTPService.cs

示例7: Handle

 public override byte[] Handle(string path, Stream request,
         OSHttpRequest httpRequest, OSHttpResponse httpResponse)
 {
     //Return the config map
     UTF8Encoding encoding = new UTF8Encoding();
     return encoding.GetBytes(OSDParser.SerializeJsonString(m_configMap));
 }
开发者ID:KristenMynx,项目名称:Aurora-Sim,代码行数:7,代码来源:AutoConfigurationPostHandler.cs

示例8: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[Wifi]: path = {0}", path);
            //m_log.DebugFormat("[Wifi]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);

            string result = string.Empty;
            try
            {
                Request request = WifiUtils.CreateRequest(string.Empty, httpRequest);
                Diva.Wifi.Environment env = new Diva.Wifi.Environment(request);

                result = m_WebApp.Services.LogoutRequest(env);

                httpResponse.ContentType = "text/html";
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LOGOUT HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WifiUtils.StringToBytes(result);

        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:27,代码来源:WifiLogoutHandler.cs

示例9: RESTGetUserProfile

        private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            // Check IP Endpoint Access
            if (!TrustManager.Instance.IsTrustedPeer(httpRequest.RemoteIPEndPoint))
            {
                httpResponse.StatusCode = 403;
                return ("Access is denied for this IP Endpoint");
            }

            UUID id;
            UserProfileData userProfile;

            try
            {
                id = new UUID(param);
            }
            catch (Exception)
            {
                httpResponse.StatusCode = 500;
                return "Malformed Param [" + param + "]";
            }

            userProfile = m_userDataBaseService.GetUserProfile(id);

            if (userProfile == null)
            {
                httpResponse.StatusCode = 404;
                return "Not Found.";
            }

            return ProfileToXmlRPCResponse(userProfile).ToString();
        }
开发者ID:BogusCurry,项目名称:halcyon,代码行数:32,代码来源:UserManager.cs

示例10: Handle

 public override byte[] Handle(string path, Stream request,
         OSHttpRequest httpRequest, OSHttpResponse httpResponse)
 {
     // Not implemented yet
     httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
     return new byte[] { };
 }
开发者ID:Ideia-Boa,项目名称:diva-distribution,代码行数:7,代码来源:AgentHandlers.cs

示例11: Handle

        public override byte[] Handle(string path, Stream request,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string[] p = SplitParams(path);

            if (p.Length > 0)
            {
                switch (p[0])
                {
                case "plain":
                    StreamReader sr = new StreamReader(request);
                    string body = sr.ReadToEnd();
                    sr.Close();

                    return DoPlainMethods(body);
                case "crypt":
                    byte[] buffer = new byte[request.Length];
                    long length = request.Length;
                    if (length > 16384)
                        length = 16384;
                    request.Read(buffer, 0, (int)length);

                    return DoEncryptedMethods(buffer);
                }
            }
            return new byte[0];
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:27,代码来源:AuthenticationServerPostHandler.cs

示例12: ProcessTextureRequest

        private bool ProcessTextureRequest(string param, OSHttpResponse resp)
        {
            UUID assetID;
            if (!UUID.TryParse(param, out assetID))
                return false;

            AssetBase asset = m_scene.AssetService.Get(assetID.ToString());

            if (asset == null)
                return false;

            ManagedImage tmp;
            Image imgData;
            byte[] jpegdata;

            OpenJPEG.DecodeToImage(asset.Data, out tmp, out imgData);

            using (MemoryStream ms = new MemoryStream())
            {
                imgData.Save(ms, ImageFormat.Jpeg);
                jpegdata = ms.GetBuffer();
            }

            resp.ContentType = "image/jpeg";
            resp.ContentLength = jpegdata.Length;
            resp.StatusCode = 200;
            resp.Body.Write(jpegdata, 0, jpegdata.Length);

            return true;
        }
开发者ID:intari,项目名称:OpenSimMirror,代码行数:30,代码来源:VWHClientView.cs

示例13: RESTGetUserProfile

        private string RESTGetUserProfile(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            UUID id;
            UserProfileData userProfile;

            try
            {
                id = new UUID(param);
            }
            catch (Exception)
            {
                httpResponse.StatusCode = 500;
                return "Malformed Param [" + param + "]";
            }

            userProfile = m_userDataBaseService.GetUserProfile(id);

            if (userProfile == null)
            {
                httpResponse.StatusCode = 404;
                return "Not Found.";
            }

            return ProfileToXmlRPCResponse(userProfile).ToString();
        }
开发者ID:ChrisD,项目名称:opensim,代码行数:25,代码来源:UserManager.cs

示例14: ProcessInMsg

        public bool ProcessInMsg(OSHttpRequest req, OSHttpResponse resp)
        {
            //                              0        1          2       3
            // http://simulator.com:9000/vwohttp/sessionid/methodname/param
            string[] urlparts = req.Url.AbsolutePath.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);

            UUID sessionID;
            // Check for session
            if (!UUID.TryParse(urlparts[1], out sessionID))
                return false;
            // Check we match session
            if (sessionID != SessionId)
                return false;

            string method = urlparts[2];

            string param = String.Empty;
            if (urlparts.Length > 3)
                param = urlparts[3];

            bool found;

            switch (method.ToLower())
            {
                case "textures":
                    found = ProcessTextureRequest(param, resp);
                    break;
                default:
                    found = false;
                    break;
            }

            return found;
        }
开发者ID:intari,项目名称:OpenSimMirror,代码行数:34,代码来源:VWHClientView.cs

示例15: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();

            //m_log.DebugFormat("[XXX]: query String: {0}", body);
            string method = string.Empty;
            try
            {
                Dictionary<string, object> request = new Dictionary<string, object>();
                request = WebUtils.ParseQueryString(body);
                if (request.Count == 1)
                    request = WebUtils.ParseXmlResponse(body);
                object value = null;
                request.TryGetValue("<?xml version", out value);
                if (value != null)
                    request = WebUtils.ParseXmlResponse(body);

                return ProcessAddCAP(request);
            }
            catch (Exception)
            {
            }

            return null;

        }
开发者ID:KristenMynx,项目名称:Aurora-Sim,代码行数:30,代码来源:CapsHandler.cs


注:本文中的OpenSim.Framework.Servers.HttpServer.OSHttpResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。