设置禁止客户端缓存的 Header。

@param response
响应
546291
public static void setNoCacheHeader(final HttpServletResponse response) {
		// Http 1.0 header
		response.setDateHeader(HttpHeaders.EXPIRES, 1L);
		response.addHeader(HttpHeaders.PRAGMA, "no-cache");
		// Http 1.1 header
		response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0");
	}
34448
private void setDateAndCacheHeaders(final HttpResponse response) {
    final SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
    dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));

    // Date header
    final Calendar time = new GregorianCalendar();
    response.headers().set(DATE, dateFormatter.format(time.getTime()));

    // Add cache headers
    time.add(Calendar.SECOND, HTTP_CACHE_SECONDS);
    response.headers().set(EXPIRES, dateFormatter.format(time.getTime()));
    response.headers().set(CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS);
    response.headers().set(LAST_MODIFIED, dateFormatter.format(new Date(startupTime)));
  }
1035967
public static void setFileDownloadHeader(final HttpServletResponse response, final String filename) {
		// 中文文件名支持
		String encodedFilename = Encodes.urlEncode(filename);
		response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedFilename + '\"');
	}
489824
function(response) {
        if (response) {
            this.destroyRequest(response.priv);
        } else {
            for (var key in this.pendingRequests) {
                this.destroyRequest(this.pendingRequests[key]);
            }
        }
    }
309880
@SuppressWarnings("unchecked")
  private void handleResponseSuccess(long requestId, Object response) {
    ContextualFuture future = responseFutures.remove(requestId);
    if (future != null) {
      future.context.executor().execute(() -> future.complete(response));
    }
  }
180523
protected int logout(final Request request, final Response response)
    {
        // Clears the credentials
        request.setChallengeResponse(null);
        final CookieSetting credentialsCookie = this.getCredentialsCookie(request, response);
        credentialsCookie.setMaxAge(0);
        
        this.log.debug("calling attemptRedirect after logout");
        // Attempt to redirect
        this.attemptRedirect(request, response, null);
        
        return Filter.STOP;
    }
537653
public static void bailResponse(HttpContext cx, HttpResponse response) throws IOException, HttpException {
        HttpServerConnection conn = getConnection(cx);
        conn.sendResponseHeader(response);
        conn.sendResponseEntity(response);
        conn.flush();
    }
1287464
@Override
    public void handleResponse(final HttpProxyResponse response)
            throws ProxyAuthException {
        if (!isHandshakeComplete()
                && ("close".equalsIgnoreCase(StringUtilities
                        .getSingleValuedHeader(response.getHeaders(),
                                "Proxy-Connection")) || "close"
                        .equalsIgnoreCase(StringUtilities
                                .getSingleValuedHeader(response.getHeaders(),
                                        "Connection")))) {
            getProxyIoSession().setReconnectionNeeded(true);
        }

        if (response.getStatusCode() == 407) {
            if (authHandler == null) {
                autoSelectAuthHandler(response);
            }
            authHandler.handleResponse(response);
        } else {
            throw new ProxyAuthException("Error: unexpected response code "
                    + response.getStatusLine() + " received from proxy.");
        }
    }
917843
@Override
    public void handle(T result, HttpResponse response) {
        result.setRequesterCharged(response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null);
    }
738153
public void doHead(String url, HttpResponse response, Map<String, Object> headers) {
        response.setRequest(url);
        httpClient.head(url, response, headers);
    }
1016692
protected void notFound(HttpServletRequest request,
                  HttpServletResponse response)
        throws IOException
    {
        if(log.isDebugEnabled())log.debug("Not Found "+request.getRequestURI());
        String method=request.getMethod();
            
        // Not found special requests.
        if (method.equals(HttpRequest.__GET)    ||
            method.equals(HttpRequest.__HEAD)   ||
            method.equals(HttpRequest.__POST))
        {
            response.sendError(HttpResponse.__404_Not_Found);
        }
        else if (method.equals(HttpRequest.__TRACE))
            handleTrace(request,response);
        else if (method.equals(HttpRequest.__OPTIONS))
            handleOptions(request,response);
        else
        {
            // Unknown METHOD
            response.setHeader(HttpFields.__Allow,__AllowString);
            response.sendError(HttpResponse.__405_Method_Not_Allowed);
        }
    }
728681
public void writeHeaders(HttpResponse response,Resource resource, long count)
        throws IOException
    {
        ResourceCache.ResourceMetaData metaData =
            (ResourceCache.ResourceMetaData)resource.getAssociate();

        response.setContentType(metaData.getMimeType());
        if (count != -1)
        {
            if (count==resource.length())
                response.setField(HttpFields.__ContentLength,metaData.getLength());
            else
                response.setContentLength((int)count);
        }

        response.setField(HttpFields.__LastModified,metaData.getLastModified());
        
        if (_acceptRanges && response.getHttpRequest().getDotVersion()>0)
            response.setField(HttpFields.__AcceptRanges,"bytes");
    }
226208
public void doDelete(String url, HttpResponse response, Map<String, Object> headers) {
        response.setRequest(url);
        httpClient.delete(url, response, headers);
    }
641872
public void onSuccess (final WriteResponse response) {
    for (final Thunk thunk: this.thunks) {
      thunk.callback.onSuccess(new WriteResponse() {
        @Override
        public Object getRawResponse() {
          return response.getRawResponse();
        }

        @Override
        public String getStringResponse() {
          return response.getStringResponse();
        }

        @Override
        public long bytesWritten() {
          return thunk.sizeInBytes;
        }
      });
    }
  }
196324
void setResponse(HttpResponse response) {
        if (isResponseAborted) {
            // This means that we already tried to close the request, so abort the response immediately.
            if (!response.isComplete()) {
                response.abort();
            }
        } else {
            this.response = response;
        }
    }
1162732
public ResponseOnSingeRequest onComplete(Response response) {

        cancelCancellable();
        try {
            
            Map<String, List<String>> responseHeaders = null;
            if (responseHeaderMeta != null) {
                responseHeaders = new LinkedHashMap<String, List<String>>();
                if (responseHeaderMeta.isGetAll()) {
                    for (Map.Entry<String, List<String>> header : response
                            .getHeaders()) {
                        responseHeaders.put(header.getKey().toLowerCase(Locale.ROOT), header.getValue());
                    }
                } else {
                    for (String key : responseHeaderMeta.getKeys()) {
                        if (response.getHeaders().containsKey(key)) {
                            responseHeaders.put(key.toLowerCase(Locale.ROOT),
                                    response.getHeaders().get(key));
                        }
                    }
                }
            }

            int statusCodeInt = response.getStatusCode();
            String statusCode = statusCodeInt + " " + response.getStatusText();
            String charset = ParallecGlobalConfig.httpResponseBodyCharsetUsesResponseContentType &&
                    response.getContentType()!=null ? 
                    AsyncHttpProviderUtils.parseCharset(response.getContentType())
                    : ParallecGlobalConfig.httpResponseBodyDefaultCharset;
            if(charset == null){
                getLogger().error("charset is not provided from response content type. Use default");
                charset = ParallecGlobalConfig.httpResponseBodyDefaultCharset; 
            }
            reply(response.getResponseBody(charset), false, null, null, statusCode,
                    statusCodeInt, responseHeaders);
        } catch (IOException e) {
            getLogger().error("fail response.getResponseBody " + e);
        }

        return null;
    }
65705
protected boolean throttleRequest(final HttpServletRequest request, final HttpServletResponse response) {
        return configurationContext.getThrottledRequestExecutor() != null
            && configurationContext.getThrottledRequestExecutor().throttle(request, response);
    }