Mercurial Hosting > luan
comparison src/org/eclipse/jetty/http/HttpParser.java @ 1052:4a2489f1d5fe
remove JBuffer.peek()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 08 Nov 2016 00:27:16 -0700 |
parents | 1ab2dd0a7db5 |
children | 7e4b41247544 |
comparison
equal
deleted
inserted
replaced
1051:1ab2dd0a7db5 | 1052:4a2489f1d5fe |
---|---|
120 dup.limit(end); | 120 dup.limit(end); |
121 _buffer.position(end); | 121 _buffer.position(end); |
122 return dup; | 122 return dup; |
123 } | 123 } |
124 | 124 |
125 public byte peek() { | |
126 return _buffer.get(_buffer.position()); | |
127 } | |
128 | |
125 | 129 |
126 public long getContentLength() | 130 public long getContentLength() |
127 { | 131 { |
128 return _contentLength; | 132 return _contentLength; |
129 } | 133 } |
569 _contentLength=HttpTokens.EOF_CONTENT; | 573 _contentLength=HttpTokens.EOF_CONTENT; |
570 } | 574 } |
571 | 575 |
572 _contentPosition=0; | 576 _contentPosition=0; |
573 _eol=ch; | 577 _eol=ch; |
574 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) | 578 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED) |
575 _eol=_buffer.get(); | 579 _eol=_buffer.get(); |
576 | 580 |
577 // We convert _contentLength to an int for this switch statement because | 581 // We convert _contentLength to an int for this switch statement because |
578 // we don't care about the amount of data available just whether there is some. | 582 // we don't care about the amount of data available just whether there is some. |
579 switch (_contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) _contentLength) | 583 switch (_contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) _contentLength) |
779 { | 783 { |
780 progress++; | 784 progress++; |
781 last=_state; | 785 last=_state; |
782 } | 786 } |
783 | 787 |
784 if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED) | 788 if (_eol == HttpTokens.CARRIAGE_RETURN && peek() == HttpTokens.LINE_FEED) |
785 { | 789 { |
786 _eol=_buffer.get(); | 790 _eol=_buffer.get(); |
787 length=_buffer.remaining(); | 791 length=_buffer.remaining(); |
788 continue; | 792 continue; |
789 } | 793 } |
831 return 1; | 835 return 1; |
832 } | 836 } |
833 | 837 |
834 case STATE_CHUNKED_CONTENT: | 838 case STATE_CHUNKED_CONTENT: |
835 { | 839 { |
836 ch=_buffer.peek(); | 840 ch=peek(); |
837 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) | 841 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
838 _eol=_buffer.get(); | 842 _eol=_buffer.get(); |
839 else if (ch <= HttpTokens.SPACE) | 843 else if (ch <= HttpTokens.SPACE) |
840 _buffer.get(); | 844 _buffer.get(); |
841 else | 845 else |
854 { | 858 { |
855 _eol=ch; | 859 _eol=ch; |
856 | 860 |
857 if (_chunkLength == 0) | 861 if (_chunkLength == 0) |
858 { | 862 { |
859 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) | 863 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED) |
860 _eol=_buffer.get(); | 864 _eol=_buffer.get(); |
861 _state = _persistent?STATE_END:STATE_SEEKING_EOF; | 865 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
862 _handler.messageComplete(_contentPosition); | 866 _handler.messageComplete(_contentPosition); |
863 return 1; | 867 return 1; |
864 } | 868 } |
884 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) | 888 if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED) |
885 { | 889 { |
886 _eol=ch; | 890 _eol=ch; |
887 if (_chunkLength == 0) | 891 if (_chunkLength == 0) |
888 { | 892 { |
889 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED) | 893 if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED) |
890 _eol=_buffer.get(); | 894 _eol=_buffer.get(); |
891 _state = _persistent?STATE_END:STATE_SEEKING_EOF; | 895 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
892 _handler.messageComplete(_contentPosition); | 896 _handler.messageComplete(_contentPosition); |
893 return 1; | 897 return 1; |
894 } | 898 } |