/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Provides implementation for both HTTP and HTTPS
*/
private boolean https;
/* following two are used to keep track of the times
* when a connection/request is first received
* and when we start to send the response
*/
private volatile boolean finished = false;
private volatile boolean terminating = false;
private boolean bound = false;
private boolean started = false;
) throws IOException {
contexts = new ContextList();
bound = true;
}
schan.configureBlocking (false);
dispatcher = new Dispatcher();
if (timer1Enabled) {
}
}
if (bound) {
throw new BindException ("HttpServer already bound");
}
throw new NullPointerException ("null address");
}
bound = true;
}
public void start () {
throw new IllegalStateException ("server in wrong state");
}
executor = new DefaultExecutor();
}
started = true;
t.start();
}
if (started) {
throw new IllegalStateException ("server already started");
}
}
}
}
return executor;
}
throw new NullPointerException ("null HttpsConfigurator");
}
if (started) {
throw new IllegalStateException ("server already started");
}
this.httpsConfig = config;
}
return httpsConfig;
}
if (delay < 0) {
throw new IllegalArgumentException ("negative delay parameter");
}
terminating = true;
delay();
if (finished) {
break;
}
}
finished = true;
synchronized (allConnections) {
for (HttpConnection c : allConnections) {
c.close();
}
}
if (timer1Enabled) {
}
}
throw new NullPointerException ("null handler, or path parameter");
}
return context;
}
throw new NullPointerException ("null path parameter");
}
return context;
}
throw new NullPointerException ("null path parameter");
}
}
if (!(context instanceof HttpContextImpl)) {
throw new IllegalArgumentException ("wrong HttpContext type");
}
}
return AccessController.doPrivileged(
new PrivilegedAction<InetSocketAddress>() {
public InetSocketAddress run() {
return
}
});
}
return selector;
}
synchronized (lolock) {
}
}
/* main server listener task */
ExchangeImpl t = r.exchange;
HttpConnection c = t.getConnection();
try {
if (r instanceof WriteFinishedEvent) {
int exchanges = endExchange();
finished = true;
}
responseCompleted (c);
t.close = true;
}
c.close();
allConnections.remove (c);
} else {
if (is.isDataBuffered()) {
/* don't re-enable the interestops, just handle it */
requestStarted (c);
handle (c.getChannel(), c);
} else {
connsToRegister.add (c);
}
}
}
} catch (IOException e) {
);
c.close();
}
}
new LinkedList<HttpConnection>();
/* re-register with selector */
try {
chan.configureBlocking (false);
c.selectionKey = key;
idleConnections.add (c);
} catch (IOException e) {
dprint(e);
c.close();
}
}
public void run() {
while (!finished) {
try {
for (HttpConnection c : connsToRegister) {
reRegister(c);
}
synchronized (lolock) {
}
}
handleEvent (r);
}
}
/* process the selected list now */
if (terminating) {
continue;
}
// Set TCP_NODELAY, if appropriate
if (ServerConfig.noDelay()) {
}
continue; /* cancel something ? */
}
chan.configureBlocking (false);
HttpConnection c = new HttpConnection ();
c.selectionKey = newkey;
c.setChannel (chan);
requestStarted (c);
allConnections.add (c);
} else {
try {
if (key.isReadable()) {
boolean closed;
chan.configureBlocking (true);
// was an idle connection so add it
// to reqConnections set.
}
} else {
assert false;
}
} catch (CancelledKeyException e) {
} catch (IOException e) {
handleException(key, e);
}
}
}
// call the selector just to process the cancelled keys
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (e != null) {
}
}
throws IOException
{
try {
} catch (IOException e) {
}
}
}
if (debug) {
}
}
if (debug) {
e.printStackTrace();
}
}
return logger;
}
case REQUEST:
break;
case RESPONSE:
break;
case IDLE:
break;
}
}
/* per exchange task */
boolean rejected = false;
this.connection = conn;
}
public void run () {
/* context will be null for new connections */
boolean newconnection;
try {
newconnection = false;
} else {
/* figure out what kind of connection this is */
newconnection = true;
if (https) {
if (sslContext == null) {
throw new HttpError ("No SSL context established");
}
} else {
rawin = new BufferedInputStream(
new Request.ReadStream (
ServerImpl.this, chan
));
ServerImpl.this, chan
);
}
}
if (requestLine == null) {
/* connection closed */
return;
}
if (space == -1) {
requestLine, "Bad request line");
return;
}
if (space == -1) {
requestLine, "Bad request line");
return;
}
long clen = 0L;
clen = -1L;
} else {
if (s != null) {
}
if (clen == 0) {
}
}
requestLine, "No context found for request");
return;
}
requestLine, "No handler for context");
return;
}
tx = new ExchangeImpl (
);
}
}
}
if (newconnection) {
);
}
/* check if client sent an Expect 100 Continue.
* In that case, need to send an interim response.
* In future API may be modified to allow app to
* be involved in this process.
*/
);
}
* sf is the list of filters established internally
* and which are not visible to the user. uc and sc
* are the corresponding Filter.Chains.
* They are linked together by a LinkHandler
* so that they can both be invoked in one call.
*/
/* set up the two stream references */
tx.getRequestBody();
if (https) {
} else {
}
} catch (IOException e1) {
} catch (NumberFormatException e3) {
requestLine, "NumberFormatException thrown");
} catch (URISyntaxException e) {
requestLine, "URISyntaxException thrown");
}
}
/* used to link to 2 or more Filter.Chains together */
}
}
}
rejected = true;
);
}
void sendReply (
{
try {
} else {
text = "";
}
if (closeNow) {
}
byte[] b = s.getBytes("ISO8859_1");
if (closeNow) {
}
} catch (IOException e) {
}
}
}
return;
}
text = "";
}
String r;
} else {
r = requestStr;
}
}
long getTicks() {
return ticks;
}
public long getTime() {
return time;
}
void delay () {
try {
} catch (InterruptedException e) {}
}
synchronized void startExchange () {
exchangeCount ++;
}
synchronized int endExchange () {
exchangeCount --;
assert exchangeCount >= 0;
return exchangeCount;
}
return wrapper;
}
c.creationTime = getTime();
reqConnections.add (c);
}
// called after a request has been completely read
// by the server. This stops the timer which would
// close the connection if the request doesn't arrive
// quickly enough. It then starts the timer
// that ensures the client reads the response in a timely
// fashion.
reqConnections.remove (c);
c.rspStartedTime = getTime();
rspConnections.add (c);
}
// called after response has been sent
rspConnections.remove (c);
}
/**
* TimerTask run every CLOCK_TICK ms
*/
public void run () {
ticks ++;
synchronized (idleConnections) {
for (HttpConnection c : idleConnections) {
}
}
for (HttpConnection c : toClose) {
idleConnections.remove (c);
allConnections.remove (c);
c.close();
}
}
}
}
// runs every TIMER_MILLIS
public void run () {
synchronized (reqConnections) {
if (MAX_REQ_TIME != -1) {
for (HttpConnection c : reqConnections) {
}
}
for (HttpConnection c : toClose) {
reqConnections.remove (c);
allConnections.remove (c);
c.close();
}
}
}
synchronized (rspConnections) {
if (MAX_RSP_TIME != -1) {
for (HttpConnection c : rspConnections) {
}
}
for (HttpConnection c : toClose) {
rspConnections.remove (c);
allConnections.remove (c);
c.close();
}
}
}
}
}
StringBuilder b = new StringBuilder ();
for (int i=0; i<e.length; i++) {
}
}
if (secs == -1) {
return -1;
} else {
return secs * 1000;
}
}
}