jodd-http/src/main/java/jodd/http/HttpRequest.java
public HttpRequest keepAlive(final HttpResponse httpResponse, final boolean doContinue) {
		boolean keepAlive = httpResponse.isConnectionPersistent();
		if (keepAlive) {
			HttpConnection previousConnection = httpResponse.getHttpRequest().httpConnection;

			if (previousConnection != null) {
				// keep using the connection!
				this.httpConnection = previousConnection;
				this.httpConnectionProvider = httpResponse.getHttpRequest().connectionProvider();
			}

			//keepAlive = true; (already set)
		} else {
			// close previous connection
			httpResponse.close();

			// force keep-alive on new request
			keepAlive = true;
		}

		// if we don't want to continue with this persistent session, mark this connection as closed
		if (!doContinue) {
			keepAlive = false;
		}

		connectionKeepAlive(keepAlive);

		// if connection is not opened, open it using previous connection provider
		if (httpConnection == null) {
			open(httpResponse.getHttpRequest().connectionProvider());
		}
		return this;
	}
public HttpRequest keepAlive(final HttpResponse httpResponse, final boolean doContinue) {
		boolean keepAlive = httpResponse.isConnectionPersistent();
		if (keepAlive) {
			HttpConnection previousConnection = httpResponse.getHttpRequest().httpConnection;

			if (previousConnection != null) {
				// keep using the connection!
				this.httpConnection = previousConnection;
				this.httpConnectionProvider = httpResponse.getHttpRequest().connectionProvider();
			}

			//keepAlive = true; (already set)
		} else {
			// close previous connection
			httpResponse.close();

			// force keep-alive on new request
			keepAlive = true;
		}

		// if we don't want to continue with this persistent session, mark this connection as closed
		if (!doContinue) {
			keepAlive = false;
		}

		connectionKeepAlive(keepAlive);

		// if connection is not opened, open it using previous connection provider
		if (httpConnection == null) {
			open(httpResponse.getHttpRequest().connectionProvider());
		}
		return this;
	}
public HttpRequest keepAlive ( final HttpResponse httpResponse , final boolean doContinue ) { boolean keepAlive = httpResponse . isConnectionPersistent ( ) ; if ( keepAlive ) { HttpConnection previousConnection = httpResponse . getHttpRequest ( ) . httpConnection ; if ( previousConnection != null ) { // keep using the connection! this . httpConnection = previousConnection ; this . httpConnectionProvider = httpResponse . getHttpRequest ( ) . connectionProvider ( ) ; } //keepAlive = true; (already set) } else { // close previous connection httpResponse . close ( ) ; // force keep-alive on new request keepAlive = true ; } // if we don't want to continue with this persistent session, mark this connection as closed if ( ! doContinue ) { keepAlive = false ; } connectionKeepAlive ( keepAlive ) ; // if connection is not opened, open it using previous connection provider if ( httpConnection == null ) { open ( httpResponse . getHttpRequest ( ) . connectionProvider ( ) ) ; } return this ; }
Continues using the same keep-alive connection.
Don't use any variant of <code>open()</code> when
continuing the communication!
First it checks if "Connection" header exist in the response
and if it is equal to "Keep-Alive" value. Then it
checks the "Keep-Alive" headers "max" parameter.
If its value is positive, then the existing {@link jodd.http.HttpConnection}
from the request will be reused. If max value is 1,
connection will be sent with "Connection: Close" header, indicating
its the last request. When new connection is created, the
same {@link jodd.http.HttpConnectionProvider} that was used for
creating initial connection is used for opening the new connection.

@param doContinue set it to <code>false</code> to indicate the last connection
Continues using the same keep - alive connection . Don t use any variant of <code > open () < / code > when continuing the communication! First it checks if Connection header exist in the response and if it is equal to Keep - Alive value . Then it checks the Keep - Alive headers max parameter . If its value is positive then the existing { @link jodd . http . HttpConnection } from the request will be reused . If max value is 1 connection will be sent with Connection : Close header indicating its the last request . When new connection is created the same { @link jodd . http . HttpConnectionProvider } that was used for creating initial connection is used for opening the new connection .