Search in sources :

Example 1 with ServerHttpAsyncRequestControl

use of org.springframework.http.server.ServerHttpAsyncRequestControl in project spring-framework by spring-projects.

the class AbstractHttpSockJsSession method resetRequest.

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());
                }
            }
        }
    }
}
Also used : ServerHttpAsyncRequestControl(org.springframework.http.server.ServerHttpAsyncRequestControl)

Example 2 with ServerHttpAsyncRequestControl

use of org.springframework.http.server.ServerHttpAsyncRequestControl in project spring-boot by spring-projects.

the class HttpTunnelServerTests method httpConnectionAsync.

@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();
}
Also used : HttpConnection(org.springframework.boot.devtools.tunnel.server.HttpTunnelServer.HttpConnection) ServerHttpRequest(org.springframework.http.server.ServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServerHttpAsyncRequestControl(org.springframework.http.server.ServerHttpAsyncRequestControl) Test(org.junit.Test)

Aggregations

ServerHttpAsyncRequestControl (org.springframework.http.server.ServerHttpAsyncRequestControl)2 Test (org.junit.Test)1 HttpConnection (org.springframework.boot.devtools.tunnel.server.HttpTunnelServer.HttpConnection)1 ServerHttpRequest (org.springframework.http.server.ServerHttpRequest)1 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)1