+ if (name.equalsIgnoreCase(Headers.HEADER_CACHE_CONTROL)) {
+ if (overwrite)
+ cacheParams.clear();
+ if (value == null)
+ return;
+ for (String param : value.split(",")) {
+ param = param.trim();
+ int pos = param.indexOf("=");
+ if (pos < 0) {
+ cacheParams.put(param, null);
+ }
+ else {
+ String paramName = param.substring(0, pos).trim();
+ if (paramName.equalsIgnoreCase("max-age")) {
+ try {
+ cacheSeconds = Integer.parseInt(param.substring(pos + 1));
+ cacheSecondsSet = true;
+ }
+ catch (NumberFormatException e) {
+ log.warn("illegal value for Header \"Cache-Control\":", param);
+ }
+ }
+ else {
+ cacheParams.put(paramName, param.substring(pos + 1));
+ }
+ }
+ }
+ return;
+ }
+
+ if (name.equalsIgnoreCase(Headers.HEADER_PRAGMA)) {
+ if (value != null && value.trim().equalsIgnoreCase("no-cache"))
+ cacheSeconds = 0;
+ return;
+ }
+
+ /** Pass header through, if no value from intrest was found */
+ if (overwrite)
+ response.setHeader(name, value);
+ else
+ response.addHeader(name, value);
+ }
+
+ private void calculateCacheSeconds() {
+ if (!cacheSecondsSet && expires >= now) {
+ cacheSeconds = (int)(expires/1000 - now/1000);
+ log.debug("calculating cache-seconds from DATE and EXPIRES: {}", cacheSeconds);
+ }
+ }
+
+
+ private class AcceleratorServletOutputStream extends ServletOutputStream {
+
+ private final ServletOutputStream sos;
+
+
+ private AcceleratorServletOutputStream() throws IOException {
+ bufferSize = defaultBufferSize;
+ buffer = new byte[bufferSize];
+ sos = AccelerationWrapper.this.response.getOutputStream();
+ }
+
+
+ private OutputStream out() throws IOException {
+ if (os == null)
+ os = zipped ? new GZIPOutputStream(sos) : sos;
+ return os;
+ }