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


C# HttpServer.OSHttpRequest类代码示例

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


OSHttpRequest类属于OpenSim.Framework.Servers.HttpServer命名空间,在下文中一共展示了OSHttpRequest类的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 request,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
            AssetBase asset = (AssetBase) xs.Deserialize(request);

            IGridRegistrationService urlModule =
                            m_registry.RequestModuleInterface<IGridRegistrationService>();
            if (urlModule != null)
                if (!urlModule.CheckThreatLevel("", m_regionHandle, "Asset_Update", ThreatLevel.Full))
                    return new byte[0];
            string[] p = SplitParams(path);
            if (p.Length > 1)
            {
                bool result =
                        m_AssetService.UpdateContent(p[1], asset.Data);

                xs = new XmlSerializer(typeof(bool));
                return WebUtils.SerializeResult(xs, result);
            }

            string id = m_AssetService.Store(asset);

            xs = new XmlSerializer(typeof(string));
            return WebUtils.SerializeResult(xs, id);
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:26,代码来源:AssetServerPostHandler.cs

示例4: 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

示例5: Handle

        public override byte[] Handle(string path, Stream requestData,
                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string resource = GetParam(path);
            //m_log.DebugFormat("[Wifi]: resource {0}", resource);
            resource = resource.Trim(WifiUtils.DirectorySeparatorChars);
            string resourcePath = System.IO.Path.Combine(m_LocalPath, resource);
            resourcePath = Uri.UnescapeDataString(resourcePath);

            string type = WifiUtils.GetContentType(resource);
            httpResponse.ContentType = type;
            //m_log.DebugFormat("[Wifi]: ContentType {0}", type);
            if (type.StartsWith("image"))
                return WifiUtils.ReadBinaryResource(resourcePath);

            if (type.StartsWith("application") || type.StartsWith("text"))
            {
                string res = WifiUtils.ReadTextResource(resourcePath, true);
                return WifiUtils.StringToBytes(res);
            }

            m_log.WarnFormat("[Wifi]: Could not find resource {0} in local path {1}", resource, m_LocalPath);
            httpResponse.ContentType = "text/plain";
            string result = "Boo!";
            return WifiUtils.StringToBytes(result);
        }
开发者ID:caocao,项目名称:diva-distribution,代码行数:26,代码来源:WifiGetHandler.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)
 {
     // Not implemented yet
     httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented;
     return new byte[] { };
 }
开发者ID:Ideia-Boa,项目名称:diva-distribution,代码行数:7,代码来源:AgentHandlers.cs

示例8: 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

示例9: 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

示例10: 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]);
            httpResponse.ContentType = "text/html";
            string resource = GetParam(path);
            m_log.DebugFormat("[USER ACCOUNT HANDLER GET]: resource {0}", resource);

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

            string result = string.Empty;
            UUID userID = UUID.Zero;
            if (resource == string.Empty || resource == "/")
            {
                result = m_WebApp.Services.NewAccountGetRequest(env);
            }
            else
            {
                UUID.TryParse(resource.Trim(new char[] {'/'}), out userID);
                result = m_WebApp.Services.UserAccountGetRequest(env, userID);
            }

            return WifiUtils.StringToBytes(result);

        }
开发者ID:gumho,项目名称:diva-distribution,代码行数:30,代码来源:WifiUserAccountHandlers.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: 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

示例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: Init

        public void Init()
        {
            TestHttpRequest threq0 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 
                                                       new string[] {"text/xml"}, 
                                                       ConnectionType.KeepAlive, 4711, 
                                                       new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis"));
            threq0.Method = "GET";
            threq0.HttpVersion = HttpHelper.HTTP10;

            TestHttpRequest threq1 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 
                                                       new string[] {"text/xml"}, 
                                                       ConnectionType.KeepAlive, 4711, 
                                                       new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2"));
            threq1.Method = "POST";
            threq1.HttpVersion = HttpHelper.HTTP11;
            threq1.Headers["x-wuff"] = "wuffwuff";
            threq1.Headers["www-authenticate"] = "go away";
            
            req0 = new OSHttpRequest(new TestHttpClientContext(false), threq0);
            req1 = new OSHttpRequest(new TestHttpClientContext(false), threq1);

            rsp0 = new OSHttpResponse(new TestHttpResponse());

            ipEP0 = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 4711);

        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:26,代码来源:OSHttpTests.cs

示例15: 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


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