Search in sources :

Example 11 with HttpDecoratedRequest

use of com.robo4j.socket.http.message.HttpDecoratedRequest in project robo4j by Robo4J.

the class ChannelRequestBuffer method getHttpDecoratedRequestByChannel.

public HttpDecoratedRequest getHttpDecoratedRequestByChannel(ByteChannel channel) throws IOException {
    final StringBuilder sbBasic = new StringBuilder();
    int readBytes = channel.read(requestBuffer);
    if (readBytes != ChannelBufferUtils.BUFFER_MARK_END) {
        requestBuffer.flip();
        ChannelBufferUtils.addToStringBuilder(sbBasic, requestBuffer, readBytes);
        final HttpDecoratedRequest result = ChannelBufferUtils.extractDecoratedRequestByStringMessage(sbBasic.toString());
        ChannelBufferUtils.readChannelBuffer(result, channel, requestBuffer, readBytes);
        requestBuffer.clear();
        return result;
    } else {
        return new HttpDecoratedRequest(new HashMap<>(), new HttpRequestDenominator(HttpMethod.GET, HttpVersion.HTTP_1_1));
    }
}
Also used : HttpDecoratedRequest(com.robo4j.socket.http.message.HttpDecoratedRequest) HttpRequestDenominator(com.robo4j.socket.http.message.HttpRequestDenominator)

Aggregations

HttpDecoratedRequest (com.robo4j.socket.http.message.HttpDecoratedRequest)11 HttpRequestDenominator (com.robo4j.socket.http.message.HttpRequestDenominator)7 Test (org.junit.jupiter.api.Test)3 RoboContext (com.robo4j.RoboContext)2 SocketChannel (java.nio.channels.SocketChannel)2 ConfigurationException (com.robo4j.ConfigurationException)1 RoboBuilder (com.robo4j.RoboBuilder)1 HttpMethod (com.robo4j.socket.http.HttpMethod)1 SocketException (com.robo4j.socket.http.SocketException)1 HttpDecoratedResponse (com.robo4j.socket.http.message.HttpDecoratedResponse)1 HttpDenominator (com.robo4j.socket.http.message.HttpDenominator)1 HttpResponseProcess (com.robo4j.socket.http.request.HttpResponseProcess)1 RoboRequestCallable (com.robo4j.socket.http.request.RoboRequestCallable)1 RoboRequestFactory (com.robo4j.socket.http.request.RoboRequestFactory)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Map (java.util.Map)1 Disabled (org.junit.jupiter.api.Disabled)1