// http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html#site-control
        // http://board.flashkit.com/board/showthread.php?t=782484
        // http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_02.html
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                resp.setContentType("text/x-cross-domain-policy");

                Console.WriteLine(UrlPattern);
                resp.getWriter().print(@"
            <?xml version=""1.0""?>
            <!DOCTYPE cross-domain-policy SYSTEM ""http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"">
            <cross-domain-policy>
            <site-control permitted-cross-domain-policies=""all""/>
            <allow-access-from domain=""*"" secure=""false""/>
            <allow-http-request-headers-from domain=""*"" headers=""*"" secure=""false""/>
            </cross-domain-policy>
            ".Trim());

                resp.getWriter().flush();
            }
            catch (csharp.ThrowableException ex)
            {
                // either swallow of throw a runtime exception

                ((java.lang.Throwable)(object)ex).printStackTrace();

            }
        }
        // http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html#site-control
        // http://board.flashkit.com/board/showthread.php?t=782484
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                var p = req.GetPathAndQuery();

                if (p.Length > UrlPattern.Length + 1)
                    p = p.Substring(UrlPattern.Length + 1);
                else
                    p = "";

                if ("zip" == p)
                {
                    resp.setContentType(ZIPFile.ContentType);
                    resp.getOutputStream().write((sbyte[])(object)GetContent());
                    resp.getOutputStream().flush();
                }
                else
                {
                    resp.setContentType("text/html");
                    resp.getWriter().println(Launch(p));
                    resp.getWriter().flush();
                }
            }
            catch (csharp.ThrowableException ex)
            {
                // either swallow of throw a runtime exception

                ((java.lang.Throwable)(object)ex).printStackTrace();

            }
        }
Exemplo n.º 3
0
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                var PathAndQuery = req.GetPathAndQuery().Substring(UrlPattern.Length);

                // not allowed to do so:
                // http://groups.google.com/group/google-appengine/browse_thread/thread/68a480cb7bec869e
                // http://www.ozelwebtasarim.com/index.php/google/10004-google-app-engine-java-utf-8-character-encoding-problem
                //resp.setHeader("Content-Encoding", "utf-8");

                if (PathAndQuery.Length > 1)
                {
                    resp.setContentType("text/html; charset=utf-8");
                    resp.getWriter().println(Launch(PathAndQuery.Substring(1)));
                }
                else
                {
                    resp.setContentType("text/html; charset=utf-8");
                    resp.getWriter().println(Launch(null));
                }
            }
            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
            }
        }
        // http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html#site-control
        // http://board.flashkit.com/board/showthread.php?t=782484
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                resp.setContentType("text/html");
                resp.getWriter().println(Launch(req.GetPathAndQuery()));
                resp.getWriter().flush();
            }
            catch (csharp.ThrowableException ex)
            {
                // either swallow of throw a runtime exception

                ((java.lang.Throwable)(object)ex).printStackTrace();

            }
        }
        // http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html#site-control
        // http://board.flashkit.com/board/showthread.php?t=782484
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                resp.setContentType(YAMLDocument.ContentType);

                resp.getWriter().print(GameReferenceExtensions.Default.ToYAML());

                resp.getWriter().flush();
            }
            catch (csharp.ThrowableException ex)
            {
                // either swallow of throw a runtime exception

                ((java.lang.Throwable)(object)ex).printStackTrace();

            }
        }
        // http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html#site-control
        // http://board.flashkit.com/board/showthread.php?t=782484
        protected override void doGet(HttpServletRequest req, HttpServletResponse resp)
        {
            try
            {
                resp.setContentType("application/rss+xml");

                resp.getWriter().print(GetContent());

                resp.getWriter().flush();
            }
            catch (csharp.ThrowableException ex)
            {
                // either swallow of throw a runtime exception

                ((java.lang.Throwable)(object)ex).printStackTrace();

            }
        }
Exemplo n.º 8
0
 void sendFileUsingWriter(HttpServletResponse resp, string filename)
 {
     java.io.PrintWriter writer = resp.getWriter();
     try
     {
         resp.setContentType(this.getServletContext().getMimeType(filename));
         StreamReader fis = null;
         char[]       buf = new char[4 * 1024];            // 4K buffer
         try {
             fis = new StreamReader(filename);
             int charsRead;
             while ((charsRead = fis.Read(buf, 0, buf.Length)) != -1 &&
                    charsRead != 0)
             {
                 writer.write(buf, 0, charsRead);
             }
         }
         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.");
         writer.print(((HttpException)myExp).GetHtmlErrorMessage());
         writer.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);
         writer.print(((HttpException)myExp).GetHtmlErrorMessage());
         writer.flush();
     }
 }
Exemplo n.º 9
0
        protected override void doGet(HttpServletRequest request, HttpServletResponse response)
        {
            response.setContentType("text/plain");
            StreamWriter output     = response.getWriter();
            String       counterStr = null;

            Cookie[] cookies = request.getCookies();
            if (cookies == null)
            {
                output.WriteLine("cookies == null");
            }
            else
            {
                output.WriteLine("cookies.length.." + cookies.Length);
                for (int i = 0; i < cookies.Length; i++)
                {
                    output.WriteLine("cookies[" + i + "].."
                                     + cookies[i].getName() + "/" + cookies[i].getValue());
                    if (cookies[i].getName().Equals("COUNTER"))
                    {
                        counterStr = cookies[i].getValue();
                    }
                }
            }
            int counter;

            if (counterStr == null)
            {
                counter = 1;
            }
            else
            {
                counter = Int32.Parse(counterStr) + 1;
            }
            Cookie newCookie = new Cookie("COUNTER", "" + counter);

            response.addCookie(newCookie);
        }
Exemplo n.º 10
0
        protected override void doGet(HttpServletRequest request, HttpServletResponse response)
        {
            response.setContentType("text/plain; charset=UTF-8");
            StreamWriter output = response.getWriter();

            String postalCode = request.getParameter("postalCode");
            String ret;

            if (postalCode.Equals("162-0846"))
            {
                ret = "東京都新宿区市谷左内町";
            }
            else if (postalCode.Equals("100-0014"))
            {
                ret = "東京都千代田区永田町";
            }
            else
            {
                ret = "不明";
            }
            response.setStatus(HttpServletResponse.SC_OK);
            output.WriteLine(ret);
        }
Exemplo n.º 11
0
		void sendFileUsingWriter(HttpServletResponse resp, string filename)
		{
			java.io.PrintWriter writer = resp.getWriter();
			try 
			{
				resp.setContentType(this.getServletContext().getMimeType(filename));
				StreamReader fis = null;
				char[] buf = new char[4 * 1024];  // 4K buffer
				try {
					fis = new StreamReader(filename);
					int charsRead;
					while ((charsRead = fis.Read(buf,0,buf.Length)) != -1 &&
					   	charsRead != 0) {
						writer.write(buf, 0, charsRead);
					}
				}
				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.");
				writer.print(((HttpException) myExp).GetHtmlErrorMessage ());
				writer.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);
				writer.print(((HttpException) myExp).GetHtmlErrorMessage ());
				writer.flush();
			}
		}
Exemplo n.º 12
0
 protected override OutputStreamWrapper CreateOutputStream(bool binary)
 {
     return(_outputStream ?? (_outputStream = binary ?
                                              new OutputStreamWrapper(_HttpServletResponse.getOutputStream()) :
                                              new OutputStreamWrapper(_HttpServletResponse.getWriter())));
 }