protected boolean httpServeFile(String strContType) throws IOException { String strPath = uri.getPath(); // if ( !strPath.startsWith("/apps") ) // strPath = "/apps" + strPath; LOG.TRACE("httpServeFile: " + strPath); if (!isDbFilesPath(strPath)) { if (strContType.equals("application/javascript")) { responseData = RhoRuby.loadFile(strPath); if (responseData == null) { String str = ""; responseData = new ByteArrayInputStream(str.getBytes()); } } else responseData = RhoRuby.loadFile(strPath); } else { if (strPath.startsWith("/apps/app/db/db-files")) strPath = strPath.substring(9); // remove /apps/app else strPath = strPath.substring(5); // remove /apps } if (responseData == null) { SimpleFile file = null; try { file = RhoClassFactory.createFile(); String strFileName = strPath; // if ( strFileName.startsWith("/apps") ) // strFileName = strPath.substring(5); file.open(strFileName, true, true); responseData = file.getInputStream(); if (responseData != null) { contentLength = (int) file.length(); } m_file = file; } catch (Exception exc) { if (file != null) file.close(); } } else { if (responseData != null) { contentLength = responseData.available(); } } if (responseData == null) return false; if (strContType.length() > 0) resHeaders.addProperty("Content-Type", strContType); resHeaders.addProperty("Content-Length", Integer.toString(contentLength)); // resHeaders.addProperty("Date",getLocalHttpTimeString()); // resHeaders.addProperty("Cache-control", "public, max-age=3600" ); // resHeaders.addProperty("Expires", "Thu, 01 Dec 2010 16:00:00 GMT" ); return true; }
protected boolean httpServeFile(String strContType) throws IOException { String strPath = uri.getPath(); // if ( !strPath.startsWith("/apps") ) // strPath = "/apps" + strPath; if (strContType.equals("application/javascript")) { responseData = RhoRuby.loadFile(strPath); if (responseData == null) { String str = ""; responseData = new ByteArrayInputStream(str.getBytes()); } } else responseData = RhoRuby.loadFile(strPath); if (responseData == null) { Jsr75File file = new Jsr75File(); String strFileName = strPath; if (strFileName.startsWith("/apps")) strFileName = strPath.substring(5); try { file.open(strFileName, true, true); responseData = file.getInputStream(); if (responseData != null) { contentLength = (int) file.length(); } m_file = file; } catch (StorageError exc) { file.close(); } catch (IOException exc) { file.close(); } } else { if (responseData != null) { contentLength = responseData.available(); } } if (responseData == null) return false; if (strContType.length() > 0) resHeaders.addProperty("Content-Type", strContType); resHeaders.addProperty("Content-Length", Integer.toString(contentLength)); return true; }
protected boolean httpGetIndexFile() { String strIndex = null; String slash = ""; if (uri.getPath() != null && uri.getPath().length() > 0) slash = uri.getPath().charAt(uri.getPath().length() - 1) == '/' ? "" : "/"; for (int i = 0; i < m_arIndexes.length; i++) { String name = uri.getPath() + slash + m_arIndexes[i]; String nameClass = name; if (nameClass.endsWith(".iseq")) nameClass = nameClass.substring(0, nameClass.length() - 5); if (RhoSupport.findClass(nameClass) != null || RhoRuby.loadFile(name) != null) { strIndex = name; break; } } if (strIndex == null) return false; respondMoved(strIndex); return true; }