Esempio n. 1
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];

            string format = string.Empty;

            result = m_MapService.GetMapTile(path.Trim('/'), out format);
            if (result.Length > 0)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.OK;
                if (format.Equals(".png"))
                {
                    httpResponse.ContentType = "image/png";
                }
                else if (format.Equals(".jpg") || format.Equals(".jpeg"))
                {
                    httpResponse.ContentType = "image/jpeg";
                }
            }
            else
            {
                httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                httpResponse.ContentType = "text/plain";
            }

            return(result);
        }
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            ev.WaitOne();
            lock (ev)
            {
                ev.Reset();
            }

            byte[] result = new byte[0];
            string format = string.Empty;

            //            UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992");
            UUID scopeID = UUID.Zero;

            // This will be map/tilefile.ext, but on multitenancy it will be
            // map/scope/teilefile.ext
            string[] bits = path.Trim('/').Split(new char[] { '/' });
            if (bits.Length > 2)
            {
                try
                {
                    scopeID = new UUID(bits[1]);
                }
                catch
                {
                    return(new byte[9]);
                }
                path = bits[2];
            }
            result = m_MapService.GetMapTile(path.Trim('/'), scopeID, out format);
            if (result.Length > 0)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.OK;
                if (format.Equals(".png"))
                {
                    httpResponse.ContentType = "image/png";
                }
                else if (format.Equals(".jpg") || format.Equals(".jpeg"))
                {
                    httpResponse.ContentType = "image/jpeg";
                }
            }
            else
            {
                httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                httpResponse.ContentType = "text/plain";
            }

            lock (ev)
            {
                ev.Set();
            }

            return(result);
        }
Esempio n. 3
0
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            if (!Monitor.TryEnter(ev, 5000))
            {
                httpResponse.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
                httpResponse.AddHeader("Retry-After", "10");
                return(new byte[0]);
            }

            byte[] result = new byte[0];
            string format = string.Empty;

            //UUID scopeID = new UUID("07f8d88e-cd5e-4239-a0ed-843f75d09992");
            UUID scopeID = UUID.Zero;

            // This will be map/tilefile.ext, but on multitenancy it will be
            // map/scope/teilefile.ext
            path = path.Trim('/');
            string[] bits = path.Split(new char[] { '/' });
            if (bits.Length > 2)
            {
                try
                {
                    scopeID = new UUID(bits[1]);
                }
                catch
                {
                    return(new byte[9]);
                }
                path = bits[2];
                path = path.Trim('/');
            }

            if (path.Length == 0)
            {
                httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                httpResponse.ContentType = "text/plain";
                return(new byte[0]);
            }

            result = m_MapService.GetMapTile(path, scopeID, out format);
            if (result.Length > 0)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.OK;
                if (format.Equals(".png"))
                {
                    httpResponse.ContentType = "image/png";
                }
                else if (format.Equals(".jpg") || format.Equals(".jpeg"))
                {
                    httpResponse.ContentType = "image/jpeg";
                }
            }
            else
            {
                httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                httpResponse.ContentType = "text/plain";
            }

            Monitor.Exit(ev);

            return(result);
        }