Mercurial Hosting > luan
annotate src/org/eclipse/jetty/http/HttpGenerator.java @ 1057:afc9610dc12e
remove AbstractGenerator
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 08 Nov 2016 04:05:04 -0700 |
parents | 2b769da7f67d |
children | 419bf9c03d84 |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.http; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.IOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import java.io.InterruptedIOException; |
1039
a7319f14ba1e
remove Buffer.isImmutable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
23 import java.util.Arrays; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 |
1048 | 25 import org.eclipse.jetty.io.JBuffer; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import org.eclipse.jetty.io.BufferUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import org.eclipse.jetty.io.Buffers; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import org.eclipse.jetty.io.EndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 import org.eclipse.jetty.io.EofException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import org.eclipse.jetty.util.StringUtil; |
884
cb78ee27b0e0
remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents:
877
diff
changeset
|
31 import org.eclipse.jetty.server.Server; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
32 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
33 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 /* ------------------------------------------------------------ */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 /** |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 * HttpGenerator. Builds HTTP Messages. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 */ |
1057
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
42 public final class HttpGenerator |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 { |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
44 private static final Logger LOG = LoggerFactory.getLogger(HttpGenerator.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
46 // Build cache of response lines for status |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
47 private static class Status |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
48 { |
1039
a7319f14ba1e
remove Buffer.isImmutable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
49 byte[] _schemeCode; |
a7319f14ba1e
remove Buffer.isImmutable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
50 byte[] _responseLine; |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
51 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
52 private static final Status[] __status = new Status[HttpStatus.MAX_CODE+1]; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
53 static |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
54 { |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
990
diff
changeset
|
55 final int versionLength=HttpVersions.HTTP_1_1_BYTES.length; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
57 for (int i=0;i<__status.length;i++) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
58 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
59 HttpStatus.Code code = HttpStatus.getCode(i); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
60 if (code==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
61 continue; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
62 String reason=code.getMessage(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
63 byte[] bytes=new byte[versionLength+5+reason.length()+2]; |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
990
diff
changeset
|
64 // HttpVersions.HTTP_1_1_BUFFER.peek(0,bytes, 0, versionLength); |
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
990
diff
changeset
|
65 System.arraycopy(HttpVersions.HTTP_1_1_BYTES,0,bytes,0,versionLength); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 bytes[versionLength+0]=' '; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 bytes[versionLength+1]=(byte)('0'+i/100); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 bytes[versionLength+2]=(byte)('0'+(i%100)/10); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
69 bytes[versionLength+3]=(byte)('0'+(i%10)); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
70 bytes[versionLength+4]=' '; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
71 for (int j=0;j<reason.length();j++) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
72 bytes[versionLength+5+j]=(byte)reason.charAt(j); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
73 bytes[versionLength+5+reason.length()]=HttpTokens.CARRIAGE_RETURN; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
74 bytes[versionLength+6+reason.length()]=HttpTokens.LINE_FEED; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
75 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
76 __status[i] = new Status(); |
1039
a7319f14ba1e
remove Buffer.isImmutable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
77 __status[i]._schemeCode = Arrays.copyOf(bytes,versionLength+5); |
a7319f14ba1e
remove Buffer.isImmutable()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1038
diff
changeset
|
78 __status[i]._responseLine = bytes; |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
79 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
80 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
81 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
82 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
83 // common _content |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
84 private static final byte[] LAST_CHUNK = |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
85 { (byte) '0', (byte) '\015', (byte) '\012', (byte) '\015', (byte) '\012'}; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
86 private static final byte[] CONTENT_LENGTH_0 = StringUtil.getBytes("Content-Length: 0\015\012"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
87 private static final byte[] CONNECTION_KEEP_ALIVE = StringUtil.getBytes("Connection: keep-alive\015\012"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
88 private static final byte[] CONNECTION_CLOSE = StringUtil.getBytes("Connection: close\015\012"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 private static final byte[] CONNECTION_ = StringUtil.getBytes("Connection: "); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
90 private static final byte[] CRLF = StringUtil.getBytes("\015\012"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 private static final byte[] TRANSFER_ENCODING_CHUNKED = StringUtil.getBytes("Transfer-Encoding: chunked\015\012"); |
884
cb78ee27b0e0
remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents:
877
diff
changeset
|
92 private static byte[] SERVER = StringUtil.getBytes("Server: Jetty("+Server.version+")\015\012"); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
93 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 // other statics |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 private static final int CHUNK_SPACE = 12; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
96 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
97 // data |
983
23ec25435b8c
simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
982
diff
changeset
|
98 private boolean _bypass = false; // True if _content buffer can be written directly to endp and bypass the content buffer |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 private boolean _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 private boolean _needEOC = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
101 private boolean _bufferChunked = false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
102 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
103 |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
104 public void shutdown() { |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 if (_persistent!=null && !_persistent && _endp!=null && !_endp.isOutputShutdown()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
106 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 try |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
109 _endp.shutdownOutput(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
110 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
111 catch(IOException e) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 LOG.trace("",e); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
114 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
116 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
117 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
118 /* ------------------------------------------------------------ */ |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
119 /** |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
120 * Add content. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
121 * |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 * @param content |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 * @param last |
1048 | 124 * @throws IllegalArgumentException if <code>content</code> is {@link JBuffer#isImmutable immutable}. |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
125 * @throws IllegalStateException If the request is not expecting any more content, |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
126 * or if the buffers are full and cannot be flushed. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
127 * @throws IOException if there is a problem flushing the buffers. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 */ |
1048 | 129 public void addContent(JBuffer content, boolean last) throws IOException |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
131 if (_noContent) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 throw new IllegalStateException("NO CONTENT"); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
133 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
134 if (_last || _state==STATE_END) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 LOG.warn("Ignoring extra content {}",content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 content.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 return; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
140 _last = last; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
141 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 // Handle any unfinished business? |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
143 if (_content!=null && _content.remaining()>0 || _bufferChunked) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
144 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
145 if (_endp.isOutputShutdown()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 throw new EofException(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
147 flushBuffer(); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
148 if (_content != null && _content.remaining()>0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 if (_bufferChunked) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 { |
1048 | 152 JBuffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining()); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
153 nc.put(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
154 nc.put(HttpTokens.CRLF); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
155 BufferUtil.putHexInt(nc, content.remaining()); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 nc.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 nc.put(content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 content=nc; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
160 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 { |
1048 | 162 JBuffer nc = _buffers.getBuffer(_content.remaining()+content.remaining()); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
163 nc.put(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 nc.put(content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
165 content=nc; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
167 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
168 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
169 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
170 _content = content; |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
171 _contentWritten += content.remaining(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
172 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 // Handle the _content |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 if (_head) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 content.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
177 _content=null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
178 } |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
179 else if (_endp != null && (_buffer==null || _buffer.remaining()==0) && _content.remaining() > 0 && (_last || isCommitted() && _content.remaining()>1024)) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
180 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
181 _bypass = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 else if (!_bufferChunked) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
184 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 // Yes - so we better check we have a buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
186 if (_buffer == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 _buffer = _buffers.getBuffer(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
188 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 // Copy _content to buffer; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
190 int len=_buffer.put(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
191 _content.skip(len); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
192 if (_content.remaining() == 0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 _content = null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
194 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
195 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
196 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
197 /* ------------------------------------------------------------ */ |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 /** Prepare buffer for unchecked writes. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 * Prepare the generator buffer to receive unchecked writes |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 * @return the available space in the buffer. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
201 * @throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
202 */ |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
203 public int prepareUncheckedAddContent() throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
204 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 if (_noContent) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 return -1; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
207 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
208 if (_last || _state==STATE_END) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
209 return -1; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
210 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
211 // Handle any unfinished business? |
1048 | 212 JBuffer content = _content; |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
213 if (content != null && content.remaining()>0 || _bufferChunked) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
215 flushBuffer(); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
216 if (content != null && content.remaining()>0 || _bufferChunked) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
217 throw new IllegalStateException("FULL"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
218 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
219 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 // we better check we have a buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 if (_buffer == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 _buffer = _buffers.getBuffer(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
223 |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
224 _contentWritten-=_buffer.remaining(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
225 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
226 // Handle the _content |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 if (_head) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
228 return Integer.MAX_VALUE; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
229 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 return _buffer.space()-(_contentLength == HttpTokens.CHUNKED_CONTENT?CHUNK_SPACE:0); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
232 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 public boolean isBufferFull() |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
235 // Should we flush the buffers? |
1057
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
236 return isBufferFull2() || _bufferChunked || _bypass || (_contentLength == HttpTokens.CHUNKED_CONTENT && _buffer != null && _buffer.space() < CHUNK_SPACE); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
238 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
239 public void send1xx(int code) throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
241 if (_state != STATE_HEADER) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
242 return; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
243 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
244 if (code<100||code>199) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 throw new IllegalArgumentException("!1xx"); |
983
23ec25435b8c
simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
982
diff
changeset
|
246 Status status = __status[code]; |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
247 if (status==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 throw new IllegalArgumentException(code+"?"); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
249 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 // get a header buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 if (_header == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 _header = _buffers.getHeader(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
253 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
254 _header.put(status._responseLine); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 _header.put(HttpTokens.CRLF); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
256 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 try |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
259 // nasty semi busy flush! |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
260 while(_header.remaining()>0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
261 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 int len = _endp.flush(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 if (len<0) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 throw new EofException(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 if (len==0) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 Thread.sleep(100); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
268 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 catch(InterruptedException e) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 LOG.debug("",e); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
272 throw new InterruptedIOException(e.toString()); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
274 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
275 |
983
23ec25435b8c
simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
982
diff
changeset
|
276 boolean isRequest() |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
277 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 return _method!=null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
280 |
983
23ec25435b8c
simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
982
diff
changeset
|
281 private boolean isResponse() |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
283 return _method==null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
284 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
285 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 public void completeHeader(HttpFields fields, boolean allContentAdded) throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
288 if (_state != STATE_HEADER) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
289 return; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
290 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 // handle a reset |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
292 if (isResponse() && _status==0) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 throw new EofException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
294 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 if (_last && !allContentAdded) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
296 throw new IllegalStateException("last?"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 _last = _last | allContentAdded; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
298 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 // get a header buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 if (_header == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 _header = _buffers.getHeader(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
302 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 boolean has_server = false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
304 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
305 try |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
306 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 if (isRequest()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 { |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
309 _persistent = true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
310 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 if (_version == HttpVersions.HTTP_0_9_ORDINAL) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
313 _contentLength = HttpTokens.NO_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
314 _header.put(_method); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
315 _header.put((byte)' '); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
316 _header.put(_uri.getBytes("UTF-8")); // TODO check |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
317 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
318 _state = STATE_FLUSHING; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
319 _noContent=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
320 return; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
321 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
322 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
323 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
324 _header.put(_method); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
325 _header.put((byte)' '); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
326 _header.put(_uri.getBytes("UTF-8")); // TODO check |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
327 _header.put((byte)' '); |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
990
diff
changeset
|
328 _header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BYTES:HttpVersions.HTTP_1_1_BYTES); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
329 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
330 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
331 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
332 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
333 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
334 // Responses |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
335 if (_version == HttpVersions.HTTP_0_9_ORDINAL) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
336 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
337 _persistent = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
338 _contentLength = HttpTokens.EOF_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
339 _state = STATE_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
340 return; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
341 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
342 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
343 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
344 if (_persistent==null) |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
345 _persistent = (_version > HttpVersions.HTTP_1_0_ORDINAL); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
346 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
347 // add response line |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
348 Status status = _status<__status.length?__status[_status]:null; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
349 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
350 if (status==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
351 { |
1019
f126d30e04a4
start replacing BufferCache with StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
990
diff
changeset
|
352 _header.put(HttpVersions.HTTP_1_1_BYTES); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
353 _header.put((byte) ' '); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
354 _header.put((byte) ('0' + _status / 100)); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
355 _header.put((byte) ('0' + (_status % 100) / 10)); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
356 _header.put((byte) ('0' + (_status % 10))); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
357 _header.put((byte) ' '); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
358 if (_reason==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
359 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
360 _header.put((byte) ('0' + _status / 100)); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
361 _header.put((byte) ('0' + (_status % 100) / 10)); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
362 _header.put((byte) ('0' + (_status % 10))); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
363 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
364 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
365 _header.put(_reason); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
366 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
367 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
368 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
369 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
370 if (_reason==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
371 _header.put(status._responseLine); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
372 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
373 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
374 _header.put(status._schemeCode); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
375 _header.put(_reason); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
376 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
377 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
378 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
379 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
380 if (_status<200 && _status>=100 ) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
381 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
382 _noContent=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
383 _content=null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
384 if (_buffer!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
385 _buffer.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
386 // end the header. |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
387 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
388 if (_status!=101 ) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
389 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
390 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
391 _state = STATE_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
392 return; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
393 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
394 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
395 else if (_status==204 || _status==304) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
396 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
397 _noContent=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
398 _content=null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
399 if (_buffer!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
400 _buffer.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
401 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
402 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
403 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
404 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
405 // key field values |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
406 HttpFields.Field content_length = null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
407 HttpFields.Field transfer_encoding = null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
408 boolean keep_alive = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
409 boolean close=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
410 boolean content_type=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
411 StringBuilder connection = null; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
412 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
413 if (fields != null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
414 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
415 int s=fields.size(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
416 for (int f=0;f<s;f++) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
417 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
418 HttpFields.Field field = fields.getField(f); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
419 if (field==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
420 continue; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
421 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
422 switch (field.getNameOrdinal()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
423 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
424 case HttpHeaders.CONTENT_LENGTH_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
425 content_length = field; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
426 _contentLength = field.getLongValue(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
427 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
428 if (_contentLength < _contentWritten || _last && _contentLength != _contentWritten) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
429 content_length = null; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
430 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
431 // write the field to the header buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
432 field.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
433 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
434 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
435 case HttpHeaders.CONTENT_TYPE_ORDINAL: |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
436 // if (BufferUtil.isPrefix(MimeTypes.MULTIPART_BYTERANGES_BUFFER, field.getValueBuffer())) |
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
437 if (field.getValue().startsWith(MimeTypes.MULTIPART_BYTERANGES)) |
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
438 _contentLength = HttpTokens.SELF_DEFINING_CONTENT; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
439 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
440 // write the field to the header buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
441 content_type=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
442 field.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
443 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
444 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
445 case HttpHeaders.TRANSFER_ENCODING_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
446 if (_version == HttpVersions.HTTP_1_1_ORDINAL) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
447 transfer_encoding = field; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
448 // Do NOT add yet! |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
449 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
450 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
451 case HttpHeaders.CONNECTION_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
452 if (isRequest()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
453 field.putTo(_header); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
454 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
455 int connection_value = field.getValueOrdinal(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
456 switch (connection_value) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
457 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
458 case -1: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
459 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
460 String[] values = field.getValue().split(","); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
461 for (int i=0;values!=null && i<values.length;i++) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
462 { |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
463 int ord = HttpHeaderValues.CACHE.getOrdinal(values[i].trim()); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
464 |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
465 if (ord != -1) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
466 { |
1020
6be43ef1eb96
HttpHeaderValues uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1019
diff
changeset
|
467 switch(ord) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
468 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
469 case HttpHeaderValues.CLOSE_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
470 close=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
471 if (isResponse()) |
1034
563458c4dc93
remove HttpGenerator.reset()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1022
diff
changeset
|
472 _persistent = false; |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
473 keep_alive=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
474 if (!_persistent && isResponse() && _contentLength == HttpTokens.UNKNOWN_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
475 _contentLength = HttpTokens.EOF_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
476 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
477 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
478 case HttpHeaderValues.KEEP_ALIVE_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
479 if (_version == HttpVersions.HTTP_1_0_ORDINAL) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
480 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
481 keep_alive = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
482 if (isResponse()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
483 _persistent = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
484 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
485 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
486 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
487 default: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
488 if (connection==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
489 connection=new StringBuilder(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
490 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
491 connection.append(','); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
492 connection.append(values[i]); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
493 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
494 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
495 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
496 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
497 if (connection==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
498 connection=new StringBuilder(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
499 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
500 connection.append(','); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
501 connection.append(values[i]); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
502 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
503 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
504 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
505 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
506 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
507 case HttpHeaderValues.UPGRADE_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
508 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
509 // special case for websocket connection ordering |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
510 if (isResponse()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
511 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
512 field.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
513 continue; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
514 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
515 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
516 case HttpHeaderValues.CLOSE_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
517 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
518 close=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
519 if (isResponse()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
520 _persistent=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
521 if (!_persistent && isResponse() && _contentLength == HttpTokens.UNKNOWN_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
522 _contentLength = HttpTokens.EOF_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
523 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
524 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
525 case HttpHeaderValues.KEEP_ALIVE_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
526 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
527 if (_version == HttpVersions.HTTP_1_0_ORDINAL) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
528 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
529 keep_alive = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
530 if (isResponse()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
531 _persistent=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
532 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
533 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
534 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
535 default: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
536 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
537 if (connection==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
538 connection=new StringBuilder(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
539 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
540 connection.append(','); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
541 connection.append(field.getValue()); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
542 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
543 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
544 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
545 // Do NOT add yet! |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
546 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
547 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
548 case HttpHeaders.SERVER_ORDINAL: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
549 has_server=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
550 field.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
551 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
552 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
553 default: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
554 // write the field to the header buffer |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
555 field.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
556 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
557 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
558 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
559 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
560 // Calculate how to end _content and connection, _content length and transfer encoding |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
561 // settings. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
562 // From RFC 2616 4.4: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
563 // 1. No body for 1xx, 204, 304 & HEAD response |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
564 // 2. Force _content-length? |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
565 // 3. If Transfer-Encoding!=identity && HTTP/1.1 && !HttpConnection==close then chunk |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
566 // 4. Content-Length |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
567 // 5. multipart/byteranges |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
568 // 6. close |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
569 switch ((int) _contentLength) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
570 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
571 case HttpTokens.UNKNOWN_CONTENT: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
572 // It may be that we have no _content, or perhaps _content just has not been |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
573 // written yet? |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
574 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
575 // Response known not to have a body |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
576 if (_contentWritten == 0 && isResponse() && (_status < 200 || _status == 204 || _status == 304)) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
577 _contentLength = HttpTokens.NO_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
578 else if (_last) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
579 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
580 // we have seen all the _content there is |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
581 _contentLength = _contentWritten; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
582 if (content_length == null && (isResponse() || _contentLength>0 || content_type ) && !_noContent) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
583 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
584 // known length but not actually set. |
1022
3718afd99988
HttpHeaders uses StringCache
Franklin Schmidt <fschmidt@gmail.com>
parents:
1021
diff
changeset
|
585 _header.put(HttpHeaders.CONTENT_LENGTH_BYTES); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
586 _header.put(HttpTokens.COLON); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
587 _header.put((byte) ' '); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
588 BufferUtil.putDecLong(_header, _contentLength); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
589 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
590 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
591 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
592 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
593 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
594 // No idea, so we must assume that a body is coming |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
595 _contentLength = (!_persistent || _version < HttpVersions.HTTP_1_1_ORDINAL ) ? HttpTokens.EOF_CONTENT : HttpTokens.CHUNKED_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
596 if (isRequest() && _contentLength==HttpTokens.EOF_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
597 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
598 _contentLength=HttpTokens.NO_CONTENT; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
599 _noContent=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
600 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
601 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
602 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
603 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
604 case HttpTokens.NO_CONTENT: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
605 if (content_length == null && isResponse() && _status >= 200 && _status != 204 && _status != 304) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
606 _header.put(CONTENT_LENGTH_0); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
607 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
608 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
609 case HttpTokens.EOF_CONTENT: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
610 _persistent = isRequest(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
611 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
612 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
613 case HttpTokens.CHUNKED_CONTENT: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
614 break; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
615 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
616 default: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
617 // TODO - maybe allow forced chunking by setting te ??? |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
618 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
619 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
620 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
621 // Add transfer_encoding if needed |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
622 if (_contentLength == HttpTokens.CHUNKED_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
623 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
624 // try to use user supplied encoding as it may have other values. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
625 if (transfer_encoding != null && HttpHeaderValues.CHUNKED_ORDINAL != transfer_encoding.getValueOrdinal()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
626 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
627 String c = transfer_encoding.getValue(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
628 if (c.endsWith(HttpHeaderValues.CHUNKED)) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
629 transfer_encoding.putTo(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
630 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
631 throw new IllegalArgumentException("BAD TE"); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
632 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
633 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
634 _header.put(TRANSFER_ENCODING_CHUNKED); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
635 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
636 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
637 // Handle connection if need be |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
638 if (_contentLength==HttpTokens.EOF_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
639 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
640 keep_alive=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
641 _persistent=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
642 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
643 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
644 if (isResponse()) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
645 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
646 if (!_persistent && (close || _version > HttpVersions.HTTP_1_0_ORDINAL)) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
647 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
648 _header.put(CONNECTION_CLOSE); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
649 if (connection!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
650 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
651 _header.setPutIndex(_header.putIndex()-2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
652 _header.put((byte)','); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
653 _header.put(connection.toString().getBytes()); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
654 _header.put(CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
655 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
656 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
657 else if (keep_alive) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
658 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
659 _header.put(CONNECTION_KEEP_ALIVE); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
660 if (connection!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
661 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
662 _header.setPutIndex(_header.putIndex()-2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
663 _header.put((byte)','); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
664 _header.put(connection.toString().getBytes()); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
665 _header.put(CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
666 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
667 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
668 else if (connection!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
669 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
670 _header.put(CONNECTION_); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
671 _header.put(connection.toString().getBytes()); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
672 _header.put(CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
673 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
674 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
675 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
676 if (!has_server && _status>199) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
677 _header.put(SERVER); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
678 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
679 // end the header. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
680 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
681 _state = STATE_CONTENT; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
682 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
683 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
684 catch(ArrayIndexOutOfBoundsException e) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
685 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
686 throw new RuntimeException("Header>"+_header.capacity(),e); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
687 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
688 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
689 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
690 /* ------------------------------------------------------------ */ |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
691 /** |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
692 * Complete the message. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
693 * |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
694 * @throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
695 */ |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
696 public void complete() throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
697 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
698 if (_state == STATE_END) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
699 return; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
700 |
1057
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
701 complete2(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
702 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
703 if (_state < STATE_FLUSHING) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
704 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
705 _state = STATE_FLUSHING; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
706 if (_contentLength == HttpTokens.CHUNKED_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
707 _needEOC = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
708 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
709 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
710 flushBuffer(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
711 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
712 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
713 public int flushBuffer() throws IOException |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
714 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
715 try |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
716 { |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
717 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
718 if (_state == STATE_HEADER) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
719 throw new IllegalStateException("State==HEADER"); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
720 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
721 prepareBuffers(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
722 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
723 if (_endp == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
724 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
725 if (_needCRLF && _buffer!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
726 _buffer.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
727 if (_needEOC && _buffer!=null && !_head) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
728 _buffer.put(LAST_CHUNK); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
729 _needCRLF=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
730 _needEOC=false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
731 return 0; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
732 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
733 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
734 int total= 0; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
735 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
736 int len = -1; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
737 int to_flush = flushMask(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
738 int last_flush; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
739 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
740 do |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
741 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
742 last_flush=to_flush; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
743 switch (to_flush) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
744 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
745 case 7: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
746 throw new IllegalStateException(); // should never happen! |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
747 case 6: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
748 len = _endp.flush(_header, _buffer, null); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
749 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
750 case 5: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
751 len = _endp.flush(_header, _content, null); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
752 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
753 case 4: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
754 len = _endp.flush(_header); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
755 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
756 case 3: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
757 len = _endp.flush(_buffer, _content, null); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
758 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
759 case 2: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
760 len = _endp.flush(_buffer); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
761 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
762 case 1: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
763 len = _endp.flush(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
764 break; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
765 case 0: |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
766 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
767 len=0; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
768 // Nothing more we can write now. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
769 if (_header != null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
770 _header.clear(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
771 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
772 _bypass = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
773 _bufferChunked = false; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
774 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
775 if (_buffer != null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
776 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
777 _buffer.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
778 if (_contentLength == HttpTokens.CHUNKED_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
779 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
780 // reserve some space for the chunk header |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
781 _buffer.setPutIndex(CHUNK_SPACE); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
782 _buffer.setGetIndex(CHUNK_SPACE); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
783 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
784 // Special case handling for small left over buffer from |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
785 // an addContent that caused a buffer flush. |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
786 if (_content != null && _content.remaining() < _buffer.space() && _state != STATE_FLUSHING) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
787 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
788 _buffer.put(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
789 _content.clear(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
790 _content=null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
791 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
792 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
793 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
794 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
795 // Are we completely finished for now? |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
796 if (!_needCRLF && !_needEOC && (_content==null || _content.remaining()==0)) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
797 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
798 if (_state == STATE_FLUSHING) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
799 _state = STATE_END; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
800 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
801 if (_state==STATE_END && _persistent != null && !_persistent && _status!=100 && _method==null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
802 _endp.shutdownOutput(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
803 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
804 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
805 // Try to prepare more to write. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
806 prepareBuffers(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
807 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
808 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
809 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
810 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
811 if (len > 0) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
812 total+=len; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
813 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
814 to_flush = flushMask(); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
815 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
816 // loop while progress is being made (OR we have prepared some buffers that might make progress) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
817 while (len>0 || (to_flush!=0 && last_flush==0)); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
818 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
819 return total; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
820 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
821 catch (IOException e) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
822 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
823 LOG.trace("",e); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
824 throw (e instanceof EofException) ? e:new EofException(e); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
825 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
826 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
827 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
828 private int flushMask() |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
829 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
830 return ((_header != null && _header.remaining() > 0)?4:0) |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
831 | ((_buffer != null && _buffer.remaining() > 0)?2:0) |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
832 | ((_bypass && _content != null && _content.remaining() > 0)?1:0); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
833 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
834 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
835 private void prepareBuffers() |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
836 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
837 // if we are not flushing an existing chunk |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
838 if (!_bufferChunked) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
839 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
840 // Refill buffer if possible |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
841 if (!_bypass && _content != null && _content.remaining() > 0 && _buffer != null && _buffer.space() > 0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
842 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
843 int len = _buffer.put(_content); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
844 _content.skip(len); |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
845 if (_content.remaining() == 0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
846 _content = null; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
847 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
848 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
849 // Chunk buffer if need be |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
850 if (_contentLength == HttpTokens.CHUNKED_CONTENT) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
851 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
852 if (_bypass && (_buffer==null||_buffer.remaining()==0) && _content!=null) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
853 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
854 // this is a bypass write |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
855 int size = _content.remaining(); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
856 _bufferChunked = true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
857 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
858 if (_header == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
859 _header = _buffers.getHeader(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
860 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
861 // if we need CRLF add this to header |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
862 if (_needCRLF) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
863 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
864 if (_header.remaining() > 0) throw new IllegalStateException("EOC"); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
865 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
866 _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
867 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
868 // Add the chunk size to the header |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
869 BufferUtil.putHexInt(_header, size); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
870 _header.put(HttpTokens.CRLF); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
871 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
872 // Need a CRLF after the content |
983
23ec25435b8c
simplify AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
982
diff
changeset
|
873 _needCRLF = true; |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
874 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
875 else if (_buffer!=null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
876 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
877 int size = _buffer.remaining(); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
878 if (size > 0) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
879 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
880 // Prepare a chunk! |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
881 _bufferChunked = true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
882 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
883 // Did we leave space at the start of the buffer. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
884 //noinspection ConstantConditions |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
885 if (_buffer.getIndex() == CHUNK_SPACE) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
886 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
887 // Oh yes, goodie! let's use it then! |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
888 _buffer.poke(_buffer.getIndex() - 2, HttpTokens.CRLF, 0, 2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
889 _buffer.setGetIndex(_buffer.getIndex() - 2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
890 BufferUtil.prependHexInt(_buffer, size); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
891 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
892 if (_needCRLF) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
893 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
894 _buffer.poke(_buffer.getIndex() - 2, HttpTokens.CRLF, 0, 2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
895 _buffer.setGetIndex(_buffer.getIndex() - 2); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
896 _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
897 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
898 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
899 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
900 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
901 // No space so lets use a header buffer. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
902 if (_header == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
903 _header = _buffers.getHeader(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
904 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
905 if (_needCRLF) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
906 { |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
907 if (_header.remaining() > 0) throw new IllegalStateException("EOC"); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
908 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
909 _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
910 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
911 BufferUtil.putHexInt(_header, size); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
912 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
913 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
914 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
915 // Add end chunk trailer. |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
916 if (_buffer.space() >= 2) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
917 _buffer.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
918 else |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
919 _needCRLF = true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
920 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
921 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
922 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
923 // If we need EOC and everything written |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
924 if (_needEOC && (_content == null || _content.remaining() == 0)) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
925 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
926 if (_header == null && _buffer == null) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
927 _header = _buffers.getHeader(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
928 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
929 if (_needCRLF) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
930 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
931 if (_buffer == null && _header != null && _header.space() >= HttpTokens.CRLF.length) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
932 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
933 _header.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
934 _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
935 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
936 else if (_buffer!=null && _buffer.space() >= HttpTokens.CRLF.length) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
937 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
938 _buffer.put(HttpTokens.CRLF); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
939 _needCRLF = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
940 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
941 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
942 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
943 if (!_needCRLF && _needEOC) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
944 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
945 if (_buffer == null && _header != null && _header.space() >= LAST_CHUNK.length) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
946 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
947 if (!_head) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
948 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
949 _header.put(LAST_CHUNK); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
950 _bufferChunked=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
951 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
952 _needEOC = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
953 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
954 else if (_buffer!=null && _buffer.space() >= LAST_CHUNK.length) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
955 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
956 if (!_head) |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
957 { |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
958 _buffer.put(LAST_CHUNK); |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
959 _bufferChunked=true; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
960 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
961 _needEOC = false; |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
962 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
963 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
964 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
965 } |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
966 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
967 |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
968 if (_content != null && _content.remaining() == 0) |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
969 _content = null; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
970 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
971 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
972 |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
973 @Override |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
974 public String toString() |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
975 { |
1048 | 976 JBuffer header=_header; |
977 JBuffer buffer=_buffer; | |
978 JBuffer content=_content; | |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
979 return String.format("%s{s=%d,h=%d,b=%d,c=%d}", |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
980 getClass().getSimpleName(), |
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
981 _state, |
1038
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
982 header == null ? -1 : header.remaining(), |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
983 buffer == null ? -1 : buffer.remaining(), |
b71ad168fe34
rename Buffer.length() to remaining()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1036
diff
changeset
|
984 content == null ? -1 : content.remaining()); |
877
fef4392f4905
remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
985 } |
1057
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
986 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
987 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
988 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
989 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
990 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
991 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
992 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
993 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
994 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
995 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
996 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
997 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
998 // AbstractGenerator |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
999 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1000 public static final boolean LAST=true; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1001 public static final boolean MORE=false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1002 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1003 // states |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1004 private final static int STATE_HEADER = 0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1005 private final static int STATE_CONTENT = 2; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1006 private final static int STATE_FLUSHING = 3; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1007 private final static int STATE_END = 4; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1008 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1009 // data |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1010 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1011 private final Buffers _buffers; // source of buffers |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1012 private final EndPoint _endp; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1013 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1014 private int _state = STATE_HEADER; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1015 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1016 private int _status = 0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1017 private int _version = HttpVersions.HTTP_1_1_ORDINAL; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1018 private JBuffer _reason; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1019 private JBuffer _method; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1020 private String _uri; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1021 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1022 private long _contentWritten = 0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1023 private long _contentLength = HttpTokens.UNKNOWN_CONTENT; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1024 private boolean _last = false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1025 private boolean _head = false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1026 private boolean _noContent = false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1027 private Boolean _persistent = null; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1028 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1029 private JBuffer _header; // JBuffer for HTTP header (and maybe small _content) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1030 private JBuffer _buffer; // JBuffer for copy of passed _content |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1031 private JBuffer _content; // JBuffer passed to addContent |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1032 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1033 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1034 public HttpGenerator(Buffers buffers, EndPoint io) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1035 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1036 this._buffers = buffers; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1037 this._endp = io; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1038 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1039 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1040 public final boolean isOpen() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1041 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1042 return _endp.isOpen(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1043 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1044 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1045 public final void resetBuffer() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1046 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1047 if(_state>=STATE_FLUSHING) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1048 throw new IllegalStateException("Flushed"); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1049 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1050 _last = false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1051 _persistent = null; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1052 _contentWritten = 0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1053 _contentLength = HttpTokens.UNKNOWN_CONTENT; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1054 _content=null; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1055 if (_buffer!=null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1056 _buffer.clear(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1057 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1058 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1059 /* ------------------------------------------------------------ */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1060 /** |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1061 * @return Returns the contentBufferSize. |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1062 */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1063 public final int getContentBufferSize() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1064 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1065 if (_buffer==null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1066 _buffer = _buffers.getBuffer(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1067 return _buffer.capacity(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1068 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1069 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1070 public final JBuffer getUncheckedBuffer() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1071 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1072 return _buffer; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1073 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1074 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1075 public final boolean isComplete() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1076 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1077 return _state == STATE_END; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1078 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1079 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1080 public final boolean isIdle() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1081 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1082 return _state == STATE_HEADER && _method==null && _status==0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1083 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1084 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1085 public final boolean isCommitted() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1086 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1087 return _state != STATE_HEADER; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1088 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1089 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1090 public final void setContentLength(long value) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1091 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1092 if (value<0) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1093 _contentLength=HttpTokens.UNKNOWN_CONTENT; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1094 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1095 _contentLength=value; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1096 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1097 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1098 public final void setHead(boolean head) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1099 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1100 _head = head; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1101 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1102 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1103 /* ------------------------------------------------------------ */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1104 /** |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1105 * @return <code>false</code> if the connection should be closed after a request has been read, |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1106 * <code>true</code> if it should be used for additional requests. |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1107 */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1108 public final boolean isPersistent() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1109 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1110 return _persistent!=null |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1111 ?_persistent.booleanValue() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1112 :(isRequest()?true:_version>HttpVersions.HTTP_1_0_ORDINAL); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1113 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1114 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1115 public final void setPersistent(boolean persistent) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1116 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1117 _persistent = persistent; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1118 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1119 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1120 /* ------------------------------------------------------------ */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1121 /** |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1122 * @param version The version of the client the response is being sent to (NB. Not the version |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1123 * in the response, which is the version of the server). |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1124 */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1125 public final void setVersion(int version) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1126 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1127 if (_state != STATE_HEADER) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1128 throw new IllegalStateException("STATE!=START "+_state); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1129 _version = version; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1130 if (_version==HttpVersions.HTTP_0_9_ORDINAL && _method!=null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1131 _noContent=true; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1132 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1133 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1134 /* ------------------------------------------------------------ */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1135 /** |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1136 * @param status The status code to send. |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1137 * @param reason the status message to send. |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1138 */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1139 public final void setResponse(int status, String reason) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1140 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1141 if (_state != STATE_HEADER) throw new IllegalStateException("STATE!=START"); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1142 _method=null; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1143 _status = status; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1144 if (reason!=null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1145 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1146 int len=reason.length(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1147 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1148 // TODO don't hard code |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1149 if (len>1024) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1150 len=1024; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1151 _reason = BufferUtil.newBuffer(len); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1152 for (int i=0;i<len;i++) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1153 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1154 char ch = reason.charAt(i); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1155 if (ch!='\r'&&ch!='\n') |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1156 _reason.put((byte)ch); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1157 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1158 _reason.put((byte)' '); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1159 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1160 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1161 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1162 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1163 public final void completeUncheckedAddContent() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1164 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1165 if (_noContent) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1166 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1167 if(_buffer!=null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1168 _buffer.clear(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1169 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1170 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1171 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1172 _contentWritten+=_buffer.remaining(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1173 if (_head) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1174 _buffer.clear(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1175 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1176 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1177 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1178 private boolean isBufferFull2() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1179 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1180 if (_buffer != null && _buffer.space()==0) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1181 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1182 if (_buffer.remaining()==0) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1183 _buffer.compact(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1184 return _buffer.space()==0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1185 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1186 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1187 return _content!=null && _content.remaining()>0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1188 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1189 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1190 public final boolean isWritten() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1191 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1192 return _contentWritten>0; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1193 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1194 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1195 public final boolean isAllContentWritten() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1196 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1197 return _contentLength>=0 && _contentWritten>=_contentLength; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1198 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1199 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1200 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1201 private void complete2() throws IOException |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1202 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1203 if (_state == STATE_HEADER) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1204 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1205 throw new IllegalStateException("State==HEADER"); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1206 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1207 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1208 if (_contentLength >= 0 && _contentLength != _contentWritten && !_head) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1209 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1210 if (LOG.isDebugEnabled()) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1211 LOG.debug("ContentLength written=="+_contentWritten+" != contentLength=="+_contentLength); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1212 _persistent = false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1213 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1214 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1215 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1216 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1217 public final void flush(long maxIdleTime) throws IOException |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1218 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1219 // block until everything is flushed |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1220 long now=System.currentTimeMillis(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1221 long end=now+maxIdleTime; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1222 JBuffer content = _content; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1223 JBuffer buffer = _buffer; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1224 if (content!=null && content.remaining()>0 || buffer!=null && buffer.remaining()>0 || isBufferFull()) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1225 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1226 flushBuffer(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1227 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1228 while (now<end && (content!=null && content.remaining()>0 ||buffer!=null && buffer.remaining()>0) && _endp.isOpen()&& !_endp.isOutputShutdown()) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1229 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1230 blockForOutput(end-now); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1231 now=System.currentTimeMillis(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1232 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1233 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1234 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1235 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1236 /* ------------------------------------------------------------ */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1237 /** |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1238 * Utility method to send an error response. If the builder is not committed, this call is |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1239 * equivalent to a setResponse, addContent and complete call. |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1240 * |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1241 * @param code The error code |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1242 * @param reason The error reason |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1243 * @param content Contents of the error page |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1244 * @param close True if the connection should be closed |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1245 * @throws IOException if there is a problem flushing the response |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1246 */ |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1247 public final void sendError(int code, String reason, String content, boolean close) throws IOException |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1248 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1249 if (close) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1250 _persistent=false; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1251 if (isCommitted()) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1252 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1253 LOG.debug("sendError on committed: {} {}",code,reason); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1254 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1255 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1256 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1257 LOG.debug("sendError: {} {}",code,reason); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1258 setResponse(code, reason); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1259 if (content != null) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1260 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1261 completeHeader(null, false); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1262 addContent(BufferUtil.wrap(content), LAST); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1263 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1264 else if (code>=400) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1265 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1266 completeHeader(null, false); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1267 addContent(BufferUtil.wrap("Error: "+(reason==null?(""+code):reason)), LAST); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1268 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1269 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1270 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1271 completeHeader(null, true); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1272 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1273 complete(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1274 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1275 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1276 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1277 public final long getContentWritten() |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1278 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1279 return _contentWritten; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1280 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1281 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1282 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1283 public final void blockForOutput(long maxIdleTime) throws IOException |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1284 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1285 if (_endp.isBlocking()) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1286 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1287 try |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1288 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1289 flushBuffer(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1290 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1291 catch(IOException e) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1292 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1293 _endp.close(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1294 throw e; |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1295 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1296 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1297 else |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1298 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1299 if (!_endp.blockWritable(maxIdleTime)) |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1300 { |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1301 _endp.close(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1302 throw new EofException("timeout"); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1303 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1304 |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1305 flushBuffer(); |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1306 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1307 } |
afc9610dc12e
remove AbstractGenerator
Franklin Schmidt <fschmidt@gmail.com>
parents:
1048
diff
changeset
|
1308 |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1309 } |