Java 类org.springframework.boot.devtools.tunnel.payload.HttpTunnelPayload 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelConnection.java   
private void handleResponse(ClientHttpResponse response) throws IOException {
    if (response.getStatusCode() == HttpStatus.GONE) {
        close();
        return;
    }
    if (response.getStatusCode() == HttpStatus.SERVICE_UNAVAILABLE) {
        logger.warn("Remote application responded with service unavailable. Did "
                + "you forget to start it with remote debugging enabled?");
        close();
        return;
    }
    if (response.getStatusCode() == HttpStatus.OK) {
        HttpTunnelPayload payload = HttpTunnelPayload.get(response);
        if (payload != null) {
            this.forwarder.forward(payload);
        }
    }
    if (response.getStatusCode() != HttpStatus.TOO_MANY_REQUESTS) {
        openNewConnection(null);
    }
}
项目:spring-boot-concourse    文件:HttpTunnelConnection.java   
private void handleResponse(ClientHttpResponse response) throws IOException {
    if (response.getStatusCode() == HttpStatus.GONE) {
        close();
        return;
    }
    if (response.getStatusCode() == HttpStatus.SERVICE_UNAVAILABLE) {
        logger.warn("Remote application responded with service unavailable. Did "
                + "you forget to start it with remote debugging enabled?");
        close();
        return;
    }
    if (response.getStatusCode() == HttpStatus.OK) {
        HttpTunnelPayload payload = HttpTunnelPayload.get(response);
        if (payload != null) {
            this.forwarder.forward(payload);
        }
    }
    if (response.getStatusCode() != HttpStatus.TOO_MANY_REQUESTS) {
        openNewConnection(null);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelConnection.java   
@Override
public int write(ByteBuffer src) throws IOException {
    int size = src.remaining();
    if (size > 0) {
        openNewConnection(
                new HttpTunnelPayload(this.requestSeq.incrementAndGet(), src));
    }
    return size;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelConnection.java   
private void sendAndReceive(HttpTunnelPayload payload) throws IOException {
    ClientHttpRequest request = createRequest(payload != null);
    if (payload != null) {
        payload.logIncoming();
        payload.assignTo(request);
    }
    handleResponse(request.execute());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServer.java   
private void readAndForwardTargetServerData() throws IOException {
    while (this.targetServer.isOpen()) {
        closeStaleHttpConnections();
        ByteBuffer data = HttpTunnelPayload.getPayloadData(this.targetServer);
        synchronized (this.httpConnections) {
            if (data != null) {
                HttpTunnelPayload payload = new HttpTunnelPayload(
                        this.responseSeq.incrementAndGet(), data);
                payload.logIncoming();
                HttpConnection connection = getOrWaitForHttpConnection();
                connection.respond(payload);
            }
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServer.java   
private void forwardToTargetServer(HttpConnection httpConnection)
        throws IOException {
    if (httpConnection.isDisconnectRequest()) {
        this.targetServer.close();
        interrupt();
    }
    ServerHttpRequest request = httpConnection.getRequest();
    HttpTunnelPayload payload = HttpTunnelPayload.get(request);
    if (payload != null) {
        this.payloadForwarder.forward(payload);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServer.java   
/**
 * Send a payload response.
 * @param payload the payload to send
 * @throws IOException in case of I/O errors
 */
public void respond(HttpTunnelPayload payload) throws IOException {
    Assert.notNull(payload, "Payload must not be null");
    this.response.setStatusCode(HttpStatus.OK);
    payload.assignTo(this.response);
    complete();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionRespondWithPayload() throws Exception {
    HttpConnection connection = new HttpConnection(this.request, this.response);
    connection.waitForResponse();
    connection.respond(new HttpTunnelPayload(1, ByteBuffer.wrap("hello".getBytes())));
    assertThat(this.servletResponse.getStatus()).isEqualTo(200);
    assertThat(this.servletResponse.getContentAsString()).isEqualTo("hello");
    assertThat(this.servletResponse.getHeader(SEQ_HEADER)).isEqualTo("1");
}
项目:spring-boot-concourse    文件:HttpTunnelConnection.java   
@Override
public int write(ByteBuffer src) throws IOException {
    int size = src.remaining();
    if (size > 0) {
        openNewConnection(
                new HttpTunnelPayload(this.requestSeq.incrementAndGet(), src));
    }
    return size;
}
项目:spring-boot-concourse    文件:HttpTunnelConnection.java   
private void sendAndReceive(HttpTunnelPayload payload) throws IOException {
    ClientHttpRequest request = createRequest(payload != null);
    if (payload != null) {
        payload.logIncoming();
        payload.assignTo(request);
    }
    handleResponse(request.execute());
}
项目:spring-boot-concourse    文件:HttpTunnelServer.java   
private void readAndForwardTargetServerData() throws IOException {
    while (this.targetServer.isOpen()) {
        closeStaleHttpConnections();
        ByteBuffer data = HttpTunnelPayload.getPayloadData(this.targetServer);
        synchronized (this.httpConnections) {
            if (data != null) {
                HttpTunnelPayload payload = new HttpTunnelPayload(
                        this.responseSeq.incrementAndGet(), data);
                payload.logIncoming();
                HttpConnection connection = getOrWaitForHttpConnection();
                connection.respond(payload);
            }
        }
    }
}
项目:spring-boot-concourse    文件:HttpTunnelServer.java   
private void forwardToTargetServer(HttpConnection httpConnection)
        throws IOException {
    if (httpConnection.isDisconnectRequest()) {
        this.targetServer.close();
        interrupt();
    }
    ServerHttpRequest request = httpConnection.getRequest();
    HttpTunnelPayload payload = HttpTunnelPayload.get(request);
    if (payload != null) {
        this.payloadForwarder.forward(payload);
    }
}
项目:spring-boot-concourse    文件:HttpTunnelServer.java   
/**
 * Send a payload response.
 * @param payload the payload to send
 * @throws IOException in case of I/O errors
 */
public void respond(HttpTunnelPayload payload) throws IOException {
    Assert.notNull(payload, "Payload must not be null");
    this.response.setStatusCode(HttpStatus.OK);
    payload.assignTo(this.response);
    complete();
}
项目:spring-boot-concourse    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionRespondWithPayload() throws Exception {
    HttpConnection connection = new HttpConnection(this.request, this.response);
    connection.waitForResponse();
    connection.respond(new HttpTunnelPayload(1, ByteBuffer.wrap("hello".getBytes())));
    assertThat(this.servletResponse.getStatus()).isEqualTo(200);
    assertThat(this.servletResponse.getContentAsString()).isEqualTo("hello");
    assertThat(this.servletResponse.getHeader(SEQ_HEADER)).isEqualTo("1");
}
项目:contestparser    文件:HttpTunnelConnection.java   
@Override
public int write(ByteBuffer src) throws IOException {
    int size = src.remaining();
    if (size > 0) {
        openNewConnection(
                new HttpTunnelPayload(this.requestSeq.incrementAndGet(), src));
    }
    return size;
}
项目:contestparser    文件:HttpTunnelConnection.java   
private void sendAndReceive(HttpTunnelPayload payload) throws IOException {
    ClientHttpRequest request = createRequest(payload != null);
    if (payload != null) {
        payload.logIncoming();
        payload.assignTo(request);
    }
    handleResponse(request.execute());
}
项目:contestparser    文件:HttpTunnelConnection.java   
private void handleResponse(ClientHttpResponse response) throws IOException {
    if (response.getStatusCode() == HttpStatus.GONE) {
        close();
        return;
    }
    if (response.getStatusCode() == HttpStatus.OK) {
        HttpTunnelPayload payload = HttpTunnelPayload.get(response);
        if (payload != null) {
            this.forwarder.forward(payload);
        }
    }
    if (response.getStatusCode() != HttpStatus.TOO_MANY_REQUESTS) {
        openNewConnection(null);
    }
}
项目:contestparser    文件:HttpTunnelServer.java   
private void readAndForwardTargetServerData() throws IOException {
    while (this.targetServer.isOpen()) {
        closeStaleHttpConnections();
        ByteBuffer data = HttpTunnelPayload.getPayloadData(this.targetServer);
        synchronized (this.httpConnections) {
            if (data != null) {
                HttpTunnelPayload payload = new HttpTunnelPayload(
                        this.responseSeq.incrementAndGet(), data);
                payload.logIncoming();
                HttpConnection connection = getOrWaitForHttpConnection();
                connection.respond(payload);
            }
        }
    }
}
项目:contestparser    文件:HttpTunnelServer.java   
private void forwardToTargetServer(HttpConnection httpConnection)
        throws IOException {
    if (httpConnection.isDisconnectRequest()) {
        this.targetServer.close();
        interrupt();
    }
    ServerHttpRequest request = httpConnection.getRequest();
    HttpTunnelPayload payload = HttpTunnelPayload.get(request);
    if (payload != null) {
        this.payloadForwarder.forward(payload);
    }
}
项目:contestparser    文件:HttpTunnelServer.java   
/**
 * Send a payload response.
 * @param payload the payload to send
 * @throws IOException in case of I/O errors
 */
public void respond(HttpTunnelPayload payload) throws IOException {
    Assert.notNull(payload, "Payload must not be null");
    this.response.setStatusCode(HttpStatus.OK);
    payload.assignTo(this.response);
    complete();
}
项目:contestparser    文件:HttpTunnelServerTests.java   
@Test
public void httpConnectionRespondWithPayload() throws Exception {
    HttpConnection connection = new HttpConnection(this.request, this.response);
    connection.waitForResponse();
    connection.respond(new HttpTunnelPayload(1, ByteBuffer.wrap("hello".getBytes())));
    assertThat(this.servletResponse.getStatus(), equalTo(200));
    assertThat(this.servletResponse.getContentAsString(), equalTo("hello"));
    assertThat(this.servletResponse.getHeader(SEQ_HEADER), equalTo("1"));
}