annotate src/org/eclipse/jetty/server/Connector.java @ 885:150092cebf3e

remove AbstractConnector
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Oct 2016 20:11:48 -0600
parents 6b210bb66c63
children df84a1741687
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.server;
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;
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
22 import java.net.InetAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
23 import java.net.Socket;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
24 import java.net.UnknownHostException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
25 import java.util.concurrent.ThreadPoolExecutor;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
26 import java.util.concurrent.atomic.AtomicLong;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
28 import javax.servlet.ServletRequest;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
30 import org.eclipse.jetty.http.HttpBuffers;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
31 import org.eclipse.jetty.http.HttpBuffersImpl;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
32 import org.eclipse.jetty.http.HttpFields;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
33 import org.eclipse.jetty.http.HttpHeaders;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
34 import org.eclipse.jetty.http.HttpSchemes;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
35 import org.eclipse.jetty.io.Buffers;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
36 import org.eclipse.jetty.io.Buffers.Type;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
37 import org.eclipse.jetty.io.Connection;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
38 import org.eclipse.jetty.io.EndPoint;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
39 import org.eclipse.jetty.io.EofException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
40 import org.eclipse.jetty.util.component.AggregateLifeCycle;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
41 import org.eclipse.jetty.util.component.Dumpable;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
42 import org.slf4j.Logger;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
43 import org.slf4j.LoggerFactory;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
44
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
46 * Abstract Connector implementation. This abstract implementation of the Connector interface provides:
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
47 * <ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
48 * <li>AbstractLifeCycle implementation</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
49 * <li>Implementations for connector getters and setters</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
50 * <li>Buffer management</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
51 * <li>Socket configuration</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
52 * <li>Base acceptor thread</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
53 * <li>Optional reverse proxy headers checking</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
54 * </ul>
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
56 public abstract class Connector extends AggregateLifeCycle implements HttpBuffers, Dumpable
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
57 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
58 private static final Logger LOG = LoggerFactory.getLogger(Connector.class);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
59
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
60 private String _name;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
62 private Server _server;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
63 private String _host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
64 private int _port = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
65 private String _integralScheme = HttpSchemes.HTTPS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
66 private int _integralPort = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
67 private String _confidentialScheme = HttpSchemes.HTTPS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
68 private int _confidentialPort = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
69 private int _acceptQueueSize = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
70 private int _acceptors = 1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
71 private int _acceptorPriorityOffset = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
72 private boolean _useDNS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
73 private boolean _forwarded;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
74 private String _hostHeader;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
75
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
76 private String _forwardedHostHeader = HttpHeaders.X_FORWARDED_HOST;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
77 private String _forwardedServerHeader = HttpHeaders.X_FORWARDED_SERVER;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
78 private String _forwardedForHeader = HttpHeaders.X_FORWARDED_FOR;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
79 private String _forwardedProtoHeader = HttpHeaders.X_FORWARDED_PROTO;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
80 private String _forwardedCipherSuiteHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
81 private String _forwardedSslSessionIdHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
82 private boolean _reuseAddress = true;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
83
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
84 protected int _maxIdleTime = 200000;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
85 protected int _lowResourceMaxIdleTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
86 protected int _soLingerTime = -1;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
87
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
88 private transient Thread[] _acceptorThreads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
89
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
90 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
91
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 /**
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
95 public Connector()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
96 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
97 addBean(_buffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
98 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
99
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
100 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
101 /*
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
103 public Server getServer()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
104 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
105 return _server;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
106 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
107
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
108 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
109 public void setServer(Server server)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
110 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
111 _server = server;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
112 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
113
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
114 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
115 public ThreadPoolExecutor getThreadPool()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
116 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
117 return _server.threadPool;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
118 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
119
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 /**
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
123 public void setHost(String host)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
124 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
125 _host = host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
126 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
127
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
128 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
129 /*
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
131 public String getHost()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
132 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
133 return _host;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
134 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
135
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
136 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
137 public void setPort(int port)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
138 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
139 _port = port;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
140 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
141
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
142 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
143 public int getPort()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
144 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
145 return _port;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
146 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
147
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
150 * @return Returns the maxIdleTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
151 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
152 public int getMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
153 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
154 return _maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
155 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
156
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
157 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
158 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
159 * Set the maximum Idle time for a connection, which roughly translates to the {@link Socket#setSoTimeout(int)} call, although with NIO implementations
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
160 * other mechanisms may be used to implement the timeout. The max idle time is applied:
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
161 * <ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
162 * <li>When waiting for a new request to be received on a connection</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
163 * <li>When reading the headers and content of a request</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
164 * <li>When writing the headers and content of a response</li>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
165 * </ul>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
166 * Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
167 * timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
168 * enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
169 * take many 10s of seconds for large content written to a slow device.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
170 * <p>
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
171 * Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
172 * these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
173 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
174 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
175 * The maxIdleTime to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
176 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
177 public void setMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
178 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
179 _maxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
180 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
181
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
182 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
183 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
184 * @return Returns the maxIdleTime when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
185 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
186 public int getLowResourcesMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
187 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
188 return _lowResourceMaxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
189 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
190
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
192 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
193 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
194 * The maxIdleTime to set when resources are low.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
195 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
196 public void setLowResourcesMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
197 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
198 _lowResourceMaxIdleTime = maxIdleTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
199 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
200
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
201 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
202 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
203 * @return Returns the maxIdleTime when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
204 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
205 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
206 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
207 public final int getLowResourceMaxIdleTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
208 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
209 return getLowResourcesMaxIdleTime();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
210 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
211
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
212 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
213 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
214 * @param maxIdleTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
215 * The maxIdleTime to set when resources are low.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
216 * @deprecated
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
217 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
218 @Deprecated
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
219 public final void setLowResourceMaxIdleTime(int maxIdleTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
220 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
221 setLowResourcesMaxIdleTime(maxIdleTime);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
222 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
224 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
225 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
226 * @return Returns the soLingerTime.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
227 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
228 public int getSoLingerTime()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
229 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
230 return _soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
231 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
232
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
233 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
234 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
235 * @return Returns the acceptQueueSize.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
236 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
237 public int getAcceptQueueSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
238 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
239 return _acceptQueueSize;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
240 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
241
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
242 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
243 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
244 * @param acceptQueueSize
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
245 * The acceptQueueSize to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
246 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
247 public void setAcceptQueueSize(int acceptQueueSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
248 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
249 _acceptQueueSize = acceptQueueSize;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
250 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
251
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
252 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
253 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
254 * @return Returns the number of acceptor threads.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
255 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
256 public int getAcceptors()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
257 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
258 return _acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
259 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
260
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
261 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
262 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
263 * @param acceptors
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
264 * The number of acceptor threads to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
265 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
266 public void setAcceptors(int acceptors)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
267 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
268 if (acceptors > 2 * Runtime.getRuntime().availableProcessors())
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
269 LOG.warn("Acceptors should be <=2*availableProcessors: " + this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
270 _acceptors = acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
271 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
272
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
273 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
274 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
275 * @param soLingerTime
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
276 * The soLingerTime to set or -1 to disable.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
277 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
278 public void setSoLingerTime(int soLingerTime)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
279 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
280 _soLingerTime = soLingerTime;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
281 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
282
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
283 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
284 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
285 protected void doStart() throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
286 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
287 if (_server == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
288 throw new IllegalStateException("No server");
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
289
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
290 // open listener port
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
291 open();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
292
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
293 super.doStart();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
294
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
295 // Start selector thread
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
296 synchronized (this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
297 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
298 _acceptorThreads = new Thread[getAcceptors()];
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
299
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
300 ThreadPoolExecutor _threadPool = getThreadPool();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
301 for (int i = 0; i < _acceptorThreads.length; i++)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
302 _threadPool.execute(new Acceptor(i));
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
303 if (_server.isLowOnThreads())
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
304 LOG.warn("insufficient threads configured for {}",this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
305 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
306
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
307 LOG.info("Started {}",this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
308 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
309
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
310 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
311 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
312 protected void doStop() throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
313 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
314 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
315 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
316 close();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
317 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
318 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
319 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
320 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
321 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
322
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
323 super.doStop();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
324
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
325 Thread[] acceptors;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
326 synchronized (this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
327 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
328 acceptors = _acceptorThreads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
329 _acceptorThreads = null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
330 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
331 if (acceptors != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
332 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
333 for (Thread thread : acceptors)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
334 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
335 if (thread != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
336 thread.interrupt();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
337 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
338 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
339 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
340
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
341 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
342 public void join() throws InterruptedException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
343 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
344 Thread[] threads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
345 synchronized(this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
346 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
347 threads=_acceptorThreads;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
348 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
349 if (threads != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
350 for (Thread thread : threads)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
351 if (thread != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
352 thread.join();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
353 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
354
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
355 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
356 protected void configure(Socket socket) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
357 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
358 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
359 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
360 socket.setTcpNoDelay(true);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
361 if (_soLingerTime >= 0)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
362 socket.setSoLinger(true,_soLingerTime / 1000);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
363 else
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
364 socket.setSoLinger(false,0);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
365 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
366 catch (Exception e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
367 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
368 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
369 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
370 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
371
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
372 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
373 public void customize(EndPoint endpoint, Request request) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
374 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
375 if (isForwarded())
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
376 checkForwardedHeaders(endpoint,request);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
377 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
378
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
379 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
380 protected void checkForwardedHeaders(EndPoint endpoint, Request request) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
381 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
382 HttpFields httpFields = request.getConnection().getRequestFields();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
383
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
384 // Do SSL first
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
385 if (getForwardedCipherSuiteHeader()!=null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
386 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
387 String cipher_suite=httpFields.getStringField(getForwardedCipherSuiteHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
388 if (cipher_suite!=null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
389 request.setAttribute("javax.servlet.request.cipher_suite",cipher_suite);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
390 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
391 if (getForwardedSslSessionIdHeader()!=null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
392 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
393 String ssl_session_id=httpFields.getStringField(getForwardedSslSessionIdHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
394 if(ssl_session_id!=null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
395 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
396 request.setAttribute("javax.servlet.request.ssl_session_id", ssl_session_id);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
397 request.setScheme(HttpSchemes.HTTPS);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
398 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
399 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
400
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
401 // Retrieving headers from the request
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
402 String forwardedHost = getLeftMostFieldValue(httpFields,getForwardedHostHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
403 String forwardedServer = getLeftMostFieldValue(httpFields,getForwardedServerHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
404 String forwardedFor = getLeftMostFieldValue(httpFields,getForwardedForHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
405 String forwardedProto = getLeftMostFieldValue(httpFields,getForwardedProtoHeader());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
406
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
407 if (_hostHeader != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
408 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
409 // Update host header
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
410 httpFields.put(HttpHeaders.HOST_BUFFER,_hostHeader);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
411 request.setServerName(null);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
412 request.setServerPort(-1);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
413 request.getServerName();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
414 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
415 else if (forwardedHost != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
416 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
417 // Update host header
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
418 httpFields.put(HttpHeaders.HOST_BUFFER,forwardedHost);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
419 request.setServerName(null);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
420 request.setServerPort(-1);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
421 request.getServerName();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
422 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
423 else if (forwardedServer != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
424 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
425 // Use provided server name
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
426 request.setServerName(forwardedServer);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
427 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
428
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
429 if (forwardedFor != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
430 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
431 request.setRemoteAddr(forwardedFor);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
432 InetAddress inetAddress = null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
433
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
434 if (_useDNS)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
435 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
436 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
437 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
438 inetAddress = InetAddress.getByName(forwardedFor);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
439 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
440 catch (UnknownHostException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
441 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
442 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
443 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
444 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
445
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
446 request.setRemoteHost(inetAddress == null?forwardedFor:inetAddress.getHostName());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
447 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
448
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
449 if (forwardedProto != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
450 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
451 request.setScheme(forwardedProto);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
452 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
453 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
454
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
455 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
456 protected String getLeftMostFieldValue(HttpFields fields, String header)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
457 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
458 if (header == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
459 return null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
460
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
461 String headerValue = fields.getStringField(header);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
462
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
463 if (headerValue == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
464 return null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
465
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
466 int commaIndex = headerValue.indexOf(',');
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
467
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
468 if (commaIndex == -1)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
469 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
470 // Single value
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
471 return headerValue;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
472 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
473
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
474 // The left-most value is the farthest downstream client
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
475 return headerValue.substring(0,commaIndex);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
476 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
477
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
478 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
479 public void persist(EndPoint endpoint) throws IOException
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
480 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
481 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
482
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
483 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
484 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
485 * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
486 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
487 public int getConfidentialPort()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
488 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
489 return _confidentialPort;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
490 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
491
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
492 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
493 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
494 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
495 * @see org.eclipse.jetty.server.Connector#getConfidentialScheme()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
496 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
497 public String getConfidentialScheme()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
498 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
499 return _confidentialScheme;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
500 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
501
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
502 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
503 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
504 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server .Request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
505 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
506 public boolean isIntegral(Request request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
507 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
508 return false;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
509 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
510
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
511 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
512 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
513 * @see org.eclipse.jetty.server.Connector#getConfidentialPort()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
514 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
515 public int getIntegralPort()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
516 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
517 return _integralPort;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
518 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
519
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
520 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
521 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
522 * @see org.eclipse.jetty.server.Connector#getIntegralScheme()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
523 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
524 public String getIntegralScheme()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
525 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
526 return _integralScheme;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
527 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
528
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
529 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
530 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
531 * @see org.eclipse.jetty.server.Connector#isConfidential(org.eclipse.jetty.server.Request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
532 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
533 public boolean isConfidential(Request request)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
534 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
535 return _forwarded && request.getScheme().equalsIgnoreCase(HttpSchemes.HTTPS);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
536 }
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
537
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
538 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
539 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
540 * @param confidentialPort
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
541 * The confidentialPort to set.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
542 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
543 public void setConfidentialPort(int confidentialPort)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
544 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
545 _confidentialPort = confidentialPort;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
546 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
547
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
548 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
549 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
550 * @param confidentialScheme
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
551 * The confidentialScheme to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
552 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
553 public void setConfidentialScheme(String confidentialScheme)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
554 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
555 _confidentialScheme = confidentialScheme;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
556 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
557
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
558 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
559 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
560 * @param integralPort
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
561 * The integralPort to set.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
562 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
563 public void setIntegralPort(int integralPort)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
564 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
565 _integralPort = integralPort;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
566 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
567
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
568 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
569 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
570 * @param integralScheme
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
571 * The integralScheme to set.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
572 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
573 public void setIntegralScheme(String integralScheme)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
574 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
575 _integralScheme = integralScheme;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
576 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
577
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
578 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
579 protected abstract void accept(int acceptorID) throws IOException, InterruptedException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
580
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
581 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
582 public void stopAccept(int acceptorID) throws Exception
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
583 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
584 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
585
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
586 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
587 public boolean getResolveNames()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
588 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
589 return _useDNS;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
590 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
591
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
592 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
593 public void setResolveNames(boolean resolve)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
594 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
595 _useDNS = resolve;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
596 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
597
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
598 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
599 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
600 * Is reverse proxy handling on?
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
601 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
602 * @return true if this connector is checking the x-forwarded-for/host/server headers
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
603 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
604 public boolean isForwarded()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
605 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
606 return _forwarded;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
607 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
608
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
609 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
610 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
611 * Set reverse proxy handling. If set to true, then the X-Forwarded headers (or the headers set in their place) are looked for to set the request protocol,
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
612 * host, server and client ip.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
613 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
614 * @param check
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
615 * true if this connector is checking the x-forwarded-for/host/server headers
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
616 * @see #setForwardedForHeader(String)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
617 * @see #setForwardedHostHeader(String)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
618 * @see #setForwardedProtoHeader(String)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
619 * @see #setForwardedServerHeader(String)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
620 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
621 public void setForwarded(boolean check)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
622 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
623 if (check)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
624 LOG.debug("{} is forwarded",this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
625 _forwarded = check;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
626 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
627
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
628 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
629 public String getHostHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
630 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
631 return _hostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
632 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
633
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
634 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
635 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
636 * Set a forced valued for the host header to control what is returned by {@link ServletRequest#getServerName()} and {@link ServletRequest#getServerPort()}.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
637 * This value is only used if {@link #isForwarded()} is true.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
638 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
639 * @param hostHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
640 * The value of the host header to force.
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
641 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
642 public void setHostHeader(String hostHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
643 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
644 _hostHeader = hostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
645 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
646
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
647 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
648 /*
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
649 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
650 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
651 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
652 public String getForwardedHostHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
653 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
654 return _forwardedHostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
655 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
656
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
657 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
658 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
659 * @param forwardedHostHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
660 * The header name for forwarded hosts (default x-forwarded-host)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
661 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
662 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
663 public void setForwardedHostHeader(String forwardedHostHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
664 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
665 _forwardedHostHeader = forwardedHostHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
666 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
667
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
668 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
669 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
670 * @return the header name for forwarded server.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
671 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
672 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
673 public String getForwardedServerHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
674 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
675 return _forwardedServerHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
676 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
677
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
678 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
679 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
680 * @param forwardedServerHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
681 * The header name for forwarded server (default x-forwarded-server)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
682 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
683 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
684 public void setForwardedServerHeader(String forwardedServerHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
685 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
686 _forwardedServerHeader = forwardedServerHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
687 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
688
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
689 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
690 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
691 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
692 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
693 public String getForwardedForHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
694 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
695 return _forwardedForHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
696 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
697
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
698 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
699 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
700 * @param forwardedRemoteAddressHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
701 * The header name for forwarded for (default x-forwarded-for)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
702 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
703 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
704 public void setForwardedForHeader(String forwardedRemoteAddressHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
705 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
706 _forwardedForHeader = forwardedRemoteAddressHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
707 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
708
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
709 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
710 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
711 * Get the forwardedProtoHeader.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
712 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
713 * @return the forwardedProtoHeader (default X-Forwarded-For)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
714 * @see #setForwarded(boolean)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
715 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
716 public String getForwardedProtoHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
717 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
718 return _forwardedProtoHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
719 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
720
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
721 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
722 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
723 * Set the forwardedProtoHeader.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
724 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
725 * @param forwardedProtoHeader
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
726 * the forwardedProtoHeader to set (default X-Forwarded-For)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
727 * @see #setForwarded(boolean)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
728 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
729 public void setForwardedProtoHeader(String forwardedProtoHeader)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
730 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
731 _forwardedProtoHeader = forwardedProtoHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
732 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
733
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
734 /* ------------------------------------------------------------ */
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
735 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
736 * @return The header name holding a forwarded cipher suite (default null)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
737 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
738 public String getForwardedCipherSuiteHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
739 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
740 return _forwardedCipherSuiteHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
741 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
742
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
743 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
744 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
745 * @param forwardedCipherSuite
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
746 * The header name holding a forwarded cipher suite (default null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
747 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
748 public void setForwardedCipherSuiteHeader(String forwardedCipherSuite)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
749 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
750 _forwardedCipherSuiteHeader = forwardedCipherSuite;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
751 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
752
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
753 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
754 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
755 * @return The header name holding a forwarded SSL Session ID (default null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
756 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
757 public String getForwardedSslSessionIdHeader()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
758 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
759 return _forwardedSslSessionIdHeader;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
760 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
761
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
762 /* ------------------------------------------------------------ */
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
763 /**
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
764 * @param forwardedSslSessionId
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
765 * The header name holding a forwarded SSL Session ID (default null)
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
766 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
767 public void setForwardedSslSessionIdHeader(String forwardedSslSessionId)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
768 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
769 _forwardedSslSessionIdHeader = forwardedSslSessionId;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
770 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
771
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
772 public int getRequestBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
773 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
774 return _buffers.getRequestBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
775 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
776
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
777 public void setRequestBufferSize(int requestBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
778 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
779 _buffers.setRequestBufferSize(requestBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
780 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
781
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
782 public int getRequestHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
783 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
784 return _buffers.getRequestHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
785 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
786
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
787 public void setRequestHeaderSize(int requestHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
788 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
789 _buffers.setRequestHeaderSize(requestHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
790 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
791
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
792 public int getResponseBufferSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
793 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
794 return _buffers.getResponseBufferSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
795 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
796
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
797 public void setResponseBufferSize(int responseBufferSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
798 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
799 _buffers.setResponseBufferSize(responseBufferSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
800 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
801
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
802 public int getResponseHeaderSize()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
803 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
804 return _buffers.getResponseHeaderSize();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
805 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
806
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
807 public void setResponseHeaderSize(int responseHeaderSize)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
808 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
809 _buffers.setResponseHeaderSize(responseHeaderSize);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
810 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
811
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
812 public Type getRequestBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
813 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
814 return _buffers.getRequestBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
815 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
816
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
817 public Type getRequestHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
818 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
819 return _buffers.getRequestHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
820 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
821
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
822 public Type getResponseBufferType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
823 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
824 return _buffers.getResponseBufferType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
825 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
826
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
827 public Type getResponseHeaderType()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
828 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
829 return _buffers.getResponseHeaderType();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
830 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
831
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
832 public void setRequestBuffers(Buffers requestBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
833 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
834 _buffers.setRequestBuffers(requestBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
835 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
836
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
837 public void setResponseBuffers(Buffers responseBuffers)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
838 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
839 _buffers.setResponseBuffers(responseBuffers);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
840 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
841
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
842 public Buffers getRequestBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
843 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
844 return _buffers.getRequestBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
845 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
846
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
847 public Buffers getResponseBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
848 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
849 return _buffers.getResponseBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
850 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
851
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
852 public int getMaxBuffers()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
853 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
854 return _buffers.getMaxBuffers();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
855 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
856
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
857 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
858 @Override
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
859 public String toString()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
860 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
861 return String.format("%s@%s:%d",
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
862 getClass().getSimpleName(),
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
863 getHost()==null?"0.0.0.0":getHost(),
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
864 getLocalPort()<=0?getPort():getLocalPort());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
865 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
866
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
867 /* ------------------------------------------------------------ */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
868 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
869 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
870 private class Acceptor implements Runnable
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
871 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
872 int _acceptor = 0;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
873
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
874 Acceptor(int id)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
875 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
876 _acceptor = id;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
877 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
878
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
879 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
880 public void run()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
881 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
882 Thread current = Thread.currentThread();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
883 String name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
884 synchronized (Connector.this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
885 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
886 if (_acceptorThreads == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
887 return;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
888
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
889 _acceptorThreads[_acceptor] = current;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
890 name = _acceptorThreads[_acceptor].getName();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
891 current.setName(name + " Acceptor" + _acceptor + " " + Connector.this);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
892 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
893 int old_priority = current.getPriority();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
894
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
895 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
896 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
897 current.setPriority(old_priority - _acceptorPriorityOffset);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
898 while (isRunning() && getConnection() != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
899 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
900 try
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
901 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
902 accept(_acceptor);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
903 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
904 catch (EofException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
905 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
906 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
907 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
908 catch (IOException e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
909 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
910 LOG.trace("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
911 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
912 catch (InterruptedException x)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
913 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
914 // Connector has been stopped
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
915 LOG.trace("",x);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
916 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
917 catch (Throwable e)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
918 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
919 LOG.warn("",e);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
920 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
921 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
922 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
923 finally
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
924 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
925 current.setPriority(old_priority);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
926 current.setName(name);
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
927
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
928 synchronized (Connector.this)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
929 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
930 if (_acceptorThreads != null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
931 _acceptorThreads[_acceptor] = null;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
932 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
933 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
934 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
935 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
936
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
937 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
938 public String getName()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
939 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
940 if (_name == null)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
941 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
942 return _name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
943 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
944
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
945 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
946 public void setName(String name)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
947 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
948 _name = name;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
949 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
950
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
951 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
952 protected void connectionOpened(Connection connection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
953 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
954 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
955
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
956 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
957 protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
958 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
959 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
960
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
961 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
962 protected void connectionClosed(Connection connection)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
963 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
964 connection.onClose();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
965 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
966
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
967 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
968 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
969 * @return the acceptorPriority
818
ad292e148964 remove util/statistic
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
970 */
885
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
971 public int getAcceptorPriorityOffset()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
972 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
973 return _acceptorPriorityOffset;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
974 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
975
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
976 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
977 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
978 * Set the priority offset of the acceptor threads. The priority is adjusted by this amount (default 0) to either favour the acceptance of new threads and
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
979 * newly active connections or to favour the handling of already dispatched connections.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
980 *
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
981 * @param offset
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
982 * the amount to alter the priority of the acceptor threads.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
983 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
984 public void setAcceptorPriorityOffset(int offset)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
985 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
986 _acceptorPriorityOffset = offset;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
987 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
988
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
989 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
990 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
991 * @return True if the the server socket will be opened in SO_REUSEADDR mode.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
992 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
993 public boolean getReuseAddress()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
994 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
995 return _reuseAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
996 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
997
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
998 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
999 /**
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1000 * @param reuseAddress
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1001 * True if the the server socket will be opened in SO_REUSEADDR mode.
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1002 */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1003 public void setReuseAddress(boolean reuseAddress)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1004 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1005 _reuseAddress = reuseAddress;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1006 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1007
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1008 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1009 public final boolean isLowResources()
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1010 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1011 return _server.isLowOnThreads();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1012 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1013
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1014 /* ------------------------------------------------------------ */
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1015 private void updateNotEqual(AtomicLong valueHolder, long compare, long value)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1016 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1017 long oldValue = valueHolder.get();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1018 while (compare != oldValue)
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1019 {
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1020 if (valueHolder.compareAndSet(oldValue,value))
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1021 break;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1022 oldValue = valueHolder.get();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1023 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1024 }
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1025
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1026 // from old interface
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1027 public abstract void open() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1028 public abstract void close() throws IOException;
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1029 public abstract int getLocalPort();
150092cebf3e remove AbstractConnector
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
1030 public abstract Object getConnection();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1031 }