Java 类org.springframework.http.server.ServerHttpAsyncRequestControl 实例源码

项目:spring4-understanding    文件:AbstractHttpSockJsSession.java   
protected void resetRequest() {
    synchronized (this.responseLock) {

        ServerHttpAsyncRequestControl control = this.asyncRequestControl;
        this.asyncRequestControl = null;
        this.readyToSend = false;
        this.response = null;

        updateLastActiveTime();

        if (control != null && !control.isCompleted()) {
            if (control.isStarted()) {
                try {
                    control.complete();
                }
                catch (Throwable ex) {
                    // Could be part of normal workflow (e.g. browser tab closed)
                    logger.debug("Failed to complete request: " + ex.getMessage());
                }
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServer.java   
/**
 * Start asynchronous support or if unavailable return {@code null} to cause
 * {@link #waitForResponse()} to block.
 * @return the async request control
 */
protected ServerHttpAsyncRequestControl startAsync() {
    try {
        // Try to use async to save blocking
        ServerHttpAsyncRequestControl async = this.request
                .getAsyncRequestControl(this.response);
        async.start();
        return async;
    }
    catch (Exception ex) {
        return null;
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionAsync() throws Exception {
    ServerHttpAsyncRequestControl async = mock(ServerHttpAsyncRequestControl.class);
    ServerHttpRequest request = mock(ServerHttpRequest.class);
    given(request.getAsyncRequestControl(this.response)).willReturn(async);
    HttpConnection connection = new HttpConnection(request, this.response);
    connection.waitForResponse();
    verify(async).start();
    connection.respond(HttpStatus.NO_CONTENT);
    verify(async).complete();
}
项目:spring-boot-concourse    文件:HttpTunnelServer.java   
/**
 * Start asynchronous support or if unavailable return {@code null} to cause
 * {@link #waitForResponse()} to block.
 * @return the async request control
 */
protected ServerHttpAsyncRequestControl startAsync() {
    try {
        // Try to use async to save blocking
        ServerHttpAsyncRequestControl async = this.request
                .getAsyncRequestControl(this.response);
        async.start();
        return async;
    }
    catch (Exception ex) {
        return null;
    }
}
项目:spring-boot-concourse    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionAsync() throws Exception {
    ServerHttpAsyncRequestControl async = mock(ServerHttpAsyncRequestControl.class);
    ServerHttpRequest request = mock(ServerHttpRequest.class);
    given(request.getAsyncRequestControl(this.response)).willReturn(async);
    HttpConnection connection = new HttpConnection(request, this.response);
    connection.waitForResponse();
    verify(async).start();
    connection.respond(HttpStatus.NO_CONTENT);
    verify(async).complete();
}
项目:contestparser    文件:HttpTunnelServer.java   
/**
 * Start asynchronous support or if unavailble return {@code null} to cause
 * {@link #waitForResponse()} to block.
 * @return the async request control
 */
protected ServerHttpAsyncRequestControl startAsync() {
    try {
        // Try to use async to save blocking
        ServerHttpAsyncRequestControl async = this.request
                .getAsyncRequestControl(this.response);
        async.start();
        return async;
    }
    catch (Exception ex) {
        return null;
    }
}
项目:contestparser    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionAsync() throws Exception {
    ServerHttpAsyncRequestControl async = mock(ServerHttpAsyncRequestControl.class);
    ServerHttpRequest request = mock(ServerHttpRequest.class);
    given(request.getAsyncRequestControl(this.response)).willReturn(async);
    HttpConnection connection = new HttpConnection(request, this.response);
    connection.waitForResponse();
    verify(async).start();
    connection.respond(HttpStatus.NO_CONTENT);
    verify(async).complete();
}
项目:spring4-understanding    文件:AbstractHttpSockJsSession.java   
@Override
public boolean isActive() {
    ServerHttpAsyncRequestControl control = this.asyncRequestControl;
    return (control != null && !control.isCompleted());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServerTests.java   
@Override
protected ServerHttpAsyncRequestControl startAsync() {
    getServletRequest().setAsyncSupported(true);
    return super.startAsync();
}
项目:spring-boot-concourse    文件:HttpTunnelServerTests.java   
@Override
protected ServerHttpAsyncRequestControl startAsync() {
    getServletRequest().setAsyncSupported(true);
    return super.startAsync();
}
项目:contestparser    文件:HttpTunnelServerTests.java   
@Override
protected ServerHttpAsyncRequestControl startAsync() {
    getServletRequest().setAsyncSupported(true);
    return super.startAsync();
}