Mercurial Hosting > luan
comparison src/org/eclipse/jetty/http/HttpGenerator.java @ 1065:158d1e6ac17f
fix JBuffer.compact()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 04:36:05 -0700 |
parents | a0abb16cf6e7 |
children | bbbda7c6e8ec |
comparison
equal
deleted
inserted
replaced
1064:a0abb16cf6e7 | 1065:158d1e6ac17f |
---|---|
132 throw new IllegalStateException("NO CONTENT"); | 132 throw new IllegalStateException("NO CONTENT"); |
133 | 133 |
134 if (_last || _state==STATE_END) | 134 if (_last || _state==STATE_END) |
135 { | 135 { |
136 LOG.warn("Ignoring extra content {}",content); | 136 LOG.warn("Ignoring extra content {}",content); |
137 content.clear(); | 137 // content.clear(); |
138 return; | 138 return; |
139 } | 139 } |
140 _last = last; | 140 _last = last; |
141 | 141 |
142 // Handle any unfinished business? | 142 // Handle any unfinished business? |
171 _contentWritten += content.remaining(); | 171 _contentWritten += content.remaining(); |
172 | 172 |
173 // Handle the _content | 173 // Handle the _content |
174 if (_head) | 174 if (_head) |
175 { | 175 { |
176 content.clear(); | 176 // content.clear(); |
177 _content=null; | 177 _content = null; |
178 } | 178 } |
179 else if ((_buffer==null || _buffer.remaining()==0) && _content.remaining() > 0 && (_last || isCommitted() && _content.remaining()>1024)) | 179 else if ((_buffer==null || _buffer.remaining()==0) && _content.remaining() > 0 && (_last || isCommitted() && _content.remaining()>1024)) |
180 { | 180 { |
181 _bypass = true; | 181 _bypass = true; |
182 } | 182 } |
341 if (_status<200 && _status>=100 ) | 341 if (_status<200 && _status>=100 ) |
342 { | 342 { |
343 _noContent = true; | 343 _noContent = true; |
344 _content=null; | 344 _content=null; |
345 if (_buffer!=null) | 345 if (_buffer!=null) |
346 _buffer.clear(); | 346 _buffer.clearJ(); |
347 // end the header. | 347 // end the header. |
348 | 348 |
349 if (_status!=101 ) | 349 if (_status!=101 ) |
350 { | 350 { |
351 _header.put(HttpTokens.CRLF); | 351 _header.put(HttpTokens.CRLF); |
356 else if (_status==204 || _status==304) | 356 else if (_status==204 || _status==304) |
357 { | 357 { |
358 _noContent = true; | 358 _noContent = true; |
359 _content=null; | 359 _content=null; |
360 if (_buffer!=null) | 360 if (_buffer!=null) |
361 _buffer.clear(); | 361 _buffer.clearJ(); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 // key field values | 365 // key field values |
366 HttpFields.Field content_length = null; | 366 HttpFields.Field content_length = null; |
696 case 0: | 696 case 0: |
697 { | 697 { |
698 len=0; | 698 len=0; |
699 // Nothing more we can write now. | 699 // Nothing more we can write now. |
700 if (_header != null) | 700 if (_header != null) |
701 _header.clear(); | 701 _header.clearJ(); |
702 | 702 |
703 _bypass = false; | 703 _bypass = false; |
704 _bufferChunked = false; | 704 _bufferChunked = false; |
705 | 705 |
706 if (_buffer != null) | 706 if (_buffer != null) |
707 { | 707 { |
708 _buffer.clear(); | 708 _buffer.clearJ(); |
709 if (_contentLength == HttpTokens.CHUNKED_CONTENT) | 709 if (_contentLength == HttpTokens.CHUNKED_CONTENT) |
710 { | 710 { |
711 // Special case handling for small left over buffer from | 711 // Special case handling for small left over buffer from |
712 // an addContent that caused a buffer flush. | 712 // an addContent that caused a buffer flush. |
713 if (_content != null && _content.remaining() < _buffer.space() && _state != STATE_FLUSHING) | 713 if (_content != null && _content.remaining() < _buffer.space() && _state != STATE_FLUSHING) |
714 { | 714 { |
715 _buffer.put(_content); | 715 _buffer.put(_content); |
716 _content.clear(); | 716 _content.clearJ(); |
717 _content=null; | 717 _content=null; |
718 } | 718 } |
719 } | 719 } |
720 } | 720 } |
721 | 721 |
956 _persistent = null; | 956 _persistent = null; |
957 _contentWritten = 0; | 957 _contentWritten = 0; |
958 _contentLength = HttpTokens.UNKNOWN_CONTENT; | 958 _contentLength = HttpTokens.UNKNOWN_CONTENT; |
959 _content = null; | 959 _content = null; |
960 if (_buffer!=null) | 960 if (_buffer!=null) |
961 _buffer.clear(); | 961 _buffer.clearJ(); |
962 } | 962 } |
963 | 963 |
964 /* ------------------------------------------------------------ */ | 964 /* ------------------------------------------------------------ */ |
965 /** | 965 /** |
966 * @return Returns the contentBufferSize. | 966 * @return Returns the contentBufferSize. |
1064 | 1064 |
1065 public final void completeUncheckedAddContent() | 1065 public final void completeUncheckedAddContent() |
1066 { | 1066 { |
1067 _contentWritten += _buffer.remaining(); | 1067 _contentWritten += _buffer.remaining(); |
1068 if (_head) | 1068 if (_head) |
1069 _buffer.clear(); | 1069 _buffer.clearJ(); |
1070 } | 1070 } |
1071 | 1071 |
1072 private boolean isBufferFull2() | 1072 private boolean isBufferFull2() |
1073 { | 1073 { |
1074 if (_buffer != null && _buffer.space()==0) | 1074 if (_buffer != null && _buffer.space()==0) |
1075 { | 1075 { |
1076 if (_buffer.remaining()==0) | 1076 if (_buffer.remaining()==0) |
1077 _buffer.compact(); | 1077 _buffer.limit(0); |
1078 return _buffer.space()==0; | 1078 return _buffer.space()==0; |
1079 } | 1079 } |
1080 | 1080 |
1081 return _content!=null && _content.remaining()>0; | 1081 return _content!=null && _content.remaining()>0; |
1082 } | 1082 } |