comparison src/org/eclipse/jetty/http/HttpParser.java @ 1051:1ab2dd0a7db5

remove JBuffer.get(int)
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 08 Nov 2016 00:18:45 -0700
parents 5ef954fad97b
children 4a2489f1d5fe
comparison
equal deleted inserted replaced
1050:5ef954fad97b 1051:1ab2dd0a7db5
112 _buffer.setGetIndex( old - _mark ); 112 _buffer.setGetIndex( old - _mark );
113 _mark = 0; 113 _mark = 0;
114 } 114 }
115 } 115 }
116 116
117 public JBuffer getBuffer(int length) {
118 JBuffer dup = _buffer.duplicate();
119 int end = _buffer.position() + length;
120 dup.limit(end);
121 _buffer.position(end);
122 return dup;
123 }
124
125
117 public long getContentLength() 126 public long getContentLength()
118 { 127 {
119 return _contentLength; 128 return _contentLength;
120 } 129 }
121 130
234 // do we have content to deliver? 243 // do we have content to deliver?
235 if (_state>STATE_END) 244 if (_state>STATE_END)
236 { 245 {
237 if (_buffer.remaining()>0 && !_headResponse) 246 if (_buffer.remaining()>0 && !_headResponse)
238 { 247 {
239 JBuffer chunk = _buffer.get(_buffer.remaining()); 248 JBuffer chunk = getBuffer(_buffer.remaining());
240 _contentPosition += chunk.remaining(); 249 _contentPosition += chunk.remaining();
241 _contentView = chunk; 250 _contentView = chunk;
242 _handler.content(); // May recurse here 251 _handler.content(); // May recurse here
243 } 252 }
244 } 253 }
781 _eol=0; 790 _eol=0;
782 switch (_state) 791 switch (_state)
783 { 792 {
784 case STATE_EOF_CONTENT: 793 case STATE_EOF_CONTENT:
785 { 794 {
786 JBuffer chunk = _buffer.get(_buffer.remaining()); 795 JBuffer chunk = getBuffer(_buffer.remaining());
787 _contentPosition += chunk.remaining(); 796 _contentPosition += chunk.remaining();
788 _contentView = chunk; 797 _contentView = chunk;
789 _handler.content(); // May recurse here 798 _handler.content(); // May recurse here
790 // TODO adjust the _buffer to keep unconsumed content 799 // TODO adjust the _buffer to keep unconsumed content
791 return 1; 800 return 1;
806 // We can cast reamining to an int as we know that it is smaller than 815 // We can cast reamining to an int as we know that it is smaller than
807 // or equal to length which is already an int. 816 // or equal to length which is already an int.
808 length=(int)remaining; 817 length=(int)remaining;
809 } 818 }
810 819
811 JBuffer chunk = _buffer.get(length); 820 JBuffer chunk = getBuffer(length);
812 _contentPosition += chunk.remaining(); 821 _contentPosition += chunk.remaining();
813 _contentView = chunk; 822 _contentView = chunk;
814 _handler.content(); // May recurse here 823 _handler.content(); // May recurse here
815 824
816 if(_contentPosition == _contentLength) 825 if(_contentPosition == _contentLength)
897 _state=STATE_CHUNKED_CONTENT; 906 _state=STATE_CHUNKED_CONTENT;
898 break; 907 break;
899 } 908 }
900 else if (length > remaining) 909 else if (length > remaining)
901 length=remaining; 910 length=remaining;
902 JBuffer chunk = _buffer.get(length); 911 JBuffer chunk = getBuffer(length);
903 _contentPosition += chunk.remaining(); 912 _contentPosition += chunk.remaining();
904 _chunkPosition += chunk.remaining(); 913 _chunkPosition += chunk.remaining();
905 _contentView = chunk; 914 _contentView = chunk;
906 _handler.content(); // May recurse here 915 _handler.content(); // May recurse here
907 // TODO adjust the _buffer to keep unconsumed content 916 // TODO adjust the _buffer to keep unconsumed content