List of usage examples for io.netty.handler.codec LineBasedFrameDecoder LineBasedFrameDecoder
public LineBasedFrameDecoder(final int maxLength, final boolean stripDelimiter, final boolean failFast)
From source file:com.github.sinsinpub.pero.manual.proxyhandler.HttpProxyServer.java
License:Apache License
private boolean authenticate(ChannelHandlerContext ctx, FullHttpRequest req) { assertThat(req.method(), Matchers.is(HttpMethod.CONNECT)); if (testMode != TestMode.INTERMEDIARY) { ctx.pipeline().addBefore(ctx.name(), "lineDecoder", new LineBasedFrameDecoder(64, false, true)); }/*from www .j av a2 s . com*/ ctx.pipeline().remove(HttpObjectAggregator.class); ctx.pipeline().remove(HttpRequestDecoder.class); boolean authzSuccess = false; if (username != null) { CharSequence authz = req.headers().get(HttpHeaderNames.PROXY_AUTHORIZATION); if (authz != null) { String[] authzParts = StringUtil.split(authz.toString(), ' ', 2); ByteBuf authzBuf64 = Unpooled.copiedBuffer(authzParts[1], CharsetUtil.US_ASCII); ByteBuf authzBuf = Base64.decode(authzBuf64); String expectedAuthz = username + ':' + password; authzSuccess = "Basic".equals(authzParts[0]) && expectedAuthz.equals(authzBuf.toString(CharsetUtil.US_ASCII)); authzBuf64.release(); authzBuf.release(); } } else { authzSuccess = true; } return authzSuccess; }
From source file:com.heliosapm.streams.onramp.UDPPipelineFactory.java
License:Apache License
/** * {@inheritDoc}/*from www .j a v a2 s . co m*/ * @see io.netty.channel.ChannelInitializer#initChannel(io.netty.channel.Channel) */ @Override protected void initChannel(final AbstractChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast("bytesDecoder", bytesDecoder); p.addLast("framer", new LineBasedFrameDecoder(1024, true, true)); p.addLast("linehandler", new StringMetricHandler()); }
From source file:com.netflix.iep.http.ByteBufs.java
License:Apache License
/** * Process text data so that each output ByteBuf is a single line. The final line must have a * trailing line feed or it will be skipped. * * @param maxLength//from w w w . j a v a 2s. co m * Maximum length of a line. If a line that is too long is reached a TooLongFrameException * will be thrown. * @return * Observable where each ByteBuf is a single line. */ public static Observable.Transformer<ByteBuf, ByteBuf> lines(int maxLength) { return input -> { LineBasedFrameDecoder decoder = new LineBasedFrameDecoder(maxLength, true, true); return decode(input, new EmbeddedChannel(decoder)); }; }
From source file:com.whizzosoftware.hobson.mysensors.MySensorsPlugin.java
License:Open Source License
/** * Configures the Netty channel pipeline. This can be overridden by subclasses if needed. * * @param pipeline the current channel pipeline *//*from w w w. ja v a2 s . co m*/ @Override protected void configurePipeline(ChannelPipeline pipeline) { pipeline.addLast(new LineBasedFrameDecoder(256, true, true)); pipeline.addLast("decoder", getDecoder()); pipeline.addLast("encoder", getEncoder()); pipeline.addLast("client", new ChannelObjectDriverInboundHandler(this)); }