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


Java HttpServletResponse.flushBuffer方法代码示例

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


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

示例1: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    if (!useChunks) {
        // Longer than it needs to be because response will fail before
        // it is complete
        resp.setContentLength(100);
    }
    PrintWriter pw = resp.getWriter();
    pw.print("line01");
    pw.flush();
    resp.flushBuffer();
    pw.print("line02");
    pw.flush();
    resp.flushBuffer();
    pw.print("line03");

    // Now throw a RuntimeException to end this request
    throw new ServletException("Deliberate failure");
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:TestAbstractHttp11Processor.java

示例2: getRepositoryZip

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/** 커밋을 입력받으면 당시 파일들을 압축하여 사용자에게 보내줌.
 * @param commitName
 * @param format
 * @param response
 */
public void getRepositoryZip(String commitName,String format, HttpServletResponse response) {

	try {
		ArchiveCommand.registerFormat("zip", new ZipFormat());
		ArchiveCommand.registerFormat("tar", new TarFormat());
		ObjectId revId = this.localRepo.resolve(commitName);
		git.archive().setOutputStream(response.getOutputStream())
		.setFormat(format)
		.setTree(revId)
		.call();

		ArchiveCommand.unregisterFormat("zip");
		ArchiveCommand.unregisterFormat("tar");
		response.flushBuffer();
	} catch (Exception e) {
		System.err.println(e.getMessage());
	}

}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:25,代码来源:GitUtil.java

示例3: infoMachine

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Is a wrapper to cAdvisor API
 *
 * @return
 * @throws ServiceException
 * @throws CheckException
 */
@RequestMapping(value = "/api/machine", method = RequestMethod.GET)
public void infoMachine(HttpServletRequest request, HttpServletResponse response)
		throws ServiceException, CheckException {
	String responseFromCAdvisor = monitoringService.getJsonMachineFromCAdvisor();
	try {
		response.getWriter().write(responseFromCAdvisor);
		response.flushBuffer();
	} catch (Exception e) {
		logger.error("error during write and flush response", responseFromCAdvisor);
	}

}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:20,代码来源:MonitoringController.java

示例4: onAuthenticationFailure

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void onAuthenticationFailure(HttpServletRequest request,
									HttpServletResponse response,
									AuthenticationException exception) throws IOException, ServletException {
	logger.error(exception, exception);
	AuthEvent userLogin = AuthEventHelper.buildFailedAuthEvent(request, exception);
	userAuditService.saveUserAuthEvent(userLogin);
	String accept = request.getHeader("Accept");
	if (accept != null && accept.contains("application/json")) {
		logger.warn("The ajax request is not authenticated.");
		response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
		response.flushBuffer();
		return;
	}
	super.onAuthenticationFailure(request, response, exception);
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:17,代码来源:AuthenticationFailureHandlerMvcImpl.java

示例5: handle

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void handle(HttpServletRequest request,
				   HttpServletResponse response,
				   AccessDeniedException accessDeniedException) throws IOException, ServletException {
	logger.error("The ajax request access is denied.", accessDeniedException);
	response.setStatus(HttpServletResponse.SC_FORBIDDEN);
	response.getWriter()
			.append(String.format("{\"succeed\":false,\"message\":\"%s\"}", accessDeniedException.getMessage()));
	response.flushBuffer();
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:11,代码来源:AccessDeniedHandlerRestImpl.java

示例6: doFilterInternal

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void
doFilterInternal(final HttpServletRequest request,
    final HttpServletResponse response,
    final FilterChain filterChain) throws ServletException,
    IOException {
  try {
    LOG.debug("Checking KMS key, if present.");
    final String encryptionTypeHeader = request.getHeader(SERVER_SIDE_ENCRYPTION);
    final String encryptionKeyRef = request.getHeader(SERVER_SIDE_ENCRYPTION_AWS_KMS_KEYID);

    if ("aws:kms".equals(encryptionTypeHeader) && !keystore.validateKeyRef(encryptionKeyRef)) {
      LOG.debug("Received invalid key, sending error response.");

      request.getInputStream().close();

      response.setStatus(HttpStatus.SC_BAD_REQUEST);
      response.setHeader(HttpHeaders.CONTENT_TYPE, "application/xml");

      final ErrorResponse errorResponse = new ErrorResponse();
      errorResponse.setCode("KMS.NotFoundException");
      errorResponse.setMessage("Key " + encryptionKeyRef + " does not exist!");

      marshaller.marshalOutputStream(errorResponse, response.getOutputStream());

      response.flushBuffer();
    } else {
      filterChain.doFilter(request, response);
    }
  } catch (final RuntimeException e) {
    LOG.error("Caught exception", e);
    throw e;
  } finally {
    LOG.debug("Finished checking KMS key.");
  }
}
 
开发者ID:adobe,项目名称:S3Mock,代码行数:37,代码来源:KMSValidationFilter.java

示例7: onAuthenticationFailure

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void onAuthenticationFailure(HttpServletRequest request,
									HttpServletResponse response,
									AuthenticationException exception) throws IOException, ServletException {
	logger.error("The ajax request is not authenticated.", exception);
	try {
		userAuditService.saveUserAuthEvent(AuthEventHelper.buildFailedAuthEvent(request, exception));
	}
	catch (Throwable e) {
		//do nothing
	}
	response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
	response.getWriter().append(String.format("{\"succeed\":false,\"message\":\"%s\"}", exception.getMessage()));
	response.flushBuffer();
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:16,代码来源:AuthenticationFailureHandlerRestImpl.java

示例8: get

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping(value = "/files/{uuid:[\\w-]{36}}", method = RequestMethod.GET, produces = {MediaType.APPLICATION_OCTET_STREAM_VALUE})
public void get(@PathVariable(name = "uuid") String uuid, HttpServletResponse resp) throws IOException {
	net.bndy.wf.modules.core.models.File f = this.fileService.getByUuid(uuid);
	if (f != null && this.applicationConfig.getUploadPath() != null && !applicationConfig.getUploadPath().isEmpty()) {
		String filePath = Paths.get(this.applicationConfig.getUploadPath(), f.getPath()).toAbsolutePath().toString();
		FileCopyUtils.copy(new FileInputStream(filePath), resp.getOutputStream());
		resp.flushBuffer();
	}
}
 
开发者ID:bndynet,项目名称:web-framework-for-java,代码行数:10,代码来源:HomeController.java

示例9: service

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
    Cookie cookies[] = req.getCookies();
    for (Cookie cookie : cookies) {
        resp.getWriter().write(cookie.getName() + "=" +
                cookie.getValue() + "\n");
    }
    resp.flushBuffer();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:11,代码来源:TestCookiesDisallowEquals.java

示例10: respond

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void respond(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setCharacterEncoding(UTF_8.name());
    response.setContentType("text/event-stream");
    // By adding this header, and not closing the connection,
    // we disable HTTP chunking, and we can use write()+flush()
    // to send data in the text/event-stream protocol
    response.addHeader("Connection", "close");
    response.flushBuffer();
}
 
开发者ID:IoTKETI,项目名称:IPE-LWM2M,代码行数:11,代码来源:EventSourceServlet.java

示例11: filterRequest

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response) throws IOException,
	ServletException
{
	if( CurrentInstitution.get() != null )
	{
		String path = (request.getServletPath() + Strings.nullToEmpty(request.getPathInfo())).substring(1);

		// Disallow overriding of CSS files supplied by plugins. Clients
		// should always override CSS rules in customer.css
		if( CSS_PROVIDED_BY_PLUGIN.matcher(path).matches() )
		{
			return FilterResult.FILTER_CONTINUE;
		}

		// Remove the version number from the path which is there to
		// facilitate long expiry dates.
		final Matcher m = REMOVE_VERSION_FROM_PATH.matcher(path);
		if( m.matches() )
		{
			path = "p/r/" + m.group(1);
		}

		CustomisationFile customFile = new CustomisationFile();
		if( fileService.fileExists(customFile, path) )
		{
			String mimeType = mimeTypeService.getMimeTypeForFilename(path);
			FileContentStream contentStream = fileService.getContentStream(customFile, path, mimeType);
			contentStreamWriter.outputStream(request, response, contentStream);
			response.flushBuffer();
		}
	}
	return FilterResult.FILTER_CONTINUE;
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:CustomerFilter.java

示例12: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    TestAsyncContextImpl.track("DispatchingServletGet-");
    resp.flushBuffer();

    final boolean first = TrackingServlet.first;
    TrackingServlet.first = false;

    final AsyncContext ctxt = req.startAsync();
    TrackingListener listener = new TrackingListener(false, true, null);
    ctxt.addListener(listener);
    ctxt.setTimeout(3000);

    Runnable run = new Runnable() {
        @Override
        public void run() {
            if (first) {
                ctxt.dispatch("/stage1");
            } else {
                ctxt.dispatch("/stage2");
            }
        }
    };
    if ("y".equals(req.getParameter("useThread"))) {
        new Thread(run).start();
    } else {
        run.run();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:31,代码来源:TestAsyncContextImpl.java

示例13: service

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentLength(0);
    resp.flushBuffer();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:6,代码来源:TestKeepAliveCount.java

示例14: handleConnect

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
public void handleConnect(HttpServletRequest request,
                          HttpServletResponse response)
    throws IOException
{
    String uri = request.getRequestURI();

    String port = "";
    String host = "";

    int c = uri.indexOf(':');
    if (c>=0)
    {
        port = uri.substring(c+1);
        host = uri.substring(0,c);
        if (host.indexOf('/')>0)
            host = host.substring(host.indexOf('/')+1);
    }




    InetSocketAddress inetAddress = new InetSocketAddress (host, Integer.parseInt(port));

    //if (isForbidden(HttpMessage.__SSL_SCHEME,addrPort.getHost(),addrPort.getPort(),false))
    //{
    //    sendForbid(request,response,uri);
    //}
    //else
    {
        InputStream in=request.getInputStream();
        OutputStream out=response.getOutputStream();

        Socket socket = new Socket(inetAddress.getAddress(),inetAddress.getPort());

        response.setStatus(200);
        response.setHeader("Connection","close");
        response.flushBuffer();

        IO.copyThread(socket.getInputStream(),out);
        IO.copy(in,socket.getOutputStream());
    }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:43,代码来源:ProxyServlet.java

示例15: checkFsThroughput

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@RequestMapping ( "/checkFsThroughput" )
public void checkFsThroughput (
								@RequestParam ( value = "numGb" , required = false , defaultValue = "1" ) int numGb,
								@RequestParam ( value = "targetFs" , required = false , defaultValue = "" ) String targetFs,
								HttpServletRequest request, HttpServletResponse response ) {

	if ( targetFs.length() == 0 ) {
		targetFs = csapApp.getAgentRunHome();
	}

	logger.debug( " numGb: {} , targetFs: {} ", numGb, targetFs );

	try {
		response.setContentType( "text/plain" );
		response.getWriter()
			.print(
				"\n\n ========== checkFsThroughput Begin: " + numGb
						+ "Gb will be written then deleted" );

		response.getWriter()
			.print(
				"\n\n ==Expected throughput can vary, but typically this is 200-400Mbs. Contact vif-ops for abnormal results.\n\n" );

		response.flushBuffer();

		// Same host as login, so get the processes
		if ( numGb != -1 ) {
			runFsScript( numGb, targetFs, response );

		} else {

			runFsScript( 1, targetFs, response );

			runFsScript( 2, targetFs, response );

			runFsScript( 4, targetFs, response );

			runFsScript( 8, targetFs, response );

			runFsScript( 16, targetFs, response );

		}

		response.getWriter()
			.print( "\n\n ========== checkFsThroughput End ========\n\n" );

	} catch (Exception e) {
		logger.error( "Failed to rebuild", e );
	}
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:51,代码来源:HostRequests.java


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