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

org.littleshoot.proxy.impl.ProxyConnectionPipeHandler Maven / Gradle / Ivy

Go to download

LittleProxy is a high performance HTTP proxy written in Java and using the Netty networking framework.

The newest version!
package org.littleshoot.proxy.impl;

import com.google.common.base.Preconditions;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * A {@link ChannelInboundHandler} that writes all incoming data to the
 * specified proxy connection.
 */
public class ProxyConnectionPipeHandler extends ChannelInboundHandlerAdapter {
    private final ProxyConnection sink;

    public ProxyConnectionPipeHandler(final ProxyConnection sink) {
        this.sink = Preconditions.checkNotNull(sink);
    }

    @Override
    public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
        sink.channel.writeAndFlush(msg);
    }
    
    @Override
    public void channelInactive(final ChannelHandlerContext ctx) {
        sink.disconnect();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy