All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockserver.codec.NettyHttpToMockServerHttpResponseDecoder Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.FullHttpResponse;
import org.mockserver.mappers.FullHttpResponseToMockServerHttpResponse;
import org.mockserver.logging.MockServerLogger;

import java.util.List;

/**
 * @author jamesdbloom
 */
public class NettyHttpToMockServerHttpResponseDecoder extends MessageToMessageDecoder {

    private final FullHttpResponseToMockServerHttpResponse fullHttpResponseToMockServerResponse;

    NettyHttpToMockServerHttpResponseDecoder(MockServerLogger mockServerLogger) {
        fullHttpResponseToMockServerResponse = new FullHttpResponseToMockServerHttpResponse(mockServerLogger);
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, FullHttpResponse fullHttpResponse, List out) {
        out.add(fullHttpResponseToMockServerResponse.mapFullHttpResponseToMockServerResponse(fullHttpResponse));
    }

}