2014-05-30 10:31:51 -07:00
/ *
* Copyright ( c ) 2008 , 2009 Declarative Engineering LLC .
* All rights reserved . This program and the accompanying materials
* are made available under the terms of the Declarative Engineering LLC
* verson 1 which accompanies this distribution , and is available at
* http : //declarativeengineering.com/legal/DE_Developer_License_v1.txt
* /
package com.foundation.web.interfaces ;
import java.nio.ByteBuffer ;
import java.util.Date ;
public interface IResponse {
public static final Integer INFINATE_CACHE_LENGTH = new Integer ( 15724800 ) ;
public static final int ERROR_TYPE_RESOURCE_NOT_FOUND = 1 ;
public static final int ERROR_TYPE_INVALID_ACCESS = 2 ;
/** Not exactly an error - more like information, but we will use the error mechanism to pass the info to the web server engine. */
public static final int ERROR_TYPE_RESOURCE_NOT_MODIFIED = 3 ;
/** Used to warn the user that their client did not use TLS + the domain extension, and the server cannot identify which certificate to use to allow them to connect. The user should upgrade their browser. */
public static final int ERROR_TYPE_TLS_FAILURE = 4 ;
2014-12-07 16:12:29 -08:00
/** Used to notify the client that the socket upgrade or protocol change failed or was rejected by the server. */
public static final int ERROR_UPGRADE_REJECTED = 5 ;
2014-05-30 10:31:51 -07:00
/ * *
* Gets the request this response is responding to .
* @return The request that created this response .
* /
public IRequest getRequest ( ) ;
/ * *
* Gets the content bytes .
* @return The content of the response .
* /
public IContent getContent ( ) ;
/ * *
* Sets the content .
* @param content The content of the response .
* /
public void setContent ( IContent content ) ;
/ * *
* Gets whether the response should be compressed when possible . Certain resources that compress poorly should of course ignore this directive .
* @return Whether this response should be compressed is possible and reasonable . Will never return a null value .
* /
public Boolean getCompress ( ) ;
/ * *
* Sets whether the response should be compressed when possible . Certain resources that compress poorly should of course ignore this directive .
* @param compress Whether this response should be compressed is possible and reasonable . A null value will use the application ' s default setting .
* /
public void setCompress ( Boolean compress ) ;
/ * *
* Gets the error type code .
* @return The error type code , or zero if no error occured .
* /
public int getErrorType ( ) ;
/ * *
* Determines whether there was an error .
* @return Whether there was an error .
* /
public boolean isError ( ) ;
/ * *
* Sets the content to be an error message .
* @param errorType The type of error .
* /
public void setError ( int errorType ) ;
/ * *
* Gets the URI that the client should forward to .
* @return The forward URI .
* /
public String getForwardUri ( ) ;
/ * *
* Sets the URI that the client should forward to .
* @param forwardUri The forward URI .
* /
public void setForwardUri ( String forwardUri ) ;
/ * *
* Gets the URI that the client should redirect to .
* @return The redirect URI .
* /
public String getRedirectUri ( ) ;
/ * *
* Sets the URI that the client should redirect to .
* @param redirectUri The redirect URI .
* /
public void setRedirectUri ( String redirectUri ) ;
/ * *
2014-07-13 11:01:23 -07:00
* Gets a user defined header for the response ( IMPORTANT : First line of the header ONLY ) .
2014-05-30 10:31:51 -07:00
* This is useful for specifying non - standard error codes useable by either the browser or javascript in their processing .
* The content will be written out as usual if any content is set .
* The error code prempts this .
* < p > Example : " HTTP/1.1 404 Resource Not Found \ r \ n " . Ensure that there is a \ r \ n at the end of each line you add to the header . < / p >
2014-07-13 11:01:23 -07:00
*
* < p > TODO : Rename this method . Call it getHeaderFirstLine or something , anything to distinguish it from setting a full blown header ( see # getHeader ( ) ) . < / p >
2014-05-30 10:31:51 -07:00
* @param header The header to be used in place of the standard header . This must at the very least include the HTTP tag similar to the one in the above example .
* /
public String getCustomHeader ( ) ;
/ * *
2014-07-13 11:01:23 -07:00
* Sets a user defined header for the response ( IMPORTANT : First line of the header ONLY ) .
2014-05-30 10:31:51 -07:00
* This is useful for specifying non - standard error codes useable by either the browser or javascript in their processing .
* The content will be written out as usual if any content is set .
* The error code prempts this .
* < p > Example : " HTTP/1.1 404 Resource Not Found \ r \ n " . Ensure that there is a \ r \ n at the end of each line you add to the header . < / p >
2014-07-13 11:01:23 -07:00
*
* < p > TODO : Rename this method . Call it setHeaderFirstLine or something , anything to distinguish it from setting a full blown header ( see # setHeader ( ) ) . < / p >
2014-05-30 10:31:51 -07:00
* @param customHeader The header to be used in place of the standard header . This must at the very least include the HTTP tag similar to the one in the above example .
* /
public void setCustomHeader ( String customHeader ) ;
/ * *
* Gets the web server application that the request / response is being handled through .
* @return The web server application object that for the web app handling the request / response .
* /
public IWebApplication getApplication ( ) ;
/ * *
* Gets the header field value for the given field name if a header was set [ via setHeader ( String ) ] .
* @param name The field name .
* @return The field value , or null if none exists .
* /
public String getHeaderFieldValue ( String name ) ;
/ * *
2014-07-13 11:01:23 -07:00
* Sets the exact header that will be sent before sending the content to the client .
* @param header Sets a completely custom header ( the entire header , properly formatted for HTTP and ending with \ r \ n \ r \ n ) .
2014-05-30 10:31:51 -07:00
* /
public void setHeader ( String header ) ;
} //IResponse//