protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                var Path = req.getServletPath();
                var Query = req.getQueryString();
                var PathAndQuery = Path;
                if (Query != null)
                    PathAndQuery += "?" + Query;

                if (PathAndQuery != "/")
                {
                    //resp.setContentType("text/html");
                    //resp.getWriter().println(
                    resp.sendRedirect(
                        GetTinEyeVersion(GetPosterLink(PathAndQuery))
                        //.ToImage()
                    );
                }
                else
                {
                    resp.setContentType("text/html");
                    resp.getWriter().println(Launch(PathAndQuery));
                }
            }
            catch
            {
                // either swallow of throw a runtime exception
            }
        }
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                var Path         = req.getServletPath();
                var Query        = req.getQueryString();
                var PathAndQuery = Path;
                if (Query != null)
                {
                    PathAndQuery += "?" + Query;
                }

                if (PathAndQuery != "/")
                {
                    //resp.setContentType("text/html");
                    //resp.getWriter().println(
                    resp.sendRedirect(
                        GetTinEyeVersion(GetPosterLink(PathAndQuery))
                        //.ToImage()
                        );
                }
                else
                {
                    resp.setContentType("text/html");
                    resp.getWriter().println(Launch(PathAndQuery));
                }
            }
            catch
            {
                // either swallow of throw a runtime exception
            }
        }
Ejemplo n.º 3
0
 public ServletWorkerRequest(HttpServlet servlet, HttpServletRequest req, HttpServletResponse resp)
     : base(req.getContextPath(), req.getServletPath(), req.getRequestURI())
 {
     _HttpServlet         = servlet;
     _HttpServletRequest  = req;
     _HttpServletResponse = resp;
 }
Ejemplo n.º 4
0
		public ServletWorkerRequest (HttpServlet servlet, HttpServletRequest req, HttpServletResponse resp)
			: base (req.getContextPath(), req.getServletPath (), req.getRequestURI ()) {

			_HttpServlet = servlet;
			_HttpServletRequest = req;
			_HttpServletResponse = resp;

		}
Ejemplo n.º 5
0
		override protected void service(HttpServletRequest req, HttpServletResponse resp)
		{
			resp.setHeader("X-Powered-By", "ASP.NET");
			resp.setHeader("X-AspNet-Version", "1.1.4322");

			String filename = getServletContext().getRealPath(req.getServletPath());
			ServletOutputStream hos;
			try {
				hos = resp.getOutputStream();
			}
			catch (java.lang.IllegalStateException e)
			{
				string mimeType = getServletContext().getMimeType(filename);
				if (mimeType == null || mimeType.StartsWith("text")) {
					sendFileUsingWriter(resp, filename);
					return;
				}
				else
					throw e;
			}
			try 
			{
				string mimeType = this.getServletContext().getMimeType(filename);
				if (mimeType == null)
					mimeType = "text/plain";
				
				resp.setContentType(mimeType);

				FileStream fis = null;
				try {
					fis = new FileStream(filename,FileMode.Open,FileAccess.Read);
					byte[] buf = new byte[4 * 1024];  // 4K buffer
					int bytesRead;
					while ((bytesRead = fis.Read(buf,0,buf.Length)) != -1 &&
						   bytesRead != 0) {
						hos.write(TypeUtils.ToSByteArray(buf), 0, bytesRead);
					}
				}
				finally {
					if (fis != null) fis.Close();
				}
			}
			catch (System.IO.FileNotFoundException e) 
			{
				resp.setStatus(404,"Object Not Found.");
				HttpException myExp = new HttpException (404, "File '" + filename + "' not found.");
				hos.print(((HttpException) myExp).GetHtmlErrorMessage ());
				hos.flush();
			}
			catch(Exception e) 
			{
				Trace.WriteLine (String.Format ("ERROR in Static File Reading {0},{1}", e.GetType (), e.Message));
				resp.setStatus(500);
				HttpException myExp = new HttpException ("Exception in Reading static file", e);
				hos.print(((HttpException) myExp).GetHtmlErrorMessage ());
				hos.flush();
			}
		}
Ejemplo n.º 6
0
        public static string GetPathAndQuery(this HttpServletRequest req)
        {
            var Path         = req.getPathInfo();
            var Query        = req.getQueryString();
            var PathAndQuery = req.getServletPath();

            if (Path != null)
            {
                PathAndQuery += Path;
            }

            if (Query != null)
            {
                PathAndQuery += "?" + Query;
            }

            return(PathAndQuery);
        }
Ejemplo n.º 7
0
    override protected void service(HttpServletRequest req, HttpServletResponse resp)
    {
        string pathInfo    = req.getRequestURI();
        string contextPath = req.getContextPath();

        if (pathInfo.Equals(contextPath) ||
            ((pathInfo.Length - contextPath.Length) == 1) &&
            pathInfo [pathInfo.Length - 1] == '/' && pathInfo.StartsWith(contextPath))
        {
            pathInfo = contextPath + req.getServletPath();
        }
        if (pathInfo.EndsWith(".aspx") ||
            pathInfo.EndsWith(".asmx") ||
            pathInfo.EndsWith(".invoke"))
        {
            base.service(req, resp);
        }
        else
        {
            staticServlet.service(req, resp);
        }
    }
Ejemplo n.º 8
0
	override protected void service (HttpServletRequest req, HttpServletResponse resp) {
		string pathInfo = req.getRequestURI ();
		string contextPath = req.getContextPath ();
		if (pathInfo.Equals (contextPath) ||
			((pathInfo.Length - contextPath.Length) == 1) &&
			pathInfo [pathInfo.Length - 1] == '/' && pathInfo.StartsWith (contextPath))
			pathInfo = contextPath + req.getServletPath ();
		if (pathInfo.EndsWith (".aspx") ||
			pathInfo.EndsWith (".asmx") ||
			pathInfo.EndsWith (".invoke")) {
			base.service (req, resp);
		}
		else {
			staticServlet.service (req, resp);
		}
	}
Ejemplo n.º 9
0
		protected override void service (HttpServletRequest req, HttpServletResponse resp)
		{
			const string assemblies = "/assemblies";
			const string getping = "getping";
			const string setping = "setping";
            const string version = "2.2";
			string servletPath = req.getServletPath ();

			if (String.CompareOrdinal (assemblies, 0, servletPath, 0, assemblies.Length) == 0) {
				if (servletPath.Length == assemblies.Length ||
						servletPath [assemblies.Length] == '/') {
					string requestURI = req.getRequestURI ();
					bool getp = requestURI.EndsWith (getping, StringComparison.Ordinal);
					if (!getp && requestURI.EndsWith (setping, StringComparison.Ordinal)) {
                        getServletContext().setAttribute(getping, version);
						getp = true;
					}

					if (getp) {
						string ping = (string) getServletContext ().getAttribute (getping);
						if (ping == null)
							ping = "0";
						resp.getOutputStream ().print (ping);
						return;
					}
				}
			}
			resp.setContentType ("text/html");

			try 
			{
				// Very important - to update Virtual Path!!!
				AppDomain servletDomain = (AppDomain)this.getServletContext().getAttribute(J2EEConsts.APP_DOMAIN);
				if (!_appVirDirInited) {
					string appVPath = req.getContextPath ();
					if (appVPath == null || appVPath.Length == 0)
						appVPath = "/";
					servletDomain.SetData (IAppDomainConfig.APP_VIRT_DIR, appVPath);
					servletDomain.SetData (".hostingVirtualPath", req.getContextPath ());
					_appVirDirInited = true;
				}

				// Put to the TLS current AppDomain of the servlet, so anyone can use it.
				[email protected](servletDomain);

				// put request to the TLS
				//Thread.SetData(_servletRequestSlot, req);
				//// put response to the TLS
				//Thread.SetData(_servletResponseSlot, resp);
				//// put the servlet object to the TLS
				//Thread.SetData(_servletSlot, this);

				resp.setHeader("X-Powered-By", "ASP.NET");
				resp.setHeader("X-AspNet-Version", "1.1.4322");

				HttpWorkerRequest gwr = new ServletWorkerRequest (this, req, resp);
				CultureInfo culture = (CultureInfo) [email protected] (req.getLocale ());
				Thread currentTread = Thread.CurrentThread;
				currentTread.CurrentCulture = culture;
				currentTread.CurrentUICulture = culture;
				HttpRuntime.ProcessRequest(gwr);
			}
			finally 
			{
				HttpContext.Current = null;
				//Thread.SetData(_servletRequestSlot, null);
				//Thread.SetData(_servletResponseSlot, null);
				//Thread.SetData(_servletSlot, null);
				[email protected]();
			}
		}
 public override string getServletPath()
 {
     return(_request.getServletPath());
 }
Ejemplo n.º 11
0
        protected override void service(HttpServletRequest req, HttpServletResponse resp)
        {
            const string assemblies  = "/assemblies";
            const string getping     = "getping";
            const string setping     = "setping";
            const string version     = "2.2";
            string       servletPath = req.getServletPath();

            if (String.CompareOrdinal(assemblies, 0, servletPath, 0, assemblies.Length) == 0)
            {
                if (servletPath.Length == assemblies.Length ||
                    servletPath [assemblies.Length] == '/')
                {
                    string requestURI = req.getRequestURI();
                    bool   getp       = requestURI.EndsWith(getping, StringComparison.Ordinal);
                    if (!getp && requestURI.EndsWith(setping, StringComparison.Ordinal))
                    {
                        getServletContext().setAttribute(getping, version);
                        getp = true;
                    }

                    if (getp)
                    {
                        string ping = (string)getServletContext().getAttribute(getping);
                        if (ping == null)
                        {
                            ping = "0";
                        }
                        resp.getOutputStream().print(ping);
                        return;
                    }
                }
            }
            resp.setContentType("text/html");

            try
            {
                // Very important - to update Virtual Path!!!
                AppDomain servletDomain = (AppDomain)this.getServletContext().getAttribute(J2EEConsts.APP_DOMAIN);
                if (!_appVirDirInited)
                {
                    string appVPath = req.getContextPath();
                    if (appVPath == null || appVPath.Length == 0)
                    {
                        appVPath = "/";
                    }
                    servletDomain.SetData(IAppDomainConfig.APP_VIRT_DIR, appVPath);
                    servletDomain.SetData(".hostingVirtualPath", req.getContextPath());
                    _appVirDirInited = true;
                }

                // Put to the TLS current AppDomain of the servlet, so anyone can use it.
                [email protected](servletDomain);

                // put request to the TLS
                //Thread.SetData(_servletRequestSlot, req);
                //// put response to the TLS
                //Thread.SetData(_servletResponseSlot, resp);
                //// put the servlet object to the TLS
                //Thread.SetData(_servletSlot, this);

                resp.setHeader("X-Powered-By", "ASP.NET");
                resp.setHeader("X-AspNet-Version", "1.1.4322");

                HttpWorkerRequest gwr          = new ServletWorkerRequest(this, req, resp);
                CultureInfo       culture      = (CultureInfo)[email protected](req.getLocale());
                Thread            currentTread = Thread.CurrentThread;
                currentTread.CurrentCulture   = culture;
                currentTread.CurrentUICulture = culture;
                HttpRuntime.ProcessRequest(gwr);
            }
            finally
            {
                HttpContext.Current = null;
                //Thread.SetData(_servletRequestSlot, null);
                //Thread.SetData(_servletResponseSlot, null);
                //Thread.SetData(_servletSlot, null);
                [email protected]();
            }
        }
Ejemplo n.º 12
0
        override protected void service(HttpServletRequest req, HttpServletResponse resp)
        {
            resp.setHeader("X-Powered-By", "ASP.NET");
            resp.setHeader("X-AspNet-Version", "1.1.4322");

            String filename = getServletContext().getRealPath(req.getServletPath());
            ServletOutputStream hos;

            try {
                hos = resp.getOutputStream();
            }
            catch (java.lang.IllegalStateException e)
            {
                string mimeType = getServletContext().getMimeType(filename);
                if (mimeType == null || mimeType.StartsWith("text"))
                {
                    sendFileUsingWriter(resp, filename);
                    return;
                }
                else
                {
                    throw e;
                }
            }
            try
            {
                string mimeType = this.getServletContext().getMimeType(filename);
                if (mimeType == null)
                {
                    mimeType = "text/plain";
                }

                resp.setContentType(mimeType);

                FileStream fis = null;
                try {
                    fis = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    byte[] buf = new byte[4 * 1024];                      // 4K buffer
                    int    bytesRead;
                    while ((bytesRead = fis.Read(buf, 0, buf.Length)) != -1 &&
                           bytesRead != 0)
                    {
                        hos.write(TypeUtils.ToSByteArray(buf), 0, bytesRead);
                    }
                }
                finally {
                    if (fis != null)
                    {
                        fis.Close();
                    }
                }
            }
            catch (System.IO.FileNotFoundException e)
            {
                resp.setStatus(404, "Object Not Found.");
                HttpException myExp = new HttpException(404, "File '" + filename + "' not found.");
                hos.print(((HttpException)myExp).GetHtmlErrorMessage());
                hos.flush();
            }
            catch (Exception e)
            {
                Trace.WriteLine(String.Format("ERROR in Static File Reading {0},{1}", e.GetType(), e.Message));
                resp.setStatus(500);
                HttpException myExp = new HttpException("Exception in Reading static file", e);
                hos.print(((HttpException)myExp).GetHtmlErrorMessage());
                hos.flush();
            }
        }