List of usage examples for io.netty.util.internal AppendableCharSequence reset
public void reset()
From source file:openbns.commons.net.codec.sts.HttpObjectDecoder.java
License:Apache License
private AppendableCharSequence readHeader(ByteBuf buffer) { AppendableCharSequence sb = this.sb; sb.reset(); int headerSize = this.headerSize; loop: for (;;) { char nextByte = (char) buffer.readByte(); headerSize++;//from ww w. jav a 2 s . com switch (nextByte) { case StsConstants.CR: nextByte = (char) buffer.readByte(); headerSize++; if (nextByte == StsConstants.LF) { break loop; } break; case StsConstants.LF: break loop; } // Abort decoding if the header part is too large. if (headerSize >= maxHeaderSize) { // TODO: Respond with Bad Request and discard the traffic // or close the connection. // No need to notify the upstream handlers - just log. // If decoding a response, just throw an exception. throw new TooLongFrameException("HTTP header is larger than " + maxHeaderSize + " bytes."); } sb.append(nextByte); } this.headerSize = headerSize; return sb; }
From source file:openbns.commons.net.codec.sts.HttpObjectDecoder.java
License:Apache License
private AppendableCharSequence readLine(ByteBuf buffer, int maxLineLength) { AppendableCharSequence sb = this.sb; sb.reset(); int lineLength = 0; while (true) { byte nextByte = buffer.readByte(); if (nextByte == StsConstants.CR) { nextByte = buffer.readByte(); if (nextByte == StsConstants.LF) { return sb; }// ww w .j a v a 2s. co m } else if (nextByte == StsConstants.LF) { return sb; } else { if (lineLength >= maxLineLength) { // TODO: Respond with Bad Request and discard the traffic // or close the connection. // No need to notify the upstream handlers - just log. // If decoding a response, just throw an exception. throw new TooLongFrameException("An HTTP line is larger than " + maxLineLength + " bytes."); } lineLength++; sb.append((char) nextByte); } } }