
org.glassfish.grizzly.http.ProcessingState Maven / Gradle / Ivy
/*
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.grizzly.http;
/**
* Maintains semantic state necessary to proper HTTP processing.
*/
public final class ProcessingState {
/**
*
* This flag controls the semantics of the Connection response header.
*
*/
boolean keepAlive = false;
/**
*
* Indicates if an error occurred during request/response processing.
*
*/
boolean error;
/**
*
* References {@link HttpContext} associated with the processing.
*
*/
HttpContext httpContext;
/**
*
* This flag indicates whether error occurred during the HTTP processing.
*
*
* @return true, if error occurred during the HTTP processing, or false otherwise.
*/
public boolean isError() {
return error;
}
/**
*
* This flag indicates whether error occurred during the HTTP processing.
*
*
* @param error true, if error occurred during the HTTP processing, or false otherwise.
*/
public void setError(boolean error) {
this.error = error;
}
/**
*
* Method returns true only if the connection is in keep-alive mode and there was no error occurred during the
* packet processing.
*
*
* @return true only if the connection is in keep-alive mode and there was no error occurred during the packet
* processing.
*/
public boolean isStayAlive() {
return keepAlive && !error;
}
/**
*
* This flag controls the connection keep-alive feature.
*
*
* @return true if connection may work in keep-alive mode or false otherwise.
*/
public boolean isKeepAlive() {
return keepAlive;
}
/**
*
* This flag controls the connection keep-alive feature.
*
*
* @param keepAlive true if connection may work in keep-alive mode or false otherwise.
*/
public void setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
}
/**
*
* Returns {@link HttpContext} associated with the processing.
*
*
* @return {@link HttpContext} associated with the processing.
*/
public HttpContext getHttpContext() {
return httpContext;
}
/**
*
* Sets the {@link HttpContext} associated with the processing.
*
*
* @param httpContext {@link HttpContext}.
*/
public void setHttpContext(final HttpContext httpContext) {
this.httpContext = httpContext;
}
/**
*
* Resets values to their initial states.
*
*/
public void recycle() {
keepAlive = false;
error = false;
httpContext = null;
}
}