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

remove Buffer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:15:42 -0700
parents a8c92b0a08ed
children
comparison
equal deleted inserted replaced
1047:1accf965d51a 1048:2b769da7f67d
18 18
19 package org.eclipse.jetty.http; 19 package org.eclipse.jetty.http;
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.JBuffer;
24 import org.eclipse.jetty.io.Buffers; 24 import org.eclipse.jetty.io.Buffers;
25 import org.eclipse.jetty.io.BufferUtil; 25 import org.eclipse.jetty.io.BufferUtil;
26 import org.eclipse.jetty.io.EndPoint; 26 import org.eclipse.jetty.io.EndPoint;
27 import org.eclipse.jetty.io.EofException; 27 import org.eclipse.jetty.io.EofException;
28 import org.slf4j.Logger; 28 import org.slf4j.Logger;
57 57
58 int _state = STATE_HEADER; 58 int _state = STATE_HEADER;
59 59
60 int _status = 0; 60 int _status = 0;
61 int _version = HttpVersions.HTTP_1_1_ORDINAL; 61 int _version = HttpVersions.HTTP_1_1_ORDINAL;
62 Buffer _reason; 62 JBuffer _reason;
63 Buffer _method; 63 JBuffer _method;
64 String _uri; 64 String _uri;
65 65
66 long _contentWritten = 0; 66 long _contentWritten = 0;
67 long _contentLength = HttpTokens.UNKNOWN_CONTENT; 67 long _contentLength = HttpTokens.UNKNOWN_CONTENT;
68 boolean _last = false; 68 boolean _last = false;
69 boolean _head = false; 69 boolean _head = false;
70 boolean _noContent = false; 70 boolean _noContent = false;
71 Boolean _persistent = null; 71 Boolean _persistent = null;
72 72
73 Buffer _header; // Buffer for HTTP header (and maybe small _content) 73 JBuffer _header; // JBuffer for HTTP header (and maybe small _content)
74 Buffer _buffer; // Buffer for copy of passed _content 74 JBuffer _buffer; // JBuffer for copy of passed _content
75 Buffer _content; // Buffer passed to addContent 75 JBuffer _content; // JBuffer passed to addContent
76 76
77 77
78 /* ------------------------------------------------------------------------------- */ 78 /* ------------------------------------------------------------------------------- */
79 /** 79 /**
80 * Constructor. 80 * Constructor.
92 /** 92 /**
93 * Add content. 93 * Add content.
94 * 94 *
95 * @param content 95 * @param content
96 * @param last 96 * @param last
97 * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}. 97 * @throws IllegalArgumentException if <code>content</code> is {@link JBuffer#isImmutable immutable}.
98 * @throws IllegalStateException If the request is not expecting any more content, 98 * @throws IllegalStateException If the request is not expecting any more content,
99 * or if the buffers are full and cannot be flushed. 99 * or if the buffers are full and cannot be flushed.
100 * @throws IOException if there is a problem flushing the buffers. 100 * @throws IOException if there is a problem flushing the buffers.
101 */ 101 */
102 public abstract void addContent(Buffer content, boolean last) throws IOException; 102 public abstract void addContent(JBuffer content, boolean last) throws IOException;
103 103
104 abstract boolean isRequest(); 104 abstract boolean isRequest();
105 105
106 public final boolean isOpen() 106 public final boolean isOpen()
107 { 107 {
131 if (_buffer==null) 131 if (_buffer==null)
132 _buffer = _buffers.getBuffer(); 132 _buffer = _buffers.getBuffer();
133 return _buffer.capacity(); 133 return _buffer.capacity();
134 } 134 }
135 135
136 public final Buffer getUncheckedBuffer() 136 public final JBuffer getUncheckedBuffer()
137 { 137 {
138 return _buffer; 138 return _buffer;
139 } 139 }
140 140
141 public final boolean isComplete() 141 public final boolean isComplete()
292 public final void flush(long maxIdleTime) throws IOException 292 public final void flush(long maxIdleTime) throws IOException
293 { 293 {
294 // block until everything is flushed 294 // block until everything is flushed
295 long now=System.currentTimeMillis(); 295 long now=System.currentTimeMillis();
296 long end=now+maxIdleTime; 296 long end=now+maxIdleTime;
297 Buffer content = _content; 297 JBuffer content = _content;
298 Buffer buffer = _buffer; 298 JBuffer buffer = _buffer;
299 if (content!=null && content.remaining()>0 || buffer!=null && buffer.remaining()>0 || isBufferFull()) 299 if (content!=null && content.remaining()>0 || buffer!=null && buffer.remaining()>0 || isBufferFull())
300 { 300 {
301 flushBuffer(); 301 flushBuffer();
302 302
303 while (now<end && (content!=null && content.remaining()>0 ||buffer!=null && buffer.remaining()>0) && _endp.isOpen()&& !_endp.isOutputShutdown()) 303 while (now<end && (content!=null && content.remaining()>0 ||buffer!=null && buffer.remaining()>0) && _endp.isOpen()&& !_endp.isOutputShutdown())