protected HttpMessage parseHead( final SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException { this.lineBuf.clear(); int i = sessionBuffer.readLine(this.lineBuf); if (i == -1) { throw new NoHttpResponseException("The target server failed to respond"); } //create the status line from the status string ParserCursor cursor = new ParserCursor(0, this.lineBuf.length()); StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor); return this.responseFactory.newHttpResponse(statusline, null); }
for (;;) { if (current == null) { current = new CharArrayBuffer(64); } else { current.clear(); int l = inbuffer.readLine(current); if (l == -1 || current.length() < 1) { break; CharArrayBuffer buffer = (CharArrayBuffer) headerLines.get(i); try { headers[i] = parser.parseHeader(buffer); } catch (ParseException ex) { throw new ProtocolException(ex.getMessage());
public final static ProtocolVersion parseProtocolVersion(String value, LineParser parser) throws ParseException { if (value == null) { throw new IllegalArgumentException ("Value to parse may not be null."); } if (parser == null) parser = BasicLineParser.DEFAULT; CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); ParserCursor cursor = new ParserCursor(0, value.length()); return parser.parseProtocolVersion(buffer, cursor); }
public final static StatusLine parseStatusLine(final String value, LineParser parser) throws ParseException { if (value == null) { throw new IllegalArgumentException ("Value to parse may not be null."); } if (parser == null) parser = BasicLineParser.DEFAULT; CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); ParserCursor cursor = new ParserCursor(0, value.length()); return parser.parseStatusLine(buffer, cursor); }
public final static RequestLine parseRequestLine(final String value, LineParser parser) throws ParseException { if (value == null) { throw new IllegalArgumentException ("Value to parse may not be null."); } if (parser == null) parser = BasicLineParser.DEFAULT; CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); ParserCursor cursor = new ParserCursor(0, value.length()); return parser.parseRequestLine(buffer, cursor); }
protected HttpMessage parseHead( final SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException { this.lineBuf.clear(); int i = sessionBuffer.readLine(this.lineBuf); if (i == -1) { throw new ConnectionClosedException("Client closed connection"); } ParserCursor cursor = new ParserCursor(0, this.lineBuf.length()); RequestLine requestline = this.lineParser.parseRequestLine(this.lineBuf, cursor); return this.requestFactory.newHttpRequest(requestline); }
public static Header parseHeader(final String value, final LineParser parser) throws ParseException { Args.notNull(value, "Value"); final CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); return (parser != null ? parser : BasicLineParser.INSTANCE) .parseHeader(buffer); }
public final static Header parseHeader(final String value, LineParser parser) throws ParseException { if (value == null) { throw new IllegalArgumentException ("Value to parse may not be null"); } if (parser == null) parser = BasicLineParser.DEFAULT; CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); return parser.parseHeader(buffer); }
while (this.state != COMPLETED) { if (this.lineBuf == null) { this.lineBuf = new CharArrayBuffer(64); } else { this.lineBuf.clear(); (this.lineBuf.length() > maxLineLen || (!lineComplete && this.sessionBuffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded"); for (final CharArrayBuffer buffer : this.headerBufs) { try { this.message.addHeader(lineParser.parseHeader(buffer)); } catch (final ParseException ex) { throw new ProtocolException(ex.getMessage(), ex);
@Override protected HttpResponse createMessage(final CharArrayBuffer buffer) throws HttpException, ParseException { final ParserCursor cursor = new ParserCursor(0, buffer.length()); final StatusLine statusline = lineParser.parseStatusLine(buffer, cursor); return this.responseFactory.newHttpResponse(statusline, null); }
@Override protected HttpRequest createMessage(final CharArrayBuffer buffer) throws HttpException, ParseException { final ParserCursor cursor = new ParserCursor(0, buffer.length()); final RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor); return this.requestFactory.newHttpRequest(requestLine); }
public static StatusLine parseStatusLine(final String value, final LineParser parser) throws ParseException { Args.notNull(value, "Value"); final CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); final ParserCursor cursor = new ParserCursor(0, value.length()); return (parser != null ? parser : BasicLineParser.INSTANCE) .parseStatusLine(buffer, cursor); }
public static RequestLine parseRequestLine(final String value, final LineParser parser) throws ParseException { Args.notNull(value, "Value"); final CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); final ParserCursor cursor = new ParserCursor(0, value.length()); return (parser != null ? parser : BasicLineParser.INSTANCE) .parseRequestLine(buffer, cursor); }
protected HttpMessage parseHead( final SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException { this.lineBuf.clear(); int i = sessionBuffer.readLine(this.lineBuf); if (i == -1) { throw new ConnectionClosedException("Client closed connection"); } ParserCursor cursor = new ParserCursor(0, this.lineBuf.length()); RequestLine requestline = this.lineParser.parseRequestLine(this.lineBuf, cursor); return this.requestFactory.newHttpRequest(requestline); }
public static Header parseHeader(final String value, final LineParser parser) throws ParseException { Args.notNull(value, "Value"); final CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); return (parser != null ? parser : BasicLineParserHC4.INSTANCE) .parseHeader(buffer); }
public final static Header parseHeader(final String value, LineParser parser) throws ParseException { if (value == null) { throw new IllegalArgumentException ("Value to parse may not be null"); } if (parser == null) parser = BasicLineParser.DEFAULT; CharArrayBuffer buffer = new CharArrayBuffer(value.length()); buffer.append(value); return parser.parseHeader(buffer); }
while (this.state != COMPLETED) { if (this.lineBuf == null) { this.lineBuf = new CharArrayBuffer(64); } else { this.lineBuf.clear(); (this.lineBuf.length() > maxLineLen || (!lineComplete && this.sessionBuffer.length() > maxLineLen))) { throw new MessageConstraintException("Maximum line length limit exceeded"); for (final CharArrayBuffer buffer : this.headerBufs) { try { this.message.addHeader(lineParser.parseHeader(buffer)); } catch (final ParseException ex) { throw new ProtocolException(ex.getMessage(), ex);
@Override protected HttpResponse createMessage(final CharArrayBuffer buffer) throws HttpException, ParseException { final ParserCursor cursor = new ParserCursor(0, buffer.length()); final StatusLine statusline = lineParser.parseStatusLine(buffer, cursor); return this.responseFactory.newHttpResponse(statusline, null); }
@Override protected HttpRequest createMessage(final CharArrayBuffer buffer) throws HttpException, ParseException { final ParserCursor cursor = new ParserCursor(0, buffer.length()); final RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor); return this.requestFactory.newHttpRequest(requestLine); }
@Override protected HttpMessage parseHead( final SessionInputBuffer sessionBuffer) throws IOException, HttpException { // clear the buffer this.lineBuf.clear(); //read out the HTTP status string int count = 0; ParserCursor cursor = null; do { int i = sessionBuffer.readLine(this.lineBuf); if (i == -1 && count == 0) { // The server just dropped connection on us throw new NoHttpResponseException("The target server failed to respond"); } cursor = new ParserCursor(0, this.lineBuf.length()); if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) { // Got one break; } else if (i == -1 || count >= this.maxGarbageLines) { // Giving up throw new ProtocolException("The server failed to respond with a " + "valid HTTP response"); } count++; } while(true); //create the status line from the status string StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor); return this.responseFactory.newHttpResponse(statusline, null); }