當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE屬性代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE屬性的具體用法?Java HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE怎麽用?Java HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: finishRequest

/**
 * Perform whatever actions are required to flush and close the input
 * stream or reader, in a single operation.
 *
 * @exception IOException if an input/output error occurs
 */
public void finishRequest() throws IOException {
    // Optionally disable swallowing of additional request data.
    Context context = getContext();
    if (context != null &&
            response.getStatus() == HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE &&
            !context.getSwallowAbortedUploads()) {
        coyoteRequest.action(ActionCode.DISABLE_SWALLOW_INPUT, null);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:15,代碼來源:Request.java

示例2: finishRequest

/**
 * Perform whatever actions are required to flush and close the input stream
 * or reader, in a single operation.
 *
 * @exception IOException
 *                if an input/output error occurs
 */
public void finishRequest() throws IOException {
	// Optionally disable swallowing of additional request data.
	Context context = getContext();
	if (context != null && response.getStatus() == HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE
			&& !context.getSwallowAbortedUploads()) {
		coyoteRequest.action(ActionCode.DISABLE_SWALLOW_INPUT, null);
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:15,代碼來源:Request.java

示例3: doFilter

@Override
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    if (!isGoodRequest(request)) {
        FailReason reason = (FailReason) request.getAttribute(
                Globals.PARAMETER_PARSE_FAILED_REASON_ATTR);

        int status;

        switch (reason) {
            case IO_ERROR:
                // Not the client's fault
                status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
                break;
            case POST_TOO_LARGE:
                status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE;
                break;
            case TOO_MANY_PARAMETERS:
                // 413/414 aren't really correct here since the request body
                // and/or URI could be well below any limits set. Use the
                // default.
            case UNKNOWN: // Assume the client is at fault
            // Various things that the client can get wrong that don't have
            // a specific status code so use the default.
            case INVALID_CONTENT_TYPE:
            case MULTIPART_CONFIG_INVALID:
            case NO_NAME:
            case REQUEST_BODY_INCOMPLETE:
            case URL_DECODING:
            case CLIENT_DISCONNECT:
                // Client is never going to see this so this is really just
                // for the access logs. The default is fine.
            default:
                // 400
                status = HttpServletResponse.SC_BAD_REQUEST;
                break;
        }

        ((HttpServletResponse) response).sendError(status);
        return;
    }
    chain.doFilter(request, response);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:43,代碼來源:FailedRequestFilter.java

示例4: doFilter

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
		throws IOException, ServletException {
	if (!isGoodRequest(request)) {
		FailReason reason = (FailReason) request.getAttribute(Globals.PARAMETER_PARSE_FAILED_REASON_ATTR);

		int status;

		switch (reason) {
		case IO_ERROR:
			// Not the client's fault
			status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
			break;
		case POST_TOO_LARGE:
			status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE;
			break;
		case TOO_MANY_PARAMETERS:
			// 413/414 aren't really correct here since the request body
			// and/or URI could be well below any limits set. Use the
			// default.
		case UNKNOWN: // Assume the client is at fault
			// Various things that the client can get wrong that don't have
			// a specific status code so use the default.
		case INVALID_CONTENT_TYPE:
		case MULTIPART_CONFIG_INVALID:
		case NO_NAME:
		case REQUEST_BODY_INCOMPLETE:
		case URL_DECODING:
		case CLIENT_DISCONNECT:
			// Client is never going to see this so this is really just
			// for the access logs. The default is fine.
		default:
			// 400
			status = HttpServletResponse.SC_BAD_REQUEST;
			break;
		}

		((HttpServletResponse) response).sendError(status);
		return;
	}
	chain.doFilter(request, response);
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:42,代碼來源:FailedRequestFilter.java


注:本文中的javax.servlet.http.HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。