annotate src/org/eclipse/jetty/http/AbstractGenerator.java @ 889:5731a7707466

remove _forwarded
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 06 Oct 2016 23:24:30 -0600
parents fef4392f4905
children dbecd7faa1f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import org.eclipse.jetty.io.Buffer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import org.eclipse.jetty.io.Buffers;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import org.eclipse.jetty.io.ByteArrayBuffer;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import org.eclipse.jetty.io.EofException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import org.eclipse.jetty.io.View;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
29 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
30 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 * Abstract Generator. Builds HTTP Messages.
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 * Currently this class uses a system parameter "jetty.direct.writers" to control
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 * two optional writer to byte conversions. buffer.writers=true will probably be
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 * faster, but will consume more memory. This option is just for testing and tuning.
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 public abstract class AbstractGenerator implements Generator
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 {
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
43 private static final Logger LOG = LoggerFactory.getLogger(AbstractGenerator.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
45 // states
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
46 public final static int STATE_HEADER = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
47 public final static int STATE_CONTENT = 2;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
48 public final static int STATE_FLUSHING = 3;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
49 public final static int STATE_END = 4;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
51 public static final byte[] NO_BYTES = {};
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
53 // data
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
55 protected final Buffers _buffers; // source of buffers
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
56 protected final EndPoint _endp;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
58 protected int _state = STATE_HEADER;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
60 protected int _status = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
61 protected int _version = HttpVersions.HTTP_1_1_ORDINAL;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 protected Buffer _reason;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
63 protected Buffer _method;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
64 protected String _uri;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
65
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 protected long _contentWritten = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 protected long _contentLength = HttpTokens.UNKNOWN_CONTENT;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68 protected boolean _last = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 protected boolean _head = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 protected boolean _noContent = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
71 protected Boolean _persistent = null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
72
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 protected Buffer _header; // Buffer for HTTP header (and maybe small _content)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 protected Buffer _buffer; // Buffer for copy of passed _content
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75 protected Buffer _content; // Buffer passed to addContent
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
76
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 protected Buffer _date;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
79
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
80 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
81 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 * Constructor.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
83 *
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 * @param buffers buffer pool
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
85 * @param io the end point
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 public AbstractGenerator(Buffers buffers, EndPoint io)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
89 this._buffers = buffers;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 this._endp = io;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
92
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 public abstract boolean isRequest();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
95
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 public abstract boolean isResponse();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
98
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 public boolean isOpen()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
101 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 return _endp.isOpen();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
104
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
105 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 public void reset()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
108 _state = STATE_HEADER;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
109 _status = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 _version = HttpVersions.HTTP_1_1_ORDINAL;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
111 _reason = null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 _last = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
113 _head = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
114 _noContent=false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
115 _persistent = null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
116 _contentWritten = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
117 _contentLength = HttpTokens.UNKNOWN_CONTENT;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
118 _date = null;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
119
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 _content = null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
121 _method=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
123
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 public void returnBuffers()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 if (_buffer!=null && _buffer.length()==0)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 _buffers.returnBuffer(_buffer);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
130 _buffer=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
132
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 if (_header!=null && _header.length()==0)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
134 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
135 _buffers.returnBuffer(_header);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
136 _header=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
137 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
138 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
139
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 /* ------------------------------------------------------------------------------- */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 public void resetBuffer()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
142 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
143 if(_state>=STATE_FLUSHING)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
144 throw new IllegalStateException("Flushed");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
145
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
146 _last = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
147 _persistent=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
148 _contentWritten = 0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
149 _contentLength = HttpTokens.UNKNOWN_CONTENT;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
150 _content=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
151 if (_buffer!=null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
152 _buffer.clear();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
153 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
154
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
156 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
157 * @return Returns the contentBufferSize.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
159 public int getContentBufferSize()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
161 if (_buffer==null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
162 _buffer=_buffers.getBuffer();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
163 return _buffer.capacity();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
164 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
165
877
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 * @param contentBufferSize The contentBufferSize to set.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 public void increaseContentBufferSize(int contentBufferSize)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
171 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 if (_buffer==null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
173 _buffer=_buffers.getBuffer();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 if (contentBufferSize > _buffer.capacity())
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 Buffer nb = _buffers.getBuffer(contentBufferSize);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
177 nb.put(_buffer);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
178 _buffers.returnBuffer(_buffer);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
179 _buffer = nb;
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
182
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
183 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 public Buffer getUncheckedBuffer()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
185 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
186 return _buffer;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
187 }
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 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190 public int getState()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
191 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 return _state;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
193 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
194
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
195 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 public boolean isState(int state)
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 return _state == state;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
199 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
200
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 public boolean isComplete()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 return _state == STATE_END;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
206
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
207 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 public boolean isIdle()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
209 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
210 return _state == STATE_HEADER && _method==null && _status==0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
211 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
212
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
213 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
214 public boolean isCommitted()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 return _state != STATE_HEADER;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
218
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
221 * @return Returns the head.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
222 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
223 public boolean isHead()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 return _head;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
227
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 public void setContentLength(long value)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 if (value<0)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
232 _contentLength=HttpTokens.UNKNOWN_CONTENT;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 else
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 _contentLength=value;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
235 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
236
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
237 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 * @param head The head to set.
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 public void setHead(boolean head)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 _head = head;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
245
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 * @return <code>false</code> if the connection should be closed after a request has been read,
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 * <code>true</code> if it should be used for additional requests.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
250 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
251 public boolean isPersistent()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
252 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
253 return _persistent!=null
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
254 ?_persistent.booleanValue()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
255 :(isRequest()?true:_version>HttpVersions.HTTP_1_0_ORDINAL);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
256 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
257
877
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 public void setPersistent(boolean persistent)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
260 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
261 _persistent=persistent;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
262 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
263
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
264 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
265 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
266 * @param version The version of the client the response is being sent to (NB. Not the version
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
267 * in the response, which is the version of the server).
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 public void setVersion(int version)
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 if (_state != STATE_HEADER)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
272 throw new IllegalStateException("STATE!=START "+_state);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
273 _version = version;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
274 if (_version==HttpVersions.HTTP_0_9_ORDINAL && _method!=null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
275 _noContent=true;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
276 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
277
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
278 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
279 public int getVersion()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
280 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
281 return _version;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
282 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
283
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
284 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
285 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
286 * @see org.eclipse.jetty.http.Generator#setDate(org.eclipse.jetty.io.Buffer)
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 public void setDate(Buffer timeStampBuffer)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
289 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
290 _date=timeStampBuffer;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
291 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
292
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
293 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
294 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
295 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
296 public void setRequest(String method, String uri)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
297 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
298 if (method==null || HttpMethods.GET.equals(method) )
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
299 _method=HttpMethods.GET_BUFFER;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
300 else
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
301 _method=HttpMethods.CACHE.lookup(method);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
302 _uri=uri;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
303 if (_version==HttpVersions.HTTP_0_9_ORDINAL)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
304 _noContent=true;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
305 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
306
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
307 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
308 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
309 * @param status The status code to send.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
310 * @param reason the status message to send.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
311 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
312 public void setResponse(int status, String reason)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
313 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
314 if (_state != STATE_HEADER) throw new IllegalStateException("STATE!=START");
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
315 _method=null;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
316 _status = status;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
317 if (reason!=null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
318 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
319 int len=reason.length();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
320
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
321 // TODO don't hard code
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
322 if (len>1024)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
323 len=1024;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
324 _reason=new ByteArrayBuffer(len);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
325 for (int i=0;i<len;i++)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
326 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
327 char ch = reason.charAt(i);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
328 if (ch!='\r'&&ch!='\n')
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
329 _reason.put((byte)ch);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
330 else
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
331 _reason.put((byte)' ');
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
332 }
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
335
877
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 /** Prepare buffer for unchecked writes.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
338 * Prepare the generator buffer to receive unchecked writes
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
339 * @return the available space in the buffer.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
340 * @throws IOException
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 public abstract int prepareUncheckedAddContent() throws IOException;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
343
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
344 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
345 void uncheckedAddContent(int b)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
346 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
347 _buffer.put((byte)b);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
348 }
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 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
351 public void completeUncheckedAddContent()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
352 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
353 if (_noContent)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
354 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
355 if(_buffer!=null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
356 _buffer.clear();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
357 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
358 else
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 _contentWritten+=_buffer.length();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
361 if (_head)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
362 _buffer.clear();
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
365
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
366 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
367 public boolean isBufferFull()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
368 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
369 if (_buffer != null && _buffer.space()==0)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
370 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
371 if (_buffer.length()==0 && !_buffer.isImmutable())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
372 _buffer.compact();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
373 return _buffer.space()==0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
374 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
375
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
376 return _content!=null && _content.length()>0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
377 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
378
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
379 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
380 public boolean isWritten()
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 return _contentWritten>0;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
383 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
384
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
385 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
386 public boolean isAllContentWritten()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
387 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
388 return _contentLength>=0 && _contentWritten>=_contentLength;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
389 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
390
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
391 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
392 public abstract void completeHeader(HttpFields fields, boolean allContentAdded) throws IOException;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
393
877
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 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
396 * Complete the message.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
397 *
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
398 * @throws IOException
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
399 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
400 public void complete() throws IOException
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 if (_state == STATE_HEADER)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
403 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
404 throw new IllegalStateException("State==HEADER");
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
405 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
406
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
407 if (_contentLength >= 0 && _contentLength != _contentWritten && !_head)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
408 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
409 if (LOG.isDebugEnabled())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
410 LOG.debug("ContentLength written=="+_contentWritten+" != contentLength=="+_contentLength);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
411 _persistent = false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
412 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
413 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
414
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
415 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
416 public abstract int flushBuffer() throws IOException;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
417
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
418
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
419 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
420 public void flush(long maxIdleTime) throws IOException
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
421 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
422 // block until everything is flushed
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
423 long now=System.currentTimeMillis();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
424 long end=now+maxIdleTime;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
425 Buffer content = _content;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
426 Buffer buffer = _buffer;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
427 if (content!=null && content.length()>0 || buffer!=null && buffer.length()>0 || isBufferFull())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
428 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
429 flushBuffer();
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 while (now<end && (content!=null && content.length()>0 ||buffer!=null && buffer.length()>0) && _endp.isOpen()&& !_endp.isOutputShutdown())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
432 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
433 blockForOutput(end-now);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
434 now=System.currentTimeMillis();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
435 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
436 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
437 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
438
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
439 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
440 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
441 * Utility method to send an error response. If the builder is not committed, this call is
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
442 * equivalent to a setResponse, addContent and complete call.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
443 *
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
444 * @param code The error code
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
445 * @param reason The error reason
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
446 * @param content Contents of the error page
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
447 * @param close True if the connection should be closed
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
448 * @throws IOException if there is a problem flushing the response
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
449 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
450 public void sendError(int code, String reason, String content, boolean close) throws IOException
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
451 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
452 if (close)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
453 _persistent=false;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
454 if (isCommitted())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
455 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
456 LOG.debug("sendError on committed: {} {}",code,reason);
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 else
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 LOG.debug("sendError: {} {}",code,reason);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
461 setResponse(code, reason);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
462 if (content != null)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
463 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
464 completeHeader(null, false);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
465 addContent(new View(new ByteArrayBuffer(content)), Generator.LAST);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
466 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
467 else if (code>=400)
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 completeHeader(null, false);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
470 addContent(new View(new ByteArrayBuffer("Error: "+(reason==null?(""+code):reason))), Generator.LAST);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
471 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
472 else
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
473 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
474 completeHeader(null, true);
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
475 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
476 complete();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
477 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
478 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
479
877
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 /**
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
482 * @return Returns the contentWritten.
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
483 */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
484 public long getContentWritten()
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
485 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
486 return _contentWritten;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
487 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
488
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
489
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
490
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
491 /* ------------------------------------------------------------ */
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
492 public void blockForOutput(long maxIdleTime) throws IOException
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 if (_endp.isBlocking())
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
495 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
496 try
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
497 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
498 flushBuffer();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
499 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
500 catch(IOException e)
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
501 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
502 _endp.close();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
503 throw e;
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
504 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
505 }
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
506 else
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
507 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
508 if (!_endp.blockWritable(maxIdleTime))
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
509 {
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
510 _endp.close();
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
511 throw new EofException("timeout");
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
512 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
513
877
fef4392f4905 remove sendServerVersion
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
514 flushBuffer();
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 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
517
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
518 }