Mercurial Hosting > luan
diff src/org/eclipse/jetty/http/HttpParser.java @ 1038:b71ad168fe34
rename Buffer.length() to remaining()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 22:16:11 -0600 |
parents | 3c4c7cc7904f |
children | 35e3c864d7a7 |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpParser.java Thu Nov 03 21:54:34 2016 -0600 +++ b/src/org/eclipse/jetty/http/HttpParser.java Thu Nov 03 22:16:11 2016 -0600 @@ -144,7 +144,7 @@ boolean progress = parseNext() > 0; // continue parsing - while (!isComplete() && _buffer!=null && _buffer.length()>0 && !_contentView.hasRemaining()) + while (!isComplete() && _buffer!=null && _buffer.remaining()>0 && !_contentView.hasRemaining()) { progress |= parseNext()>0; } @@ -177,7 +177,7 @@ return 1; } - int length = _buffer.length(); + int length = _buffer.remaining(); // Fill buffer if we can if (length == 0) @@ -187,7 +187,7 @@ try { filled=fill(); - LOG.debug("filled {}/{}",filled,_buffer.length()); + LOG.debug("filled {}/{}",filled,_buffer.remaining()); } catch(IOException e) { @@ -204,10 +204,10 @@ // do we have content to deliver? if (_state>STATE_END) { - if (_buffer.length()>0 && !_headResponse) + if (_buffer.remaining()>0 && !_headResponse) { - Buffer chunk = _buffer.get(_buffer.length()); - _contentPosition += chunk.length(); + Buffer chunk = _buffer.get(_buffer.remaining()); + _contentPosition += chunk.remaining(); _contentView.update(chunk); _handler.content(); // May recurse here } @@ -241,7 +241,7 @@ return -1; } - length=_buffer.length(); + length=_buffer.remaining(); } @@ -579,7 +579,7 @@ { _length = _cached.length(); _buffer.setGetIndex(_buffer.markIndex()+_length); - length = _buffer.length(); + length = _buffer.remaining(); } } } @@ -732,7 +732,7 @@ // ========================== // Handle _content - length=_buffer.length(); + length=_buffer.remaining(); Buffer chunk; last=_state; while (_state > STATE_END && length > 0) @@ -746,15 +746,15 @@ if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED) { _eol=_buffer.get(); - length=_buffer.length(); + length=_buffer.remaining(); continue; } _eol=0; switch (_state) { case STATE_EOF_CONTENT: - chunk=_buffer.get(_buffer.length()); - _contentPosition += chunk.length(); + chunk=_buffer.get(_buffer.remaining()); + _contentPosition += chunk.remaining(); _contentView.update(chunk); _handler.content(); // May recurse here // TODO adjust the _buffer to keep unconsumed content @@ -778,7 +778,7 @@ } chunk=_buffer.get(length); - _contentPosition += chunk.length(); + _contentPosition += chunk.remaining(); _contentView.update(chunk); _handler.content(); // May recurse here @@ -869,8 +869,8 @@ else if (length > remaining) length=remaining; chunk=_buffer.get(length); - _contentPosition += chunk.length(); - _chunkPosition += chunk.length(); + _contentPosition += chunk.remaining(); + _chunkPosition += chunk.remaining(); _contentView.update(chunk); _handler.content(); // May recurse here // TODO adjust the _buffer to keep unconsumed content @@ -880,7 +880,7 @@ case STATE_SEEKING_EOF: { // Close if there is more data than CRLF - if (_buffer.length()>2) + if (_buffer.remaining()>2) { _state = STATE_END; _endp.close(); @@ -888,7 +888,7 @@ else { // or if the data is not white space - while (_buffer.length()>0) + while (_buffer.remaining()>0) if (!Character.isWhitespace(_buffer.get())) { _state = STATE_END; @@ -902,7 +902,7 @@ } } - length=_buffer.length(); + length=_buffer.remaining(); } return progress; @@ -929,11 +929,11 @@ if (_state>STATE_END && _buffer==_header && !_header.hasRemaining() && _body.hasRemaining()) { _buffer = _body; - return _buffer.length(); + return _buffer.remaining(); } // Shall we switch to a body buffer? - if (_buffer==_header && _state>STATE_END && _header.length()==0 && ((_contentLength-_contentPosition)>_header.capacity())) + if (_buffer==_header && _state>STATE_END && _header.remaining()==0 && ((_contentLength-_contentPosition)>_header.capacity())) { _buffer = _body; } @@ -978,7 +978,7 @@ public Buffer blockForContent(long maxIdleTime) throws IOException { - if (_contentView.length()>0) + if (_contentView.remaining()>0) return _contentView; if (_state <= STATE_END || _state==STATE_SEEKING_EOF) @@ -989,7 +989,7 @@ parseNext(); // parse until some progress is made (or IOException thrown for timeout) - while(_contentView.length() == 0 && !(_state==STATE_END||_state==STATE_SEEKING_EOF) && _endp.isOpen()) + while(_contentView.remaining() == 0 && !(_state==STATE_END||_state==STATE_SEEKING_EOF) && _endp.isOpen()) { if (!_endp.isBlocking()) { @@ -1013,7 +1013,7 @@ throw e; } - return _contentView.length()>0 ? _contentView : null; + return _contentView.remaining()>0 ? _contentView : null; } /* ------------------------------------------------------------ */ @@ -1022,8 +1022,8 @@ */ public int available() throws IOException { - if (_contentView!=null && _contentView.length()>0) - return _contentView.length(); + if (_contentView!=null && _contentView.remaining()>0) + return _contentView.remaining(); if (_endp.isBlocking()) { @@ -1031,7 +1031,7 @@ } parseNext(); - return _contentView==null?0:_contentView.length(); + return _contentView==null?0:_contentView.remaining(); }