Mercurial Hosting > luan
comparison src/org/eclipse/jetty/http/HttpParser.java @ 1036:b87f97f6418a
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 21:42:41 -0600 |
parents | 563458c4dc93 |
children | 3c4c7cc7904f |
comparison
equal
deleted
inserted
replaced
1035:898774c2cd87 | 1036:b87f97f6418a |
---|---|
20 | 20 |
21 import java.io.IOException; | 21 import java.io.IOException; |
22 | 22 |
23 import org.eclipse.jetty.io.Buffer; | 23 import org.eclipse.jetty.io.Buffer; |
24 import org.eclipse.jetty.io.BufferUtil; | 24 import org.eclipse.jetty.io.BufferUtil; |
25 import org.eclipse.jetty.io.Buffers; | |
26 import org.eclipse.jetty.io.ByteArrayBuffer; | |
27 import org.eclipse.jetty.io.EndPoint; | 25 import org.eclipse.jetty.io.EndPoint; |
28 import org.eclipse.jetty.io.EofException; | 26 import org.eclipse.jetty.io.EofException; |
29 import org.eclipse.jetty.io.View; | 27 import org.eclipse.jetty.io.View; |
30 import org.eclipse.jetty.util.StringUtil; | 28 import org.eclipse.jetty.util.StringUtil; |
31 import org.slf4j.Logger; | 29 import org.slf4j.Logger; |
209 if (_buffer.length()>0 && !_headResponse) | 207 if (_buffer.length()>0 && !_headResponse) |
210 { | 208 { |
211 Buffer chunk = _buffer.get(_buffer.length()); | 209 Buffer chunk = _buffer.get(_buffer.length()); |
212 _contentPosition += chunk.length(); | 210 _contentPosition += chunk.length(); |
213 _contentView.update(chunk); | 211 _contentView.update(chunk); |
214 _handler.content(chunk); // May recurse here | 212 _handler.content(); // May recurse here |
215 } | 213 } |
216 } | 214 } |
217 | 215 |
218 // was this unexpected? | 216 // was this unexpected? |
219 switch(_state) | 217 switch(_state) |
756 { | 754 { |
757 case STATE_EOF_CONTENT: | 755 case STATE_EOF_CONTENT: |
758 chunk=_buffer.get(_buffer.length()); | 756 chunk=_buffer.get(_buffer.length()); |
759 _contentPosition += chunk.length(); | 757 _contentPosition += chunk.length(); |
760 _contentView.update(chunk); | 758 _contentView.update(chunk); |
761 _handler.content(chunk); // May recurse here | 759 _handler.content(); // May recurse here |
762 // TODO adjust the _buffer to keep unconsumed content | 760 // TODO adjust the _buffer to keep unconsumed content |
763 return 1; | 761 return 1; |
764 | 762 |
765 case STATE_CONTENT: | 763 case STATE_CONTENT: |
766 { | 764 { |
780 } | 778 } |
781 | 779 |
782 chunk=_buffer.get(length); | 780 chunk=_buffer.get(length); |
783 _contentPosition += chunk.length(); | 781 _contentPosition += chunk.length(); |
784 _contentView.update(chunk); | 782 _contentView.update(chunk); |
785 _handler.content(chunk); // May recurse here | 783 _handler.content(); // May recurse here |
786 | 784 |
787 if(_contentPosition == _contentLength) | 785 if(_contentPosition == _contentLength) |
788 { | 786 { |
789 _state = _persistent?STATE_END:STATE_SEEKING_EOF; | 787 _state = _persistent?STATE_END:STATE_SEEKING_EOF; |
790 _handler.messageComplete(_contentPosition); | 788 _handler.messageComplete(_contentPosition); |
872 length=remaining; | 870 length=remaining; |
873 chunk=_buffer.get(length); | 871 chunk=_buffer.get(length); |
874 _contentPosition += chunk.length(); | 872 _contentPosition += chunk.length(); |
875 _chunkPosition += chunk.length(); | 873 _chunkPosition += chunk.length(); |
876 _contentView.update(chunk); | 874 _contentView.update(chunk); |
877 _handler.content(chunk); // May recurse here | 875 _handler.content(); // May recurse here |
878 // TODO adjust the _buffer to keep unconsumed content | 876 // TODO adjust the _buffer to keep unconsumed content |
879 return 1; | 877 return 1; |
880 } | 878 } |
881 | 879 |
882 case STATE_SEEKING_EOF: | 880 case STATE_SEEKING_EOF: |
891 { | 889 { |
892 // or if the data is not white space | 890 // or if the data is not white space |
893 while (_buffer.length()>0) | 891 while (_buffer.length()>0) |
894 if (!Character.isWhitespace(_buffer.get())) | 892 if (!Character.isWhitespace(_buffer.get())) |
895 { | 893 { |
896 _state=STATE_END; | 894 _state = STATE_END; |
897 _endp.close(); | 895 _endp.close(); |
898 _buffer.clear(); | 896 _buffer.clear(); |
899 } | 897 } |
900 } | 898 } |
901 | 899 |
1037 } | 1035 } |
1038 | 1036 |
1039 | 1037 |
1040 public interface EventHandler | 1038 public interface EventHandler |
1041 { | 1039 { |
1042 public abstract void content(Buffer ref) throws IOException; | 1040 public abstract void content() throws IOException; |
1043 | 1041 |
1044 public void headerComplete() throws IOException; | 1042 public void headerComplete() throws IOException; |
1045 | 1043 |
1046 public void messageComplete(long contentLength) throws IOException; | 1044 public void messageComplete(long contentLength) throws IOException; |
1047 | 1045 |