diff --git a/BUILDING.txt b/BUILDING.txt
deleted file mode 100644
index ff168133e48..00000000000
--- a/BUILDING.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-BUILDING JETTY
---------------
-
-Jetty is built with maven 3.x+
-
- $ cd /my/work/directory/jetty-7
- $ mvn clean install
-
-
diff --git a/LICENSE-APACHE-2.0.txt b/LICENSE-APACHE-2.0.txt
deleted file mode 100644
index d6456956733..00000000000
--- a/LICENSE-APACHE-2.0.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/LICENSE-ECLIPSE-1.0.html b/LICENSE-eplv10-aslv20.html
similarity index 55%
rename from LICENSE-ECLIPSE-1.0.html
rename to LICENSE-eplv10-aslv20.html
index 9320c9f37cf..48addaaddf7 100644
--- a/LICENSE-ECLIPSE-1.0.html
+++ b/LICENSE-eplv10-aslv20.html
@@ -6,7 +6,7 @@
-
Eclipse Public License - Version 1.0
+Eclipse Public License - Version 1.0 / Apache License - Version 2.0
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
-
- org.eclipse.jetty.client.*
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- unpack
- generate-test-resources
-
- unpack
-
-
-
-
- org.eclipse.jetty.toolchain
- jetty-test-policy
- ${jetty-test-policy-version}
- jar
- true
- **/*.keystore,**/*.pem
- ${jetty.test.policy.loc}
-
-
-
-
-
-
-
-
-
-
-
- org.eclipse.jetty
- jetty-http
- ${project.version}
-
-
- org.eclipse.jetty
- jetty-server
- ${project.version}
- test
-
-
- org.eclipse.jetty
- jetty-security
- ${project.version}
- test
-
-
- org.eclipse.jetty
- jetty-servlet
- ${project.version}
- test
-
-
-
- org.eclipse.jetty.toolchain
- jetty-test-helper
- test
-
-
-
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
deleted file mode 100644
index 83960b87a39..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
+++ /dev/null
@@ -1,570 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.eclipse.jetty.client.security.Authentication;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.http.HttpGenerator;
-import org.eclipse.jetty.http.HttpHeaderValue;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpParser;
-import org.eclipse.jetty.http.HttpScheme;
-import org.eclipse.jetty.http.HttpStatus;
-import org.eclipse.jetty.http.HttpVersion;
-import org.eclipse.jetty.io.AbstractConnection;
-
-import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.ByteArrayBuffer;
-import org.eclipse.jetty.io.Connection;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.io.EofException;
-import org.eclipse.jetty.io.View;
-import org.eclipse.jetty.util.component.AggregateLifeCycle;
-import org.eclipse.jetty.util.component.Dumpable;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.util.thread.Timeout;
-
-/**
- *
- * @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
- */
-public abstract class AbstractHttpConnection extends AbstractConnection implements Dumpable
-{
- private static final Logger LOG = Log.getLogger(AbstractHttpConnection.class);
-
- protected HttpDestination _destination;
- protected HttpGenerator _generator;
- protected HttpParser _parser;
- protected boolean _http11 = true;
- protected int _status;
- protected ByteBuffer _connectionHeader;
- protected boolean _reserved;
-
- // The current exchange waiting for a response
- protected volatile HttpExchange _exchange;
- protected HttpExchange _pipeline;
- private final Timeout.Task _idleTimeout = new ConnectionIdleTask();
- private AtomicBoolean _idle = new AtomicBoolean(false);
-
-
- AbstractHttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
- {
- super(endp);
-
- _generator = new HttpGenerator(requestBuffers,endp);
- _parser = new HttpParser(responseBuffers,endp,new Handler());
- }
-
- public void setReserved (boolean reserved)
- {
- _reserved = reserved;
- }
-
- public boolean isReserved()
- {
- return _reserved;
- }
-
- public HttpDestination getDestination()
- {
- return _destination;
- }
-
- public void setDestination(HttpDestination destination)
- {
- _destination = destination;
- }
-
- public boolean send(HttpExchange ex) throws IOException
- {
- LOG.debug("Send {} on {}",ex,this);
- synchronized (this)
- {
- if (_exchange != null)
- {
- if (_pipeline != null)
- throw new IllegalStateException(this + " PIPELINED!!! _exchange=" + _exchange);
- _pipeline = ex;
- return true;
- }
-
- _exchange = ex;
- _exchange.associate(this);
-
- // The call to associate() may have closed the connection, check if it's the case
- if (!_endp.isOpen())
- {
- _exchange.disassociate();
- _exchange = null;
- return false;
- }
-
- _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_COMMIT);
-
- adjustIdleTimeout();
-
- return true;
- }
- }
-
- private void adjustIdleTimeout() throws IOException
- {
- // Adjusts the idle timeout in case the default or exchange timeout
- // are greater. This is needed for long polls, where one wants an
- // aggressive releasing of idle connections (so idle timeout is small)
- // but still allow long polls to complete normally
-
- long timeout = _exchange.getTimeout();
- if (timeout <= 0)
- timeout = _destination.getHttpClient().getTimeout();
-
- long endPointTimeout = _endp.getMaxIdleTime();
-
- if (timeout > 0 && timeout > endPointTimeout)
- {
- // Make it larger than the exchange timeout so that there are
- // no races between the idle timeout and the exchange timeout
- // when trying to close the endpoint
- _endp.setMaxIdleTime(2 * (int)timeout);
- }
- }
-
- public abstract Connection handle() throws IOException;
-
-
- public boolean isIdle()
- {
- synchronized (this)
- {
- return _exchange == null;
- }
- }
-
- public boolean isSuspended()
- {
- return false;
- }
-
- public void onClose()
- {
- }
-
- /**
- * @throws IOException
- */
- protected void commitRequest() throws IOException
- {
- synchronized (this)
- {
- _status=0;
- if (_exchange.getStatus() != HttpExchange.STATUS_WAITING_FOR_COMMIT)
- throw new IllegalStateException();
-
- _exchange.setStatus(HttpExchange.STATUS_SENDING_REQUEST);
- _generator.setVersion(_exchange.getVersion());
-
- String method=_exchange.getMethod();
- String uri = _exchange.getRequestURI();
- if (_destination.isProxied())
- {
- if (!HttpMethod.CONNECT.equals(method) && uri.startsWith("/"))
- {
- boolean secure = _destination.isSecure();
- String host = _destination.getAddress().getHost();
- int port = _destination.getAddress().getPort();
- StringBuilder absoluteURI = new StringBuilder();
- absoluteURI.append(secure ? HttpScheme.HTTPS : HttpScheme.HTTP);
- absoluteURI.append("://");
- absoluteURI.append(host);
- // Avoid adding default ports
- if (!(secure && port == 443 || !secure && port == 80))
- absoluteURI.append(":").append(port);
- absoluteURI.append(uri);
- uri = absoluteURI.toString();
- }
- Authentication auth = _destination.getProxyAuthentication();
- if (auth != null)
- auth.setCredentials(_exchange);
- }
-
- _generator.setRequest(method, uri);
- _parser.setHeadResponse(HttpMethod.HEAD.equalsIgnoreCase(method));
-
- HttpFields requestHeaders = _exchange.getRequestFields();
- if (_exchange.getVersion() >= HttpVersion.HTTP_1_1_ORDINAL)
- {
- if (!requestHeaders.containsKey(HttpHeader.HOST_BUFFER))
- requestHeaders.add(HttpHeader.HOST_BUFFER,_destination.getHostHeader());
- }
-
- ByteBuffer requestContent = _exchange.getRequestContent();
- if (requestContent != null)
- {
- requestHeaders.putLongField(HttpHeader.CONTENT_LENGTH, requestContent.length());
- _generator.completeHeader(requestHeaders,false);
- _generator.addContent(new View(requestContent),true);
- _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
- }
- else
- {
- InputStream requestContentStream = _exchange.getRequestContentSource();
- if (requestContentStream != null)
- {
- _generator.completeHeader(requestHeaders, false);
- }
- else
- {
- requestHeaders.remove(HttpHeader.CONTENT_LENGTH);
- _generator.completeHeader(requestHeaders, true);
- _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
- }
- }
- }
- }
-
- protected void reset() throws IOException
- {
- _connectionHeader = null;
- _parser.reset();
- _generator.reset();
- _http11 = true;
- }
-
-
- private class Handler extends HttpParser.EventHandler
- {
- @Override
- public void startRequest(ByteBuffer method, ByteBuffer url, ByteBuffer version) throws IOException
- {
- // System.out.println( method.toString() + "///" + url.toString() +
- // "///" + version.toString() );
- // TODO validate this is acceptable, the = 0)
- {
- host = hostAndPort.substring(0, colon);
- port = Integer.parseInt(hostAndPort.substring(colon + 1));
- }
- else
- {
- host = hostAndPort;
- port = 0;
- }
- return new Address(host, port);
- }
-
- public Address(String host, int port)
- {
- if (host == null)
- throw new IllegalArgumentException("Host is null");
-
- this.host = host.trim();
- this.port = port;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- Address that = (Address)obj;
- if (!host.equals(that.host)) return false;
- return port == that.port;
- }
-
- @Override
- public int hashCode()
- {
- int result = host.hashCode();
- result = 31 * result + port;
- return result;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public InetSocketAddress toSocketAddress()
- {
- return new InetSocketAddress(getHost(), getPort());
- }
-
- @Override
- public String toString()
- {
- return host + ":" + port;
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
deleted file mode 100644
index 8c95ceab571..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
+++ /dev/null
@@ -1,267 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-
-import org.eclipse.jetty.http.AbstractGenerator;
-import org.eclipse.jetty.http.HttpStatus;
-import org.eclipse.jetty.io.AsyncEndPoint;
-
-import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.Connection;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.io.nio.AsyncConnection;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-
-
-
-/* ------------------------------------------------------------ */
-/** Asynchronous Client HTTP Connection
- */
-public class AsyncHttpConnection extends AbstractHttpConnection implements AsyncConnection
-{
- private static final Logger LOG = Log.getLogger(AsyncHttpConnection.class);
-
- private boolean _requestComplete;
- private ByteBuffer _requestContentChunk;
- private final AsyncEndPoint _asyncEndp;
-
- AsyncHttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endp)
- {
- super(requestBuffers,responseBuffers,endp);
- _asyncEndp=(AsyncEndPoint)endp;
- }
-
- protected void reset() throws IOException
- {
- _requestComplete = false;
- super.reset();
- }
-
- public Connection handle() throws IOException
- {
- Connection connection = this;
- boolean progress=true;
-
- try
- {
- boolean failed = false;
-
- // While we are making progress and have not changed connection
- while (progress && connection==this)
- {
- LOG.debug("while open={} more={} progress={}",_endp.isOpen(),_parser.isMoreInBuffer(),progress);
-
- progress=false;
- HttpExchange exchange=_exchange;
-
- LOG.debug("exchange {} on {}",exchange,this);
-
- try
- {
- // Should we commit the request?
- if (!_generator.isCommitted() && exchange!=null && exchange.getStatus() == HttpExchange.STATUS_WAITING_FOR_COMMIT)
- {
- LOG.debug("commit {}",exchange);
- progress=true;
- commitRequest();
- }
-
- // Generate output
- if (_generator.isCommitted() && !_generator.isComplete())
- {
- if (_generator.flushBuffer()>0)
- {
- LOG.debug("flushed");
- progress=true;
- }
-
- // Is there more content to send or should we complete the generator
- if (_generator.isState(AbstractGenerator.STATE_CONTENT))
- {
- // Look for more content to send.
- if (_requestContentChunk==null)
- _requestContentChunk = exchange.getRequestContentChunk(null);
-
- if (_requestContentChunk==null)
- {
- LOG.debug("complete {}",exchange);
- progress=true;
- _generator.complete();
- }
- else if (_generator.isEmpty())
- {
- LOG.debug("addChunk");
- progress=true;
- ByteBuffer chunk=_requestContentChunk;
- _requestContentChunk=exchange.getRequestContentChunk(null);
- _generator.addContent(chunk,_requestContentChunk==null);
- if (_requestContentChunk==null)
- exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
- }
- }
- }
-
- // Signal request completion
- if (_generator.isComplete() && !_requestComplete)
- {
- LOG.debug("requestComplete {}",exchange);
- progress=true;
- _requestComplete = true;
- exchange.getEventListener().onRequestComplete();
- }
-
- // Read any input that is available
- if (!_parser.isComplete() && _parser.parseAvailable())
- {
- LOG.debug("parsed {}",exchange);
- progress=true;
- }
-
- // Flush output
- _endp.flush();
-
- // Has any IO been done by the endpoint itself since last loop
- if (_asyncEndp.hasProgressed())
- {
- LOG.debug("hasProgressed {}",exchange);
- progress=true;
- }
- }
- catch (Throwable e)
- {
- LOG.debug("Failure on " + _exchange, e);
-
- failed = true;
-
- synchronized (this)
- {
- if (exchange != null)
- {
- // Cancelling the exchange causes an exception as we close the connection,
- // but we don't report it as it is normal cancelling operation
- if (exchange.getStatus() != HttpExchange.STATUS_CANCELLING &&
- exchange.getStatus() != HttpExchange.STATUS_CANCELLED &&
- !exchange.isDone())
- {
- if (exchange.setStatus(HttpExchange.STATUS_EXCEPTED))
- exchange.getEventListener().onException(e);
- }
- }
- else
- {
- if (e instanceof IOException)
- throw (IOException)e;
- if (e instanceof Error)
- throw (Error)e;
- if (e instanceof RuntimeException)
- throw (RuntimeException)e;
- throw new RuntimeException(e);
- }
- }
- }
- finally
- {
- LOG.debug("finally {} on {} progress={} {}",exchange,this,progress,_endp);
-
- boolean complete = failed || _generator.isComplete() && _parser.isComplete();
-
- if (complete)
- {
- boolean persistent = !failed && _parser.isPersistent() && _generator.isPersistent();
- _generator.setPersistent(persistent);
- reset();
- if (persistent)
- _endp.setMaxIdleTime((int)_destination.getHttpClient().getIdleTimeout());
-
- synchronized (this)
- {
- exchange=_exchange;
- _exchange = null;
-
- // Cancel the exchange
- if (exchange!=null)
- {
- exchange.cancelTimeout(_destination.getHttpClient());
-
- // TODO should we check the exchange is done?
- }
-
- // handle switched protocols
- if (_status==HttpStatus.SWITCHING_PROTOCOLS_101)
- {
- Connection switched=exchange.onSwitchProtocol(_endp);
- if (switched!=null)
- {
- // switched protocol!
- if (_pipeline!=null)
- {
- _destination.send(_pipeline);
- }
- _pipeline = null;
-
- connection=switched;
- }
- }
-
- // handle pipelined requests
- if (_pipeline!=null)
- {
- if (!persistent || connection!=this)
- _destination.send(_pipeline);
- else
- _exchange=_pipeline;
- _pipeline=null;
- }
-
- if (_exchange==null && !isReserved()) // TODO how do we return switched connections?
- _destination.returnConnection(this, !persistent);
- }
-
- }
- }
- }
- }
- finally
- {
- _parser.returnBuffers();
- _generator.returnBuffers();
- LOG.debug("unhandle {} on {}",_exchange,_endp);
- }
-
- return connection;
- }
-
- public void onInputShutdown() throws IOException
- {
- if (_generator.isIdle())
- _endp.shutdownOutput();
- }
-
- @Override
- public boolean send(HttpExchange ex) throws IOException
- {
- boolean sent=super.send(ex);
- if (sent)
- _asyncEndp.asyncDispatch();
- return sent;
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java
deleted file mode 100644
index 22f61346efe..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java
+++ /dev/null
@@ -1,264 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-
-import org.eclipse.jetty.http.AbstractGenerator;
-import org.eclipse.jetty.http.HttpStatus;
-
-import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.Connection;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-
-
-/* ------------------------------------------------------------ */
-/** Blocking HTTP Connection
- */
-public class BlockingHttpConnection extends AbstractHttpConnection
-{
- private static final Logger LOG = Log.getLogger(BlockingHttpConnection.class);
-
- private boolean _requestComplete;
- private ByteBuffer _requestContentChunk;
-
- BlockingHttpConnection(Buffers requestBuffers, Buffers responseBuffers, EndPoint endPoint)
- {
- super(requestBuffers, responseBuffers, endPoint);
- }
-
- protected void reset() throws IOException
- {
- _requestComplete = false;
- super.reset();
- }
-
- @Override
- public Connection handle() throws IOException
- {
- Connection connection = this;
-
- try
- {
- boolean failed = false;
-
-
- // While we are making progress and have not changed connection
- while (_endp.isOpen() && connection==this)
- {
- LOG.debug("open={} more={}",_endp.isOpen(),_parser.isMoreInBuffer());
-
- HttpExchange exchange;
- synchronized (this)
- {
- exchange=_exchange;
-
- while (exchange == null)
- {
- try
- {
- this.wait();
- exchange=_exchange;
- }
- catch (InterruptedException e)
- {
- throw new InterruptedIOException();
- }
- }
- }
- LOG.debug("exchange {}",exchange);
-
- try
- {
- // Should we commit the request?
- if (!_generator.isCommitted() && exchange!=null && exchange.getStatus() == HttpExchange.STATUS_WAITING_FOR_COMMIT)
- {
- LOG.debug("commit");
- commitRequest();
- }
-
- // Generate output
- while (_generator.isCommitted() && !_generator.isComplete())
- {
- if (_generator.flushBuffer()>0)
- {
- LOG.debug("flushed");
- }
-
- // Is there more content to send or should we complete the generator
- if (_generator.isState(AbstractGenerator.STATE_CONTENT))
- {
- // Look for more content to send.
- if (_requestContentChunk==null)
- _requestContentChunk = exchange.getRequestContentChunk(null);
-
- if (_requestContentChunk==null)
- {
- LOG.debug("complete");
- _generator.complete();
- }
- else if (_generator.isEmpty())
- {
- LOG.debug("addChunk");
- ByteBuffer chunk=_requestContentChunk;
- _requestContentChunk=exchange.getRequestContentChunk(null);
- _generator.addContent(chunk,_requestContentChunk==null);
- if (_requestContentChunk==null)
- exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE);
- }
- }
- }
-
- // Signal request completion
- if (_generator.isComplete() && !_requestComplete)
- {
- LOG.debug("requestComplete");
- _requestComplete = true;
- exchange.getEventListener().onRequestComplete();
- }
-
- // Read any input that is available
- if (!_parser.isComplete() && _parser.parseAvailable())
- {
- LOG.debug("parsed");
- }
-
- // Flush output
- _endp.flush();
- }
- catch (Throwable e)
- {
- LOG.debug("Failure on " + _exchange, e);
-
- failed = true;
-
- synchronized (this)
- {
- if (exchange != null)
- {
- // Cancelling the exchange causes an exception as we close the connection,
- // but we don't report it as it is normal cancelling operation
- if (exchange.getStatus() != HttpExchange.STATUS_CANCELLING &&
- exchange.getStatus() != HttpExchange.STATUS_CANCELLED &&
- !exchange.isDone())
- {
- if(exchange.setStatus(HttpExchange.STATUS_EXCEPTED))
- exchange.getEventListener().onException(e);
- }
- }
- else
- {
- if (e instanceof IOException)
- throw (IOException)e;
- if (e instanceof Error)
- throw (Error)e;
- if (e instanceof RuntimeException)
- throw (RuntimeException)e;
- throw new RuntimeException(e);
- }
- }
- }
- finally
- {
- LOG.debug("{} {}",_generator, _parser);
- LOG.debug("{}",_endp);
-
- boolean complete = failed || _generator.isComplete() && _parser.isComplete();
-
- if (complete)
- {
- boolean persistent = !failed && _parser.isPersistent() && _generator.isPersistent();
- _generator.setPersistent(persistent);
- reset();
- if (persistent)
- _endp.setMaxIdleTime((int)_destination.getHttpClient().getIdleTimeout());
-
- synchronized (this)
- {
- exchange=_exchange;
- _exchange = null;
-
- // Cancel the exchange
- if (exchange!=null)
- {
- exchange.cancelTimeout(_destination.getHttpClient());
-
- // TODO should we check the exchange is done?
- }
-
- // handle switched protocols
- if (_status==HttpStatus.SWITCHING_PROTOCOLS_101)
- {
- Connection switched=exchange.onSwitchProtocol(_endp);
- if (switched!=null)
- connection=switched;
- {
- // switched protocol!
- _pipeline = null;
- if (_pipeline!=null)
- _destination.send(_pipeline);
- _pipeline = null;
-
- connection=switched;
- }
- }
-
- // handle pipelined requests
- if (_pipeline!=null)
- {
- if (!persistent || connection!=this)
- _destination.send(_pipeline);
- else
- _exchange=_pipeline;
- _pipeline=null;
- }
-
- if (_exchange==null && !isReserved()) // TODO how do we return switched connections?
- _destination.returnConnection(this, !persistent);
- }
- }
- }
- }
- }
- finally
- {
- _parser.returnBuffers();
- _generator.returnBuffers();
- }
-
- return connection;
- }
-
- @Override
- public boolean send(HttpExchange ex) throws IOException
- {
- boolean sent=super.send(ex);
- if (sent)
- {
- synchronized (this)
- {
- notifyAll();
- }
- }
- return sent;
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/CachedExchange.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/CachedExchange.java
deleted file mode 100644
index fa9094bb815..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/CachedExchange.java
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-
-import org.eclipse.jetty.http.HttpFields;
-
-
-/**
- * An exchange that retains response status and response headers for later use.
- */
-public class CachedExchange extends HttpExchange
-{
- private final HttpFields _responseFields;
- private volatile int _responseStatus;
-
- /**
- * Creates a new CachedExchange.
- *
- * @param cacheHeaders true to cache response headers, false to not cache them
- */
- public CachedExchange(boolean cacheHeaders)
- {
- _responseFields = cacheHeaders ? new HttpFields() : null;
- }
-
- public synchronized int getResponseStatus()
- {
- if (getStatus() < HttpExchange.STATUS_PARSING_HEADERS)
- throw new IllegalStateException("Response not received yet");
- return _responseStatus;
- }
-
- public synchronized HttpFields getResponseFields()
- {
- if (getStatus() < HttpExchange.STATUS_PARSING_CONTENT)
- throw new IllegalStateException("Headers not completely received yet");
- return _responseFields;
- }
-
- @Override
- protected synchronized void onResponseStatus(ByteBuffer version, int status, ByteBuffer reason) throws IOException
- {
- _responseStatus = status;
- super.onResponseStatus(version, status, reason);
- }
-
- @Override
- protected synchronized void onResponseHeader(ByteBuffer name, ByteBuffer value) throws IOException
- {
- if (_responseFields != null)
- {
- _responseFields.add(name, value.asImmutableBuffer());
- }
-
- super.onResponseHeader(name, value);
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/ContentExchange.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/ContentExchange.java
deleted file mode 100644
index 532c2331745..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/ContentExchange.java
+++ /dev/null
@@ -1,135 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.jetty.http.HttpHeader;
-
-
-import org.eclipse.jetty.util.StringUtil;
-
-/**
- * A exchange that retains response content for later use.
- */
-public class ContentExchange extends CachedExchange
-{
- private int _bufferSize = 4096;
- private String _encoding = "utf-8";
- private ByteArrayOutputStream _responseContent;
- private File _fileForUpload;
-
- public ContentExchange()
- {
- super(false);
- }
-
- public ContentExchange(boolean cacheFields)
- {
- super(cacheFields);
- }
-
- public synchronized String getResponseContent() throws UnsupportedEncodingException
- {
- if (_responseContent != null)
- return _responseContent.toString(_encoding);
- return null;
- }
-
- public synchronized byte[] getResponseContentBytes()
- {
- if (_responseContent != null)
- return _responseContent.toByteArray();
- return null;
- }
-
- @Override
- protected synchronized void onResponseStatus(ByteBuffer version, int status, ByteBuffer reason) throws IOException
- {
- if (_responseContent!=null)
- _responseContent.reset();
- super.onResponseStatus(version,status,reason);
- }
-
- @Override
- protected synchronized void onResponseHeader(ByteBuffer name, ByteBuffer value) throws IOException
- {
- super.onResponseHeader(name, value);
- int header = HttpHeader.CACHE.getOrdinal(name);
- switch (header)
- {
- case HttpHeader.CONTENT_LENGTH_ORDINAL:
- _bufferSize = BufferUtil.toInt(value);
- break;
- case HttpHeader.CONTENT_TYPE_ORDINAL:
- String mime = StringUtil.asciiToLowerCase(value.toString());
- int i = mime.indexOf("charset=");
- if (i > 0)
- {
- _encoding = mime.substring(i + 8);
- i = _encoding.indexOf(';');
- if (i > 0)
- _encoding = _encoding.substring(0, i);
- }
- break;
- }
- }
-
- @Override
- protected synchronized void onResponseContent(ByteBuffer content) throws IOException
- {
- super.onResponseContent(content);
- if (_responseContent == null)
- _responseContent = new ByteArrayOutputStream(_bufferSize);
- content.writeTo(_responseContent);
- }
-
- @Override
- protected synchronized void onRetry() throws IOException
- {
- if (_fileForUpload != null)
- {
- setRequestContent(null);
- setRequestContentSource(getInputStream());
- }
- else
- super.onRetry();
- }
-
- private synchronized InputStream getInputStream() throws IOException
- {
- return new FileInputStream(_fileForUpload);
- }
-
- public synchronized File getFileForUpload()
- {
- return _fileForUpload;
- }
-
- public synchronized void setFileForUpload(File fileForUpload) throws IOException
- {
- this._fileForUpload = fileForUpload;
- setRequestContentSource(getInputStream());
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpClient.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpClient.java
deleted file mode 100644
index 704e289c552..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpClient.java
+++ /dev/null
@@ -1,906 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import javax.net.ssl.SSLContext;
-
-import org.eclipse.jetty.client.security.Authentication;
-import org.eclipse.jetty.client.security.RealmResolver;
-import org.eclipse.jetty.client.security.SecurityListener;
-import org.eclipse.jetty.http.HttpBuffers;
-import org.eclipse.jetty.http.HttpBuffersImpl;
-import org.eclipse.jetty.http.HttpScheme;
-import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.Buffers.Type;
-import org.eclipse.jetty.util.Attributes;
-import org.eclipse.jetty.util.AttributesMap;
-import org.eclipse.jetty.util.component.AggregateLifeCycle;
-import org.eclipse.jetty.util.component.Dumpable;
-import org.eclipse.jetty.util.component.LifeCycle;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
-import org.eclipse.jetty.util.thread.QueuedThreadPool;
-import org.eclipse.jetty.util.thread.ThreadPool;
-import org.eclipse.jetty.util.thread.Timeout;
-
-/**
- * Http Client.
- *
- * HttpClient is the main active component of the client API implementation.
- * It is the opposite of the Connectors in standard Jetty, in that it listens
- * for responses rather than requests. Just like the connectors, there is a
- * blocking socket version and a non-blocking NIO version (implemented as nested classes
- * selected by {@link #setConnectorType(int)}).
- *
- * The an instance of {@link HttpExchange} is passed to the {@link #send(HttpExchange)} method
- * to send a request. The exchange contains both the headers and content (source) of the request
- * plus the callbacks to handle responses. A HttpClient can have many exchanges outstanding
- * and they may be queued on the {@link HttpDestination} waiting for a {@link AbstractHttpConnection},
- * queued in the {@link AbstractHttpConnection} waiting to be transmitted or pipelined on the actual
- * TCP/IP connection waiting for a response.
- *
- * The {@link HttpDestination} class is an aggregation of {@link AbstractHttpConnection}s for the
- * same host, port and protocol. A destination may limit the number of connections
- * open and they provide a pool of open connections that may be reused. Connections may also
- * be allocated from a destination, so that multiple request sources are not multiplexed
- * over the same connection.
- *
- * @see HttpExchange
- * @see HttpDestination
- */
-public class HttpClient extends AggregateLifeCycle implements HttpBuffers, Attributes, Dumpable
-{
- public static final int CONNECTOR_SOCKET = 0;
- public static final int CONNECTOR_SELECT_CHANNEL = 2;
-
- private int _connectorType = CONNECTOR_SELECT_CHANNEL;
- private boolean _useDirectBuffers = true;
- private boolean _connectBlocking = true;
- private int _maxConnectionsPerAddress = Integer.MAX_VALUE;
- private int _maxQueueSizePerAddress = Integer.MAX_VALUE;
- private ConcurrentMap _destinations = new ConcurrentHashMap();
- ThreadPool _threadPool;
- Connector _connector;
- private long _idleTimeout = 20000;
- private long _timeout = 320000;
- private int _connectTimeout = 75000;
- private Timeout _timeoutQ = new Timeout();
- private Timeout _idleTimeoutQ = new Timeout();
- private Address _proxy;
- private Authentication _proxyAuthentication;
- private Set _noProxy;
- private int _maxRetries = 3;
- private int _maxRedirects = 20;
- private LinkedList _registeredListeners;
-
- private final SslContextFactory _sslContextFactory;
-
- private RealmResolver _realmResolver;
-
- private AttributesMap _attributes=new AttributesMap();
-
- private final HttpBuffersImpl _buffers= new HttpBuffersImpl();
-
- /* ------------------------------------------------------------------------------- */
- private void setBufferTypes()
- {
- if (_connectorType==CONNECTOR_SOCKET)
- {
- _buffers.setRequestBufferType(Type.BYTE_ARRAY);
- _buffers.setRequestHeaderType(Type.BYTE_ARRAY);
- _buffers.setResponseBufferType(Type.BYTE_ARRAY);
- _buffers.setResponseHeaderType(Type.BYTE_ARRAY);
- }
- else
- {
- _buffers.setRequestBufferType(Type.DIRECT);
- _buffers.setRequestHeaderType(_useDirectBuffers?Type.DIRECT:Type.INDIRECT);
- _buffers.setResponseBufferType(Type.DIRECT);
- _buffers.setResponseHeaderType(_useDirectBuffers?Type.DIRECT:Type.INDIRECT);
- }
-
- }
-
- /* ------------------------------------------------------------------------------- */
- public HttpClient()
- {
- this(new SslContextFactory());
- }
-
- /* ------------------------------------------------------------------------------- */
- public HttpClient(SslContextFactory sslContextFactory)
- {
- _sslContextFactory = sslContextFactory;
- addBean(_sslContextFactory);
- addBean(_buffers);
- }
-
- /* ------------------------------------------------------------------------------- */
- /**
- * @return True if connects will be in blocking mode.
- */
- public boolean isConnectBlocking()
- {
- return _connectBlocking;
- }
-
- /* ------------------------------------------------------------------------------- */
- /**
- * @param connectBlocking True if connects will be in blocking mode.
- */
- public void setConnectBlocking(boolean connectBlocking)
- {
- _connectBlocking = connectBlocking;
- }
-
- /* ------------------------------------------------------------------------------- */
- public void send(HttpExchange exchange) throws IOException
- {
- boolean ssl = HttpScheme.HTTPS_BUFFER.equalsIgnoreCase(exchange.getScheme());
- exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_CONNECTION);
- HttpDestination destination = getDestination(exchange.getAddress(), ssl);
- destination.send(exchange);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the threadpool
- */
- public ThreadPool getThreadPool()
- {
- return _threadPool;
- }
-
- /* ------------------------------------------------------------ */
- /** Set the ThreadPool.
- * The threadpool passed is added via {@link #addBean(Object)} so that
- * it's lifecycle may be managed as a {@link AggregateLifeCycle}.
- * @param threadPool the threadPool to set
- */
- public void setThreadPool(ThreadPool threadPool)
- {
- removeBean(_threadPool);
- _threadPool = threadPool;
- addBean(_threadPool);
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * @param name
- * @return Attribute associated with client
- */
- public Object getAttribute(String name)
- {
- return _attributes.getAttribute(name);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return names of attributes associated with client
- */
- public Enumeration getAttributeNames()
- {
- return _attributes.getAttributeNames();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param name
- */
- public void removeAttribute(String name)
- {
- _attributes.removeAttribute(name);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Set an attribute on the HttpClient.
- * Attributes are not used by the client, but are provided for
- * so that users of a shared HttpClient may share other structures.
- * @param name
- * @param attribute
- */
- public void setAttribute(String name, Object attribute)
- {
- _attributes.setAttribute(name,attribute);
- }
-
- /* ------------------------------------------------------------ */
- public void clearAttributes()
- {
- _attributes.clearAttributes();
- }
-
- /* ------------------------------------------------------------------------------- */
- public HttpDestination getDestination(Address remote, boolean ssl) throws IOException
- {
- if (remote == null)
- throw new UnknownHostException("Remote socket address cannot be null.");
-
- HttpDestination destination = _destinations.get(remote);
- if (destination == null)
- {
- destination = new HttpDestination(this, remote, ssl);
- if (_proxy != null && (_noProxy == null || !_noProxy.contains(remote.getHost())))
- {
- destination.setProxy(_proxy);
- if (_proxyAuthentication != null)
- destination.setProxyAuthentication(_proxyAuthentication);
- }
- HttpDestination other =_destinations.putIfAbsent(remote, destination);
- if (other!=null)
- destination=other;
- }
- return destination;
- }
-
- /* ------------------------------------------------------------ */
- public void schedule(Timeout.Task task)
- {
- _timeoutQ.schedule(task);
- }
-
- /* ------------------------------------------------------------ */
- public void schedule(Timeout.Task task, long timeout)
- {
- _timeoutQ.schedule(task, timeout - _timeoutQ.getDuration());
- }
-
- /* ------------------------------------------------------------ */
- public void scheduleIdle(Timeout.Task task)
- {
- _idleTimeoutQ.schedule(task);
- }
-
- /* ------------------------------------------------------------ */
- public void cancel(Timeout.Task task)
- {
- task.cancel();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Get whether the connector can use direct NIO buffers.
- */
- public boolean getUseDirectBuffers()
- {
- return _useDirectBuffers;
- }
-
- /* ------------------------------------------------------------ */
- /** Set a RealmResolver for client Authentication.
- * If a realmResolver is set, then the HttpDestinations created by
- * this client will instantiate a {@link SecurityListener} so that
- * BASIC and DIGEST authentication can be performed.
- * @param resolver
- */
- public void setRealmResolver(RealmResolver resolver)
- {
- _realmResolver = resolver;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * returns the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null
- *
- * @return the SecurityRealmResolver reg_realmResolveristered with the HttpClient or null
- */
- public RealmResolver getRealmResolver()
- {
- return _realmResolver;
- }
-
- /* ------------------------------------------------------------ */
- public boolean hasRealms()
- {
- return _realmResolver == null ? false : true;
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * Registers a listener that can listen to the stream of execution between the client and the
- * server and influence events. Sequential calls to the method wrapper sequentially wrap the preceding
- * listener in a delegation model.
- *
- * NOTE: the SecurityListener is a special listener which doesn't need to be added via this
- * mechanic, if you register security realms then it will automatically be added as the top listener of the
- * delegation stack.
- *
- * @param listenerClass
- */
- public void registerListener(String listenerClass)
- {
- if (_registeredListeners == null)
- {
- _registeredListeners = new LinkedList();
- }
- _registeredListeners.add(listenerClass);
- }
-
- /* ------------------------------------------------------------ */
- public LinkedList getRegisteredListeners()
- {
- return _registeredListeners;
- }
-
-
- /* ------------------------------------------------------------ */
- /**
- * Set to use NIO direct buffers.
- *
- * @param direct If True (the default), the connector can use NIO direct
- * buffers. Some JVMs have memory management issues (bugs) with
- * direct buffers.
- */
- public void setUseDirectBuffers(boolean direct)
- {
- _useDirectBuffers = direct;
- setBufferTypes();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * Get the type of connector (socket, blocking or select) in use.
- */
- public int getConnectorType()
- {
- return _connectorType;
- }
-
- /* ------------------------------------------------------------ */
- public void setConnectorType(int connectorType)
- {
- this._connectorType = connectorType;
- setBufferTypes();
- }
-
- /* ------------------------------------------------------------ */
- public int getMaxConnectionsPerAddress()
- {
- return _maxConnectionsPerAddress;
- }
-
- /* ------------------------------------------------------------ */
- public void setMaxConnectionsPerAddress(int maxConnectionsPerAddress)
- {
- _maxConnectionsPerAddress = maxConnectionsPerAddress;
- }
-
- public int getMaxQueueSizePerAddress()
- {
- return _maxQueueSizePerAddress;
- }
-
- public void setMaxQueueSizePerAddress(int maxQueueSizePerAddress)
- {
- this._maxQueueSizePerAddress = maxQueueSizePerAddress;
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected void doStart() throws Exception
- {
- setBufferTypes();
-
- _timeoutQ.setDuration(_timeout);
- _timeoutQ.setNow();
- _idleTimeoutQ.setDuration(_idleTimeout);
- _idleTimeoutQ.setNow();
-
- if (_threadPool==null)
- {
- QueuedThreadPool pool = new LocalQueuedThreadPool();
- pool.setMaxThreads(16);
- pool.setDaemon(true);
- pool.setName("HttpClient");
- _threadPool = pool;
- addBean(_threadPool,true);
- }
-
- _connector=(_connectorType == CONNECTOR_SELECT_CHANNEL)?new SelectConnector(this):new SocketConnector(this);
- addBean(_connector,true);
-
- super.doStart();
-
- _threadPool.dispatch(new Runnable()
- {
- public void run()
- {
- while (isRunning())
- {
- _timeoutQ.tick(System.currentTimeMillis());
- _idleTimeoutQ.tick(_timeoutQ.getNow());
- try
- {
- Thread.sleep(200);
- }
- catch (InterruptedException ignored)
- {
- }
- }
- }
- });
- }
-
- /* ------------------------------------------------------------ */
- @Override
- protected void doStop() throws Exception
- {
- for (HttpDestination destination : _destinations.values())
- destination.close();
-
- _timeoutQ.cancelAll();
- _idleTimeoutQ.cancelAll();
-
- super.doStop();
-
- if (_threadPool instanceof LocalQueuedThreadPool)
- {
- removeBean(_threadPool);
- _threadPool = null;
- }
-
- removeBean(_connector);
- }
-
- /* ------------------------------------------------------------ */
- interface Connector extends LifeCycle
- {
- public void startConnection(HttpDestination destination) throws IOException;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * if a keystore location has been provided then client will attempt to use it as the keystore,
- * otherwise we simply ignore certificates and run with a loose ssl context.
- *
- * @return the SSL context
- */
- protected SSLContext getSSLContext()
- {
- return _sslContextFactory.getSslContext();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the instance of SslContextFactory associated with the client
- */
- public SslContextFactory getSslContextFactory()
- {
- return _sslContextFactory;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the period in milliseconds a {@link AbstractHttpConnection} can be idle for before it is closed.
- */
- public long getIdleTimeout()
- {
- return _idleTimeout;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param ms the period in milliseconds a {@link AbstractHttpConnection} can be idle for before it is closed.
- */
- public void setIdleTimeout(long ms)
- {
- _idleTimeout = ms;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the period in ms that an exchange will wait for a response from the server.
- * @deprecated use {@link #getTimeout()} instead.
- */
- @Deprecated
- public int getSoTimeout()
- {
- return Long.valueOf(getTimeout()).intValue();
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @deprecated use {@link #setTimeout(long)} instead.
- * @param timeout the period in ms that an exchange will wait for a response from the server.
- */
- @Deprecated
- public void setSoTimeout(int timeout)
- {
- setTimeout(timeout);
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the period in ms that an exchange will wait for a response from the server.
- */
- public long getTimeout()
- {
- return _timeout;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param timeout the period in ms that an exchange will wait for a response from the server.
- */
- public void setTimeout(long timeout)
- {
- _timeout = timeout;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @return the period in ms before timing out an attempt to connect
- */
- public int getConnectTimeout()
- {
- return _connectTimeout;
- }
-
- /* ------------------------------------------------------------ */
- /**
- * @param connectTimeout the period in ms before timing out an attempt to connect
- */
- public void setConnectTimeout(int connectTimeout)
- {
- this._connectTimeout = connectTimeout;
- }
-
- /* ------------------------------------------------------------ */
- public Address getProxy()
- {
- return _proxy;
- }
-
- /* ------------------------------------------------------------ */
- public void setProxy(Address proxy)
- {
- this._proxy = proxy;
- }
-
- /* ------------------------------------------------------------ */
- public Authentication getProxyAuthentication()
- {
- return _proxyAuthentication;
- }
-
- /* ------------------------------------------------------------ */
- public void setProxyAuthentication(Authentication authentication)
- {
- _proxyAuthentication = authentication;
- }
-
- /* ------------------------------------------------------------ */
- public boolean isProxied()
- {
- return this._proxy != null;
- }
-
- /* ------------------------------------------------------------ */
- public Set getNoProxy()
- {
- return _noProxy;
- }
-
- /* ------------------------------------------------------------ */
- public void setNoProxy(Set noProxyAddresses)
- {
- _noProxy = noProxyAddresses;
- }
-
- /* ------------------------------------------------------------ */
- public int maxRetries()
- {
- return _maxRetries;
- }
-
- /* ------------------------------------------------------------ */
- public void setMaxRetries(int retries)
- {
- _maxRetries = retries;
- }
-
- /* ------------------------------------------------------------ */
- public int maxRedirects()
- {
- return _maxRedirects;
- }
-
- /* ------------------------------------------------------------ */
- public void setMaxRedirects(int redirects)
- {
- _maxRedirects = redirects;
- }
-
- public int getRequestBufferSize()
- {
- return _buffers.getRequestBufferSize();
- }
-
- public void setRequestBufferSize(int requestBufferSize)
- {
- _buffers.setRequestBufferSize(requestBufferSize);
- }
-
- public int getRequestHeaderSize()
- {
- return _buffers.getRequestHeaderSize();
- }
-
- public void setRequestHeaderSize(int requestHeaderSize)
- {
- _buffers.setRequestHeaderSize(requestHeaderSize);
- }
-
- public int getResponseBufferSize()
- {
- return _buffers.getResponseBufferSize();
- }
-
- public void setResponseBufferSize(int responseBufferSize)
- {
- _buffers.setResponseBufferSize(responseBufferSize);
- }
-
- public int getResponseHeaderSize()
- {
- return _buffers.getResponseHeaderSize();
- }
-
- public void setResponseHeaderSize(int responseHeaderSize)
- {
- _buffers.setResponseHeaderSize(responseHeaderSize);
- }
-
- public Type getRequestBufferType()
- {
- return _buffers.getRequestBufferType();
- }
-
- public Type getRequestHeaderType()
- {
- return _buffers.getRequestHeaderType();
- }
-
- public Type getResponseBufferType()
- {
- return _buffers.getResponseBufferType();
- }
-
- public Type getResponseHeaderType()
- {
- return _buffers.getResponseHeaderType();
- }
-
- public void setRequestBuffers(Buffers requestBuffers)
- {
- _buffers.setRequestBuffers(requestBuffers);
- }
-
- public void setResponseBuffers(Buffers responseBuffers)
- {
- _buffers.setResponseBuffers(responseBuffers);
- }
-
- public Buffers getRequestBuffers()
- {
- return _buffers.getRequestBuffers();
- }
-
- public Buffers getResponseBuffers()
- {
- return _buffers.getResponseBuffers();
- }
-
- public void setMaxBuffers(int maxBuffers)
- {
- _buffers.setMaxBuffers(maxBuffers);
- }
-
- public int getMaxBuffers()
- {
- return _buffers.getMaxBuffers();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getTrustStoreLocation()
- {
- return _sslContextFactory.getTrustStore();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setTrustStoreLocation(String trustStoreLocation)
- {
- _sslContextFactory.setTrustStore(trustStoreLocation);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public InputStream getTrustStoreInputStream()
- {
- return _sslContextFactory.getTrustStoreInputStream();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setTrustStoreInputStream(InputStream trustStoreInputStream)
- {
- _sslContextFactory.setTrustStoreInputStream(trustStoreInputStream);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getKeyStoreLocation()
- {
- return _sslContextFactory.getKeyStorePath();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setKeyStoreLocation(String keyStoreLocation)
- {
- _sslContextFactory.setKeyStorePath(keyStoreLocation);
- }
-
- @Deprecated
- public InputStream getKeyStoreInputStream()
- {
- return _sslContextFactory.getKeyStoreInputStream();
- }
-
- @Deprecated
- public void setKeyStoreInputStream(InputStream keyStoreInputStream)
- {
- _sslContextFactory.setKeyStoreInputStream(keyStoreInputStream);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setKeyStorePassword(String keyStorePassword)
- {
- _sslContextFactory.setKeyStorePassword(keyStorePassword);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setKeyManagerPassword(String keyManagerPassword)
- {
- _sslContextFactory.setKeyManagerPassword(keyManagerPassword);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setTrustStorePassword(String trustStorePassword)
- {
- _sslContextFactory.setTrustStorePassword(trustStorePassword);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getKeyStoreType()
- {
- return _sslContextFactory.getKeyStoreType();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setKeyStoreType(String keyStoreType)
- {
- _sslContextFactory.setKeyStoreType(keyStoreType);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getTrustStoreType()
- {
- return _sslContextFactory.getTrustStoreType();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setTrustStoreType(String trustStoreType)
- {
- _sslContextFactory.setTrustStoreType(trustStoreType);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getKeyManagerAlgorithm()
- {
- return _sslContextFactory.getSslKeyManagerFactoryAlgorithm();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setKeyManagerAlgorithm(String keyManagerAlgorithm)
- {
- _sslContextFactory.setSslKeyManagerFactoryAlgorithm(keyManagerAlgorithm);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getTrustManagerAlgorithm()
- {
- return _sslContextFactory.getTrustManagerFactoryAlgorithm();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setTrustManagerAlgorithm(String trustManagerAlgorithm)
- {
- _sslContextFactory.setTrustManagerFactoryAlgorithm(trustManagerAlgorithm);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getProtocol()
- {
- return _sslContextFactory.getProtocol();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setProtocol(String protocol)
- {
- _sslContextFactory.setProtocol(protocol);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getProvider()
- {
- return _sslContextFactory.getProvider();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setProvider(String provider)
- {
- _sslContextFactory.setProvider(provider);
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public String getSecureRandomAlgorithm()
- {
- return _sslContextFactory.getSecureRandomAlgorithm();
- }
-
- /* ------------------------------------------------------------ */
- @Deprecated
- public void setSecureRandomAlgorithm(String secureRandomAlgorithm)
- {
- _sslContextFactory.setSecureRandomAlgorithm(secureRandomAlgorithm);
- }
-
- private static class LocalQueuedThreadPool extends QueuedThreadPool
- {
- }
-}
diff --git a/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpDestination.java b/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpDestination.java
deleted file mode 100644
index 5541582aa40..00000000000
--- a/jetty-client-old/src/main/java/org/eclipse/jetty/client/HttpDestination.java
+++ /dev/null
@@ -1,734 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.client;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.net.ProtocolException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.eclipse.jetty.client.HttpClient.Connector;
-import org.eclipse.jetty.client.security.Authentication;
-import org.eclipse.jetty.client.security.SecurityListener;
-import org.eclipse.jetty.http.HttpCookie;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import org.eclipse.jetty.http.PathMap;
-
-import org.eclipse.jetty.io.ByteArrayBuffer;
-import org.eclipse.jetty.io.Connection;
-import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.util.component.AggregateLifeCycle;
-import org.eclipse.jetty.util.component.Dumpable;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
-
-/**
- * @version $Revision: 879 $ $Date: 2009-09-11 16:13:28 +0200 (Fri, 11 Sep 2009) $
- */
-public class HttpDestination implements Dumpable
-{
- private static final Logger LOG = Log.getLogger(HttpDestination.class);
-
- private final List _queue = new LinkedList();
- private final List _connections = new LinkedList();
- private final BlockingQueue