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

org.mockserver.codec.MockServerHttpToNettyHttpResponseEncoder 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.MessageToMessageEncoder;
import org.mockserver.logging.MockServerLogger;
import org.mockserver.mappers.MockServerHttpResponseToFullHttpResponse;
import org.mockserver.model.HttpResponse;

import java.util.List;

/**
 * @author jamesdbloom
 */
public class MockServerHttpToNettyHttpResponseEncoder extends MessageToMessageEncoder {

    private final MockServerHttpResponseToFullHttpResponse mockServerHttpResponseToFullHttpResponse;

    public MockServerHttpToNettyHttpResponseEncoder(MockServerLogger mockServerLogger) {
        mockServerHttpResponseToFullHttpResponse = new MockServerHttpResponseToFullHttpResponse(mockServerLogger);
    }

    @Override
    protected void encode(ChannelHandlerContext ctx, HttpResponse response, List out) {
        out.addAll(mockServerHttpResponseToFullHttpResponse.mapMockServerResponseToNettyResponse(response));
    }

}