Example usage for org.springframework.http.server ServerHttpRequest getBody

List of usage examples for org.springframework.http.server ServerHttpRequest getBody

Introduction

In this page you can find the example usage for org.springframework.http.server ServerHttpRequest getBody.

Prototype

InputStream getBody() throws IOException;

Source Link

Document

Return the body of the message as an input stream.

Usage

From source file:com.hxh.websocket.HandshakeInterceptor.java

@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response,
        WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
    System.out.println("Before Handshake");
    System.out.println(request.getHeaders().toString());
    System.out.println("?:" + request.getURI());
    System.out.println(":" + request.getBody());
    return super.beforeHandshake(request, response, wsHandler, attributes);
}

From source file:org.springframework.boot.devtools.restart.server.HttpRestartServer.java

/**
 * Handle a server request.//from ww w  .j a v  a  2 s.  c o  m
 * @param request the request
 * @param response the response
 * @throws IOException in case of I/O errors
 */
public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
    try {
        Assert.state(request.getHeaders().getContentLength() > 0, "No content");
        ObjectInputStream objectInputStream = new ObjectInputStream(request.getBody());
        ClassLoaderFiles files = (ClassLoaderFiles) objectInputStream.readObject();
        objectInputStream.close();
        this.server.updateAndRestart(files);
        response.setStatusCode(HttpStatus.OK);
    } catch (Exception ex) {
        logger.warn("Unable to handler restart server HTTP request", ex);
        response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}