public static Request parseRequest(ByteBuffer request) { Request r=new Request(); HttpParser parser =new HttpParser(r); parser.parseNext(request); return r; }
/** * Parse until {@link #STATE_END END} state. * If the parser is already in the END state, then it is {@link #reset reset} and re-parsed. * @throws IllegalStateException If the buffers have already been partially parsed. */ public void parse() throws IOException { if (_state==STATE_END) reset(); if (_state!=STATE_START) throw new IllegalStateException("!START"); // continue parsing while (_state != STATE_END) if (parseNext()<0) return; }
_buffer=getHeaderBuffer(); try filled=fill(); LOG.debug("filled {}/{}",filled,_buffer.length()); LOG.debug(this.toString(),e); ex=e; throw ex; if (!isComplete() && !isIdle()) throw new EofException();
_parser.setPersistent(true); if (_parser instanceof HttpParser) ((HttpParser)_parser).setState(HttpParser.STATE_END); if ((((HttpParser)_parser).getContentLength()<=0 && !((HttpParser)_parser).isChunking())||_expect100Continue) handleRequest(); else
getEndPoint().upgrade(connection); _channel.recycle(); _parser.reset(); _generator.reset(); if (_contentBufferReferences.get()==0) _parser.close(); else if (_parser.inContentState() && _generator.isPersistent()) if (_generator.isPersistent() && !_parser.isClosed()) _parser.reset(); else _parser.close(); if (_parser.isStart())
connection.fillBuffersFrom(((HttpParser)http.getParser()).getHeaderBuffer()); connection.fillBuffersFrom(((HttpParser)http.getParser()).getBodyBuffer());
boolean call_channel=_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer); _parser.shutdownInput(); call_channel=_parser.parseNext(_requestBuffer); while (_parser.inContentState()) if (!_parser.parseNext(_requestBuffer==null?BufferUtil.EMPTY_BUFFER:_requestBuffer)) break; if (_parser.isIdle()) LOG.debug(e); else
public void reset() { // reset state setState(State.START); _endOfContent=EndOfContent.UNKNOWN_CONTENT; _contentLength=-1; _contentPosition=0; _responseStatus=0; _contentChunk=null; _headerBytes=0; _host=false; }
public Connection handle() throws IOException while (_endp.isOpen() && !_parser.isComplete()) return this; if (!_parser.parseAvailable()) Buffer header = _parser.getHeaderBuffer(); if (header.hasContent()) connection.fillBuffersFrom(header);
_httpConnection.getParser().close(); return false; && (_httpConnection.getParser().getContentLength() > 0 || _httpConnection.getParser().isChunking()) && !isExpecting100Continue() && !isCommitted()
@Override protected void reset() { super.reset(); parser.reset(); }
public void reset() { // If we are still expecting if (_channel.isExpecting100Continue()) { // reset to avoid seeking remaining content _parser.reset(); // close to seek EOF _parser.close(); } // else if we are persistent else if (_generator.isPersistent()) // reset to seek next request _parser.reset(); else // else seek EOF _parser.close(); _generator.reset(); _channel.reset(); releaseRequestBuffer(); if (_chunk!=null) { _bufferPool.release(_chunk); _chunk=null; } }
private void parse(ByteBuffer buffer) { while (buffer.hasRemaining()) parser.parseNext(buffer); }
public HttpReceiverOverHTTP(HttpChannelOverHTTP channel) { super(channel); parser = new HttpParser(this, -1, channel.getHttpDestination().getHttpClient().getHttpCompliance()); }
if ((((HttpParser)_parser).getContentLength()<=0 && !((HttpParser)_parser).isChunking())||_expect100Continue) handleRequest(); else
/** * Get the inputStream from the connection. * <p> * If the associated response has the Expect header set to 100 Continue, * then accessing the input stream indicates that the handler/servlet * is ready for the request body and thus a 100 Continue response is sent. * * @return The input stream for this connection. * The stream will be created if it does not already exist. * @throws IOException if the input stream cannot be retrieved */ public ServletInputStream getInputStream() throws IOException { // If the client is expecting 100 CONTINUE, then send it now. if (_expect100Continue) { // is content missing? if (((HttpParser)_parser).getHeaderBuffer()==null || ((HttpParser)_parser).getHeaderBuffer().length()<2) { if (_generator.isCommitted()) throw new IllegalStateException("Committed before 100 Continues"); ((HttpGenerator)_generator).send1xx(HttpStatus.CONTINUE_100); } _expect100Continue=false; } if (_in == null) _in = new HttpInput(AbstractHttpConnection.this); return _in; }
_httpConnection.getParser().close(); return false; _delayedForContent = (getHttpConfiguration().isDelayDispatchUntilContent() && _httpConnection.getParser().getContentLength()>0 && !isExpecting100Continue() && !isCommitted() && _httpConnection.isRequestBufferEmpty());