当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletResponse.resetBuffer方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.resetBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.resetBuffer方法的具体用法?Java HttpServletResponse.resetBuffer怎么用?Java HttpServletResponse.resetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.resetBuffer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doPost

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");
    Reader r = req.getReader();

    resp.setCharacterEncoding("UTF-8");
    resp.setContentType("text/plain");
    Writer w = resp.getWriter();

    try {
        // Copy one character at a time
        int c = r.read();
        while (c != -1) {
            w.write(c);
            c = r.read();
        }
        w.close();
    } catch (MalformedInputException mie) {
        resp.resetBuffer();
        w.write("FAILED");
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:TestInputBuffer.java

示例2: handleInvalidCORS

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Handles a CORS request that violates specification.
 *
 * @param request
 *            The {@link HttpServletRequest} object.
 * @param response
 *            The {@link HttpServletResponse} object.
 * @param filterChain
 *            The {@link FilterChain} object.
 */
private void handleInvalidCORS(final HttpServletRequest request,
        final HttpServletResponse response, final FilterChain filterChain) {
    String origin = request.getHeader(CorsFilter.REQUEST_HEADER_ORIGIN);
    String method = request.getMethod();
    String accessControlRequestHeaders = request.getHeader(
            REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS);

    response.setContentType("text/plain");
    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
    response.resetBuffer();

    if (log.isDebugEnabled()) {
        // Debug so no need for i18n
        StringBuilder message =
                new StringBuilder("Invalid CORS request; Origin=");
        message.append(origin);
        message.append(";Method=");
        message.append(method);
        if (accessControlRequestHeaders != null) {
            message.append(";Access-Control-Request-Headers=");
            message.append(accessControlRequestHeaders);
        }
        log.debug(message.toString());
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:CorsFilter.java

示例3: handleInvalidCORS

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Handles a CORS request that violates specification.
 *
 * @param request
 *            The {@link HttpServletRequest} object.
 * @param response
 *            The {@link HttpServletResponse} object.
 * @param filterChain
 *            The {@link FilterChain} object.
 */
private void handleInvalidCORS(final HttpServletRequest request, final HttpServletResponse response,
		final FilterChain filterChain) {
	String origin = request.getHeader(CorsFilter.REQUEST_HEADER_ORIGIN);
	String method = request.getMethod();
	String accessControlRequestHeaders = request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS);

	response.setContentType("text/plain");
	response.setStatus(HttpServletResponse.SC_FORBIDDEN);
	response.resetBuffer();

	if (log.isDebugEnabled()) {
		// Debug so no need for i18n
		StringBuilder message = new StringBuilder("Invalid CORS request; Origin=");
		message.append(origin);
		message.append(";Method=");
		message.append(method);
		if (accessControlRequestHeaders != null) {
			message.append(";Access-Control-Request-Headers=");
			message.append(accessControlRequestHeaders);
		}
		log.debug(message.toString());
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:CorsFilter.java

示例4: getAttachmentContent

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping(value = "/email/attachment/{id}",method = RequestMethod.GET)
public void getAttachmentContent(@PathVariable("id") Long id, HttpServletResponse response) {

	final AttachmentEntity attachment = attachmentService.findAttachmentById(id);

	if (attachment != null) {
		try {
			ServletOutputStream stream = response.getOutputStream();
			OutputStream out = new BufferedOutputStream(stream);

			response.resetBuffer();
			response.setBufferSize(attachment.getAttachmentContent().getData().length);
			response.setHeader("Content-Length", String.valueOf(attachment.
                       getAttachmentContent().getData().length));

			out.write(attachment.getAttachmentContent().getData());

			out.close();
			stream.close();
		} catch (final IOException e) {
			log.error("Unable to open file", e);
		}
	} else {
		log.error("File does not exist");
	}
}
 
开发者ID:dopse,项目名称:maildump,代码行数:27,代码来源:EmailController.java

示例5: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    Writer w = resp.getWriter();
    w.write("OK");
    resp.resetBuffer();
    w.write("OK");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:TestOutputBuffer.java

示例6: sendForm

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/** Send the given parameters as a form-encoded response body. */
public static void sendForm(HttpServletResponse response,
        Iterable<? extends Map.Entry> parameters) throws IOException {
    response.resetBuffer();
    response.setContentType(OAuth.FORM_ENCODED + ";charset="
            + OAuth.ENCODING);
    OAuth.formEncode(parameters, response.getOutputStream());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:OAuthServlet.java

示例7: onProxyResponseFailure

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void onProxyResponseFailure(final HttpServletRequest clientRequest, final HttpServletResponse proxyResponse,
		final Response serverResponse, final Throwable failure) {
	_log.warn(failure.toString());

	if (proxyResponse.isCommitted()) {
		// Parent behavior
		super.onProxyResponseFailure(clientRequest, proxyResponse, serverResponse, failure);
	} else {
		proxyResponse.resetBuffer();
		if (failure instanceof TimeoutException) {
			proxyResponse.setStatus(HttpServletResponse.SC_GATEWAY_TIMEOUT);
		} else {

			// Unavailable business server as JSON response
			proxyResponse.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
			proxyResponse.setContentType("application/json");
			try {
				proxyResponse.getOutputStream().write("{\"code\":\"business-down\"}".getBytes(StandardCharsets.UTF_8));
			} catch (final IOException ioe) {
				_log.warn("Broken proxy stream", ioe);
			}
		}
		proxyResponse.setHeader(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
		final AsyncContext asyncContext = clientRequest.getAsyncContext();
		asyncContext.complete();
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:29,代码来源:BackendProxyServlet.java

示例8: clearBuffer

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void clearBuffer(HttpServletResponse response) {
    if (!response.isCommitted()) {
        response.resetBuffer();
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:6,代码来源:PrepareExceptionValve.java

示例9: printMessage

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Produces a simple HTTP text/plain response for the specified CORS
 * exception.
 *
 * <p>Note: The CORS filter avoids falling back to the default web
 * container error page (typically a richly-formatted HTML page) to
 * make it easier for XHR debugger tools to identify the cause of
 * failed requests.
 *
 * @param corsException The CORS exception. Must not be {@code null}.
 * @param response      The HTTP servlet response. Must not be
 *                      {@code null}.
 *
 * @throws IOException      On a I/O exception.
 * @throws ServletException On a general request processing exception.
 */
private void printMessage(final CORSException corsException,
			  final HttpServletResponse response)
	throws IOException, ServletException {

	// Set the status code
	response.setStatus(corsException.getHTTPStatusCode());

	// Write the error message
	response.resetBuffer();
	response.setContentType("text/plain");
	PrintWriter out = response.getWriter();
	out.println("Cross-Origin Resource Sharing (CORS) Filter: " + corsException.getMessage());
}
 
开发者ID:sdcuike,项目名称:cors-filter,代码行数:30,代码来源:CORSFilter.java


注:本文中的javax.servlet.http.HttpServletResponse.resetBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。