Java Code Examples for javax.servlet.http.HttpServletRequest#upgrade()

The following examples show how to use javax.servlet.http.HttpServletRequest#upgrade() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = newServletWriter(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
	response.flushBuffer();
}
 
Example 2
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = newServletWriter(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
	response.flushBuffer();
}
 
Example 3
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = servletWriterHelper.newInstance(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
		response.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
	}
	response.flushBuffer();
}
 
Example 4
Source Project: haven-platform   File: ProxyServlet.java    License: Apache License 2.0 5 votes vote down vote up
private void doUpgrade(String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
    // currently we not support tcp upgrade (but websockets doing in WsProxy)
    // we can send error for docker clients (it accept only 400, 404 & 500 codes),
    // but sending 500 does not interrupt docker client, and its hangs
    request.upgrade(ImmediateCloseConnection.class);
    log.debug("{}: close upgraded connection", id);
}
 
Example 5
@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
  
    if (Log.doTrace()) {
        Log.trace("PingUpgradeServlet:doPost");
    }
    
    if ("echo".equals(req.getHeader("Upgrade"))) {
        
        if (Log.doTrace()) {
            Log.trace("PingUpgradeServlet:doPost -- found echo, doing upgrade");
        }
        
        res.setStatus(101);
        res.setHeader("Upgrade", "echo");
        res.setHeader("Connection", "Upgrade");

        req.upgrade(Handler.class);          
      
    } else {
        
        if (Log.doTrace()) {
            Log.trace("PingUpgradeServlet:doPost -- did not find echo, no upgrade");
        }
        
        res.getWriter().println("No upgrade: " + req.getHeader("Upgrade"));
    }
}
 
Example 6
Source Project: Tomcat8-Source-Read   File: TestUpgrade.java    License: MIT License 4 votes vote down vote up
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    req.upgrade(upgradeHandlerClass);
}
 
Example 7
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    req.upgrade(upgradeHandlerClass);
}
 
Example 8
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
    req.upgrade(Handler.class);
}
 
Example 9
Source Project: quarkus-http   File: UpgradeServlet.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
    req.upgrade(Handler.class);
}