org.apache.shindig.common.servlet
Class HttpUtil

java.lang.Object
  extended by org.apache.shindig.common.servlet.HttpUtil

public final class HttpUtil
extends Object

Collection of HTTP utilities


Field Summary
static String ACCESS_CONTROL_ALLOW_ORIGIN_HEADER
           
 
Method Summary
static List<Pair<String,String>> getCachingHeadersToSet(int ttl, boolean noProxy)
           
static int getDefaultTtl()
           
static TimeSource getTimeSource()
           
static boolean isJSONP(javax.servlet.http.HttpServletRequest request)
           
static void setCachingHeaders(javax.servlet.http.HttpServletResponse response)
          Sets HTTP headers that instruct the browser to cache content.
static void setCachingHeaders(javax.servlet.http.HttpServletResponse response, boolean noProxy)
          Sets HTTP headers that instruct the browser to cache content.
static void setCachingHeaders(javax.servlet.http.HttpServletResponse response, int ttl)
          Sets HTTP headers that instruct the browser to cache content.
static void setCachingHeaders(javax.servlet.http.HttpServletResponse response, int ttl, boolean noProxy)
          Sets HTTP headers that instruct the browser to cache content.
static void setCORSheader(javax.servlet.http.HttpServletResponse resp, Collection<String> validOrigins)
          Set the header for Cross-Site Resource Sharing.
static void setDefaultTtl(int defaultTtl)
           
static void setNoCache(javax.servlet.http.HttpServletResponse response)
           
static void setTimeSource(TimeSource timeSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCESS_CONTROL_ALLOW_ORIGIN_HEADER

public static final String ACCESS_CONTROL_ALLOW_ORIGIN_HEADER
See Also:
Constant Field Values
Method Detail

setTimeSource

public static void setTimeSource(TimeSource timeSource)

getTimeSource

public static TimeSource getTimeSource()

setCachingHeaders

public static void setCachingHeaders(javax.servlet.http.HttpServletResponse response)
Sets HTTP headers that instruct the browser to cache content. Implementations should take care to use cache-busting techniques on the url if caching for a long period of time.

Parameters:
response - The HTTP response

setCachingHeaders

public static void setCachingHeaders(javax.servlet.http.HttpServletResponse response,
                                     boolean noProxy)
Sets HTTP headers that instruct the browser to cache content. Implementations should take care to use cache-busting techniques on the url if caching for a long period of time.

Parameters:
response - The HTTP response
noProxy - True if you don't want the response to be cacheable by proxies.

setCachingHeaders

public static void setCachingHeaders(javax.servlet.http.HttpServletResponse response,
                                     int ttl)
Sets HTTP headers that instruct the browser to cache content. Implementations should take care to use cache-busting techniques on the url if caching for a long period of time.

Parameters:
response - The HTTP response
ttl - The time to cache for, in seconds. If 0, then insure that this object is not cached.

setNoCache

public static void setNoCache(javax.servlet.http.HttpServletResponse response)

setCachingHeaders

public static void setCachingHeaders(javax.servlet.http.HttpServletResponse response,
                                     int ttl,
                                     boolean noProxy)
Sets HTTP headers that instruct the browser to cache content. Implementations should take care to use cache-busting techniques on the url if caching for a long period of time.

Parameters:
response - The HTTP response
ttl - The time to cache for, in seconds. If 0, then insure that this object is not cached.
noProxy - True if you don't want the response to be cacheable by proxies.

getCachingHeadersToSet

public static List<Pair<String,String>> getCachingHeadersToSet(int ttl,
                                                               boolean noProxy)

getDefaultTtl

public static int getDefaultTtl()

setDefaultTtl

public static void setDefaultTtl(int defaultTtl)

isJSONP

public static boolean isJSONP(javax.servlet.http.HttpServletRequest request)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException

setCORSheader

public static void setCORSheader(javax.servlet.http.HttpServletResponse resp,
                                 Collection<String> validOrigins)
Set the header for Cross-Site Resource Sharing.

Parameters:
resp - HttpServletResponse to modify
validOrigins - a space separated list of Origins as defined by the html5 spec
See Also:
http://dev.w3.org/html5/spec/browsers.html#origin-0


Copyright © 2007-2012. All Rights Reserved.