comparison src/org/eclipse/jetty/http/HttpGenerator.java @ 1048:2b769da7f67d

remove Buffer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:15:42 -0700
parents a7319f14ba1e
children afc9610dc12e
comparison
equal deleted inserted replaced
1047:1accf965d51a 1048:2b769da7f67d
20 20
21 import java.io.IOException; 21 import java.io.IOException;
22 import java.io.InterruptedIOException; 22 import java.io.InterruptedIOException;
23 import java.util.Arrays; 23 import java.util.Arrays;
24 24
25 import org.eclipse.jetty.io.Buffer; 25 import org.eclipse.jetty.io.JBuffer;
26 import org.eclipse.jetty.io.BufferUtil; 26 import org.eclipse.jetty.io.BufferUtil;
27 import org.eclipse.jetty.io.Buffers; 27 import org.eclipse.jetty.io.Buffers;
28 import org.eclipse.jetty.io.EndPoint; 28 import org.eclipse.jetty.io.EndPoint;
29 import org.eclipse.jetty.io.EofException; 29 import org.eclipse.jetty.io.EofException;
30 import org.eclipse.jetty.util.StringUtil; 30 import org.eclipse.jetty.util.StringUtil;
124 /** 124 /**
125 * Add content. 125 * Add content.
126 * 126 *
127 * @param content 127 * @param content
128 * @param last 128 * @param last
129 * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}. 129 * @throws IllegalArgumentException if <code>content</code> is {@link JBuffer#isImmutable immutable}.
130 * @throws IllegalStateException If the request is not expecting any more content, 130 * @throws IllegalStateException If the request is not expecting any more content,
131 * or if the buffers are full and cannot be flushed. 131 * or if the buffers are full and cannot be flushed.
132 * @throws IOException if there is a problem flushing the buffers. 132 * @throws IOException if there is a problem flushing the buffers.
133 */ 133 */
134 public void addContent(Buffer content, boolean last) throws IOException 134 public void addContent(JBuffer content, boolean last) throws IOException
135 { 135 {
136 if (_noContent) 136 if (_noContent)
137 throw new IllegalStateException("NO CONTENT"); 137 throw new IllegalStateException("NO CONTENT");
138 138
139 if (_last || _state==STATE_END) 139 if (_last || _state==STATE_END)
152 flushBuffer(); 152 flushBuffer();
153 if (_content != null && _content.remaining()>0) 153 if (_content != null && _content.remaining()>0)
154 { 154 {
155 if (_bufferChunked) 155 if (_bufferChunked)
156 { 156 {
157 Buffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining()); 157 JBuffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining());
158 nc.put(_content); 158 nc.put(_content);
159 nc.put(HttpTokens.CRLF); 159 nc.put(HttpTokens.CRLF);
160 BufferUtil.putHexInt(nc, content.remaining()); 160 BufferUtil.putHexInt(nc, content.remaining());
161 nc.put(HttpTokens.CRLF); 161 nc.put(HttpTokens.CRLF);
162 nc.put(content); 162 nc.put(content);
163 content=nc; 163 content=nc;
164 } 164 }
165 else 165 else
166 { 166 {
167 Buffer nc = _buffers.getBuffer(_content.remaining()+content.remaining()); 167 JBuffer nc = _buffers.getBuffer(_content.remaining()+content.remaining());
168 nc.put(_content); 168 nc.put(_content);
169 nc.put(content); 169 nc.put(content);
170 content=nc; 170 content=nc;
171 } 171 }
172 } 172 }
212 212
213 if (_last || _state==STATE_END) 213 if (_last || _state==STATE_END)
214 return -1; 214 return -1;
215 215
216 // Handle any unfinished business? 216 // Handle any unfinished business?
217 Buffer content = _content; 217 JBuffer content = _content;
218 if (content != null && content.remaining()>0 || _bufferChunked) 218 if (content != null && content.remaining()>0 || _bufferChunked)
219 { 219 {
220 flushBuffer(); 220 flushBuffer();
221 if (content != null && content.remaining()>0 || _bufferChunked) 221 if (content != null && content.remaining()>0 || _bufferChunked)
222 throw new IllegalStateException("FULL"); 222 throw new IllegalStateException("FULL");
981 } 981 }
982 982
983 @Override 983 @Override
984 public String toString() 984 public String toString()
985 { 985 {
986 Buffer header=_header; 986 JBuffer header=_header;
987 Buffer buffer=_buffer; 987 JBuffer buffer=_buffer;
988 Buffer content=_content; 988 JBuffer content=_content;
989 return String.format("%s{s=%d,h=%d,b=%d,c=%d}", 989 return String.format("%s{s=%d,h=%d,b=%d,c=%d}",
990 getClass().getSimpleName(), 990 getClass().getSimpleName(),
991 _state, 991 _state,
992 header == null ? -1 : header.remaining(), 992 header == null ? -1 : header.remaining(),
993 buffer == null ? -1 : buffer.remaining(), 993 buffer == null ? -1 : buffer.remaining(),