filehandler.java

来自「反向的AJAX。最大的特性是我们成为反向的Ajax。DWR1.x允许你用java」· Java 代码 · 共 535 行 · 第 1/2 页

JAVA
535
字号
        // Deal with missing If-Modified-Since        if (modifiedSince == -1)        {            if (!etag.equals(givenEtag))            {                // There is an ETag, but no If-Modified-Since                if (log.isDebugEnabled())                {                    log.debug("Sending 304 for " + filePath + " Old ETag=" + givenEtag + ", New ETag=" + etag);                }                return true;            }            // There are no modified setttings, carry on            return false;        }        // Do both values indicate that we are in-date?        if (etag.equals(givenEtag) && modifiedSince >= servletContainerStartTime)        {            if (log.isDebugEnabled())            {                log.debug("Sending 304 for " + filePath);            }            return true;        }        return false;    }    /**     * @param allowGetForSafariButMakeForgeryEasier Do we reduce security to help Safari     */    public void setAllowGetForSafariButMakeForgeryEasier(boolean allowGetForSafariButMakeForgeryEasier)    {        this.allowGetForSafariButMakeForgeryEasier = allowGetForSafariButMakeForgeryEasier;    }    /**     * @param ignoreLastModified The ignoreLastModified to set.     */    public void setIgnoreLastModified(boolean ignoreLastModified)    {        this.ignoreLastModified = ignoreLastModified;    }    /**     * Alter the session cookie name from the default JSESSIONID.     * @param sessionCookieName the sessionCookieName to set     */    public void setSessionCookieName(String sessionCookieName)    {        this.sessionCookieName = sessionCookieName;    }    /**     * To what level do we compress scripts?     * @param scriptCompressed The scriptCompressed to set.     */    public void setScriptCompressed(boolean scriptCompressed)    {        this.scriptCompressed = scriptCompressed;    }    /**     * @param compressionLevel The compressionLevel to set.     */    public void setCompressionLevel(int compressionLevel)    {        this.compressionLevel = compressionLevel;    }    /**     * @param filePath the filePath to set     */    public void setFilePath(String filePath)    {        this.filePath = filePath;    }    /**     * Are we expected to do the minor EL type processing?     * @param dynamic the dynamic to set     */    public void setDynamic(boolean dynamic)    {        this.dynamic = dynamic;    }    /**     * The mime type to send the output under     * @param mimeType the mimeType to set     */    public void setMimeType(String mimeType)    {        this.mimeType = mimeType;    }    /**     * What is the string we use for script tag hack protection     * @param scriptTagProtection the scriptTagProtection to set     */    public void setScriptTagProtection(String scriptTagProtection)    {        this.scriptTagProtection = scriptTagProtection;    }    /**     * If we need to override the default path     * @param overridePath The new override path     */    public void setOverridePath(String overridePath)    {        this.overridePath = overridePath;    }    /**     * Sometimes with proxies, you need to close the stream all the time to     * make the flush work. A value of -1 indicated that we do not do early     * closing after writes.     * @param maxWaitAfterWrite the maxWaitAfterWrite to set     */    public void setMaxWaitAfterWrite(int maxWaitAfterWrite)    {        this.maxWaitAfterWrite = maxWaitAfterWrite;    }    /**     * If we need to override the default path     */    private String overridePath = null;    /**     * By default we disable GET, but this hinders old Safaris     */    private boolean allowGetForSafariButMakeForgeryEasier = false;    /**     * What is the string we use for script tag hack protection     */    private String scriptTagProtection = DwrConstants.SCRIPT_TAG_PROTECTION;    /**     * Do we ignore all the Last-Modified/ETags blathering?     */    protected boolean ignoreLastModified = false;    /**     * Sometimes with proxies, you need to close the stream all the time to     * make the flush work. A value of -1 indicated that we do not do early     * closing after writes.     * See also: org.directwebremoting.dwrp.PollHandler.maxWaitAfterWrite     */    protected int maxWaitAfterWrite = -1;    /**     * The session cookie name     */    protected String sessionCookieName = "JSESSIONID";    /**     * How much do we compression javascript by?     */    protected int compressionLevel = JavascriptUtil.LEVEL_DEBUGGABLE;    /**     * Do we retain comments and unneeded spaces in Javascript code?     */    protected boolean scriptCompressed = false;    /**     * The method by which we get new page ids     */    protected IdGenerator generator = new IdGenerator();    /**     * The page id length     */    protected int pageIdLength = 16;    /**     * We cache the script output for speed     */    protected final Map scriptCache = new HashMap();    /**     * The file filePath and resource filePath (minus org.directwebremoting) to read from     */    private String filePath;    /**     * The mime type to send the output under     */    private String mimeType;    /**     * Are we expected to do the minor EL type processing?     */    private boolean dynamic;    /**     * What are we sending as the pollWithXhr setting.     * This is a hack. See the notes in {@link #afterContainerSetup(Container)}     */    private String pollWithXhr;    /**     * The time on the script files     */    private static final long servletContainerStartTime;    /**     * The etag (=time for us) on the script files     */    private static final String etag;    /**     * Initialize the container start time     */    static    {        // Browsers are only accurate to the second        long now = System.currentTimeMillis();        servletContainerStartTime = now - (now % 1000);        etag = "\"" + servletContainerStartTime + '\"';    }    /**     * Does engine.js do GETs for Safari     */    protected static final String PARAM_SCRIPT_ALLOWGET = "${allowGetForSafariButMakeForgeryEasier}";    /**     * Doe we force polling with XHR on IE to prevent clicking     */    protected static final String PARAM_SCRIPT_POLLXHR = "${pollWithXhr}";    /**     * The page id parameter that goes in engine.js     */    protected static final String PARAM_SCRIPT_SESSIONID = "${scriptSessionId}";    /**     * Under what cookie name is the session id stored?     */    protected static final String PARAM_SCRIPT_COOKIENAME = "${sessionCookieName}";    /**     * What is the replacement field we use to tell engine.js what we are using     * for script tag hack protection     */    protected static final String PARAM_SCRIPT_TAG_PROTECTION = "${scriptTagProtection}";    /**     * What is the replacement field we use to tell engine.js what we are using     * for script tag hack protection     */    protected static final String PARAM_DEFAULT_PATH = "${defaultPath}";    /**     * The log stream     */    private static final Logger log = Logger.getLogger(FileHandler.class);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?