// 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(); } }
// 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(); } }
private void printFile(String fileName, HttpServletRequest req, HttpServletResponse res) { string mimeType = getServletContext().getMimeType(fileName); if (fileName.endsWith(".php") || fileName.endsWith(".inc") || fileName.endsWith(".js") || fileName.endsWith(".html") || fileName.endsWith(".xsl") || fileName.endsWith(".css")) { res.setContentType("text/plain"); } else if (mimeType != null) { res.setContentType(mimeType); } OutputStream os = res.getOutputStream(); string path = _path.lookup(fileName); path.writeToStream(os); }
// 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(ZIPFile.ContentType); resp.getOutputStream().write((sbyte[])(object)GetContent()); resp.getOutputStream().flush(); } catch (csharp.ThrowableException ex) { // either swallow of throw a runtime exception ((java.lang.Throwable)(object) ex).printStackTrace(); } }
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(); } }
// 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(ZIPFile.ContentType); resp.getOutputStream().write((sbyte[])(object)GetContent()); resp.getOutputStream().flush(); } catch (csharp.ThrowableException ex) { // either swallow of throw a runtime exception ((java.lang.Throwable)(object)ex).printStackTrace(); } }
protected WriteStream openWrite(HttpServletResponse response) { WriteStream ws; OutputStream @out = response.getOutputStream(); ws = Vfs.openWrite(out); return(ws); }
protected override void handleThrowable(HttpServletResponse response, Throwable e) { log.log(Level.WARNING, e.ToString(), e); OutputStream os = response.getOutputStream(); WriteStream @out = Vfs.openWrite(os); @out.println(e); @out.close(); }
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](); } }
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](); } }
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(); } }
protected override OutputStreamWrapper CreateOutputStream(bool binary) { return(_outputStream ?? (_outputStream = binary ? new OutputStreamWrapper(_HttpServletResponse.getOutputStream()) : new OutputStreamWrapper(_HttpServletResponse.getWriter()))); }