diff --git a/src/org/apache/commons/codec/BinaryDecoder.java b/src/org/apache/commons/codec/BinaryDecoder.java deleted file mode 100644 index 7aebabffff7ee3ec7f37a0fc7e689ec49641684c..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/BinaryDecoder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec; - -/** - * Defines common decoding methods for byte array decoders. - * - * @author Apache Software Foundation - * @version $Id: BinaryDecoder.java,v 1.10 2004/06/15 18:14:15 ggregory Exp $ - */ -public interface BinaryDecoder extends Decoder { - - /** - * Decodes a byte array and returns the results as a byte array. - * - * @param pArray A byte array which has been encoded with the - * appropriate encoder - * - * @return a byte array that contains decoded content - * - * @throws DecoderException A decoder exception is thrown - * if a Decoder encounters a failure condition during - * the decode process. - */ - byte[] decode(byte[] pArray) throws DecoderException; -} - diff --git a/src/org/apache/commons/codec/BinaryEncoder.java b/src/org/apache/commons/codec/BinaryEncoder.java deleted file mode 100644 index 52859ed4f981175d1bb538a2be32cb86271b0a94..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/BinaryEncoder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec; - -/** - * Defines common encoding methods for byte array encoders. - * - * @author Apache Software Foundation - * @version $Id: BinaryEncoder.java,v 1.10 2004/02/29 04:08:31 tobrien Exp $ - */ -public interface BinaryEncoder extends Encoder { - - /** - * Encodes a byte array and return the encoded data - * as a byte array. - * - * @param pArray Data to be encoded - * - * @return A byte array containing the encoded data - * - * @throws EncoderException thrown if the Encoder - * encounters a failure condition during the - * encoding process. - */ - byte[] encode(byte[] pArray) throws EncoderException; -} - diff --git a/src/org/apache/commons/codec/Decoder.java b/src/org/apache/commons/codec/Decoder.java deleted file mode 100644 index 184920cf035242f015491c9f26f797209a855879..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/Decoder.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec; - -/** - *
Provides the highest level of abstraction for Decoders. - * This is the sister interface of {@link Encoder}. All - * Decoders implement this common generic interface.
- * - *Allows a user to pass a generic Object to any Decoder - * implementation in the codec package.
- * - *One of the two interfaces at the center of the codec package.
- * - * @author Apache Software Foundation - * @version $Id: Decoder.java,v 1.9 2004/02/29 04:08:31 tobrien Exp $ - */ -public interface Decoder { - - /** - * Decodes an "encoded" Object and returns a "decoded" - * Object. Note that the implementation of this - * interface will try to cast the Object parameter - * to the specific type expected by a particular Decoder - * implementation. If a {@link java.lang.ClassCastException} occurs - * this decode method will throw a DecoderException. - * - * @param pObject an object to "decode" - * - * @return a 'decoded" object - * - * @throws DecoderException a decoder exception can - * be thrown for any number of reasons. Some good - * candidates are that the parameter passed to this - * method is null, a param cannot be cast to the - * appropriate type for a specific encoder. - */ - Object decode(Object pObject) throws DecoderException; -} - diff --git a/src/org/apache/commons/codec/DecoderException.java b/src/org/apache/commons/codec/DecoderException.java deleted file mode 100644 index f35c016cf5cb34952ff6f933f95b2b5a482d9b41..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/DecoderException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec; - -/** - * Thrown when a Decoder has encountered a failure condition during a decode. - * - * @author Apache Software Foundation - * @version $Id: DecoderException.java,v 1.9 2004/02/29 04:08:31 tobrien Exp $ - */ -public class DecoderException extends Exception { - - /** - * Creates a DecoderException - * - * @param pMessage A message with meaning to a human - */ - public DecoderException(String pMessage) { - super(pMessage); - } - -} - diff --git a/src/org/apache/commons/codec/Encoder.java b/src/org/apache/commons/codec/Encoder.java deleted file mode 100644 index fa339eed98bc1d54bf282a42e80ae60936d74acb..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/Encoder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec; - -/** - *Provides the highest level of abstraction for Encoders. - * This is the sister interface of {@link Decoder}. Every implementation of - * Encoder provides this common generic interface whic allows a user to pass a - * generic Object to any Encoder implementation in the codec package.
- * - * @author Apache Software Foundation - * @version $Id: Encoder.java,v 1.10 2004/02/29 04:08:31 tobrien Exp $ - */ -public interface Encoder { - - /** - * Encodes an "Object" and returns the encoded content - * as an Object. The Objects here may just bebyte[]
- * or Strings depending on the implementation used.
- *
- * @param pObject An object ot encode
- *
- * @return An "encoded" Object
- *
- * @throws EncoderException an encoder exception is
- * thrown if the encoder experiences a failure
- * condition during the encoding process.
- */
- Object encode(Object pObject) throws EncoderException;
-}
-
diff --git a/src/org/apache/commons/codec/EncoderException.java b/src/org/apache/commons/codec/EncoderException.java
deleted file mode 100644
index 0e202c1b226a57418f22926f67f26b320a2bf463..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/EncoderException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec;
-
-/**
- * Thrown when there is a failure condition during the encoding process. This
- * exception is thrown when an Encoder encounters a encoding specific exception
- * such as invalid data, inability to calculate a checksum, characters outside of the
- * expected range.
- *
- * @author Apache Software Foundation
- * @version $Id: EncoderException.java,v 1.10 2004/02/29 04:08:31 tobrien Exp $
- */
-public class EncoderException extends Exception {
-
- /**
- * Creates a new instance of this exception with an useful message.
- *
- * @param pMessage a useful message relating to the encoder specific error.
- */
- public EncoderException(String pMessage) {
- super(pMessage);
- }
-}
-
diff --git a/src/org/apache/commons/codec/StringDecoder.java b/src/org/apache/commons/codec/StringDecoder.java
deleted file mode 100644
index 9b1a0cd33b8ce8d6eb2ea827167552950e0b1ead..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/StringDecoder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec;
-
-/**
- * Decodes a String into a String.
- *
- * @author Apache Software Foundation
- * @version $Id: StringDecoder.java,v 1.9 2004/02/29 04:08:31 tobrien Exp $
- */
-public interface StringDecoder extends Decoder {
-
- /**
- * Decodes a String and returns a String.
- *
- * @param pString a String to encode
- *
- * @return the encoded String
- *
- * @throws DecoderException thrown if there is
- * an error conidition during the Encoding process.
- */
- String decode(String pString) throws DecoderException;
-}
-
diff --git a/src/org/apache/commons/codec/StringEncoder.java b/src/org/apache/commons/codec/StringEncoder.java
deleted file mode 100644
index 46f5404e7a8d3c1635f8fd79f114b5825f206f53..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/StringEncoder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec;
-
-/**
- * Encodes a String into a String.
- *
- * @author Apache Software Foundation
- * @version $Id: StringEncoder.java,v 1.9 2004/02/29 04:08:31 tobrien Exp $
- */
-public interface StringEncoder extends Encoder {
-
- /**
- * Encodes a String and returns a String.
- *
- * @param pString a String to encode
- *
- * @return the encoded String
- *
- * @throws EncoderException thrown if there is
- * an error conidition during the Encoding process.
- */
- String encode(String pString) throws EncoderException;
-}
-
diff --git a/src/org/apache/commons/codec/StringEncoderComparator.java b/src/org/apache/commons/codec/StringEncoderComparator.java
deleted file mode 100644
index 6d29af26d195e00680ac90b9a8828e9e489867ce..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/StringEncoderComparator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec;
-
-import java.util.Comparator;
-
-/**
- * Strings are comparable, and this comparator allows
- * you to configure it with an instance of a class
- * which implements StringEncoder. This comparator
- * is used to sort Strings by an encoding scheme such
- * as Soundex, Metaphone, etc. This class can come in
- * handy if one need to sort Strings by an encoded
- * form of a name such as Soundex.
- *
- * @author Apache Software Foundation
- * @version $Id: StringEncoderComparator.java,v 1.14 2004/06/21 23:24:17 ggregory Exp $
- */
-public class StringEncoderComparator implements Comparator {
-
- /**
- * Internal encoder instance.
- */
- private StringEncoder stringEncoder;
-
- /**
- * Constructs a new instance.
- */
- public StringEncoderComparator() {
- // no init.
- }
-
- /**
- * Constructs a new instance with the given algorithm.
- * @param stringEncoder the StringEncoder used for comparisons.
- */
- public StringEncoderComparator(StringEncoder stringEncoder) {
- this.stringEncoder = stringEncoder;
- }
-
- /**
- * Compares two strings based not on the strings
- * themselves, but on an encoding of the two
- * strings using the StringEncoder this Comparator
- * was created with.
- *
- * If an {@link EncoderException} is encountered, return 0.
- *
- * @param o1 the object to compare
- * @param o2 the object to compare to
- * @return the Comparable.compareTo() return code or 0 if an encoding error was caught.
- * @see Comparable
- */
- public int compare(Object o1, Object o2) {
-
- int compareCode = 0;
-
- try {
- Comparable s1 = (Comparable) ((Encoder) this.stringEncoder).encode(o1);
- Comparable s2 = (Comparable) ((Encoder) this.stringEncoder).encode(o2);
- compareCode = s1.compareTo(s2);
- }
- catch (EncoderException ee) {
- compareCode = 0;
- }
- return compareCode;
- }
-
-}
diff --git a/src/org/apache/commons/codec/binary/Base64.java b/src/org/apache/commons/codec/binary/Base64.java
deleted file mode 100644
index ea479e99d7902d23d40be1fabddac383b7b8e174..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/binary/Base64.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec.binary;
-
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.BinaryEncoder;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.EncoderException;
-
-/**
- * Provides Base64 encoding and decoding as defined by RFC 2045.
- *
- * This class implements section 6.8. Base64 Content-Transfer-Encoding - * from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: - * Format of Internet Message Bodies by Freed and Borenstein.
- * - * @see RFC 2045 - * @author Apache Software Foundation - * @since 1.0-dev - * @version $Id: Base64.java,v 1.20 2004/05/24 00:21:24 ggregory Exp $ - */ -public class Base64 implements BinaryEncoder, BinaryDecoder { - - /** - * Chunk size per RFC 2045 section 6.8. - * - *The {@value} character limit does not count the trailing CRLF, but counts - * all other characters, including any equal signs.
- * - * @see RFC 2045 section 6.8 - */ - static final int CHUNK_SIZE = 76; - - /** - * Chunk separator per RFC 2045 section 2.1. - * - * @see RFC 2045 section 2.1 - */ - static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes(); - - /** - * The base length. - */ - static final int BASELENGTH = 255; - - /** - * Lookup length. - */ - static final int LOOKUPLENGTH = 64; - - /** - * Used to calculate the number of bits in a byte. - */ - static final int EIGHTBIT = 8; - - /** - * Used when encoding something which has fewer than 24 bits. - */ - static final int SIXTEENBIT = 16; - - /** - * Used to determine how many bits data contains. - */ - static final int TWENTYFOURBITGROUP = 24; - - /** - * Used to get the number of Quadruples. - */ - static final int FOURBYTE = 4; - - /** - * Used to test the sign of a byte. - */ - static final int SIGN = -128; - - /** - * Byte used to pad output. - */ - static final byte PAD = (byte) '='; - - // Create arrays to hold the base64 characters and a - // lookup for base64 chars - private static byte[] base64Alphabet = new byte[BASELENGTH]; - private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH]; - - // Populating the lookup and character arrays - static { - for (int i = 0; i < BASELENGTH; i++) { - base64Alphabet[i] = (byte) -1; - } - for (int i = 'Z'; i >= 'A'; i--) { - base64Alphabet[i] = (byte) (i - 'A'); - } - for (int i = 'z'; i >= 'a'; i--) { - base64Alphabet[i] = (byte) (i - 'a' + 26); - } - for (int i = '9'; i >= '0'; i--) { - base64Alphabet[i] = (byte) (i - '0' + 52); - } - - base64Alphabet['+'] = 62; - base64Alphabet['/'] = 63; - - for (int i = 0; i <= 25; i++) { - lookUpBase64Alphabet[i] = (byte) ('A' + i); - } - - for (int i = 26, j = 0; i <= 51; i++, j++) { - lookUpBase64Alphabet[i] = (byte) ('a' + j); - } - - for (int i = 52, j = 0; i <= 61; i++, j++) { - lookUpBase64Alphabet[i] = (byte) ('0' + j); - } - - lookUpBase64Alphabet[62] = (byte) '+'; - lookUpBase64Alphabet[63] = (byte) '/'; - } - - private static boolean isBase64(byte octect) { - if (octect == PAD) { - return true; - } else if (base64Alphabet[octect] == -1) { - return false; - } else { - return true; - } - } - - /** - * Tests a given byte array to see if it contains - * only valid characters within the Base64 alphabet. - * - * @param arrayOctect byte array to test - * @return true if all bytes are valid characters in the Base64 - * alphabet or if the byte array is empty; false, otherwise - */ - public static boolean isArrayByteBase64(byte[] arrayOctect) { - - arrayOctect = discardWhitespace(arrayOctect); - - int length = arrayOctect.length; - if (length == 0) { - // shouldn't a 0 length array be valid base64 data? - // return false; - return true; - } - for (int i = 0; i < length; i++) { - if (!isBase64(arrayOctect[i])) { - return false; - } - } - return true; - } - - /** - * Encodes binary data using the base64 algorithm but - * does not chunk the output. - * - * @param binaryData binary data to encode - * @return Base64 characters - */ - public static byte[] encodeBase64(byte[] binaryData) { - return encodeBase64(binaryData, false); - } - - /** - * Encodes binary data using the base64 algorithm and chunks - * the encoded output into 76 character blocks - * - * @param binaryData binary data to encode - * @return Base64 characters chunked in 76 character blocks - */ - public static byte[] encodeBase64Chunked(byte[] binaryData) { - return encodeBase64(binaryData, true); - } - - - /** - * Decodes an Object using the base64 algorithm. This method - * is provided in order to satisfy the requirements of the - * Decoder interface, and will throw a DecoderException if the - * supplied object is not of type byte[]. - * - * @param pObject Object to decode - * @return An object (of type byte[]) containing the - * binary data which corresponds to the byte[] supplied. - * @throws DecoderException if the parameter supplied is not - * of type byte[] - */ - public Object decode(Object pObject) throws DecoderException { - if (!(pObject instanceof byte[])) { - throw new DecoderException("Parameter supplied to Base64 decode is not a byte[]"); - } - return decode((byte[]) pObject); - } - - /** - * Decodes a byte[] containing containing - * characters in the Base64 alphabet. - * - * @param pArray A byte array containing Base64 character data - * @return a byte array containing binary data - */ - public byte[] decode(byte[] pArray) { - return decodeBase64(pArray); - } - - /** - * Encodes binary data using the base64 algorithm, optionally - * chunking the output into 76 character blocks. - * - * @param binaryData Array containing binary data to encode. - * @param isChunked if isChunked is true this encoder will chunk - * the base64 output into 76 character blocks - * @return Base64-encoded data. - */ - public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) { - int lengthDataBits = binaryData.length * EIGHTBIT; - int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; - int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; - byte encodedData[] = null; - int encodedDataLength = 0; - int nbrChunks = 0; - - if (fewerThan24bits != 0) { - //data not divisible by 24 bit - encodedDataLength = (numberTriplets + 1) * 4; - } else { - // 16 or 8 bit - encodedDataLength = numberTriplets * 4; - } - - // If the output is to be "chunked" into 76 character sections, - // for compliance with RFC 2045 MIME, then it is important to - // allow for extra length to account for the separator(s) - if (isChunked) { - - nbrChunks = - (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE)); - encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length; - } - - encodedData = new byte[encodedDataLength]; - - byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0; - - int encodedIndex = 0; - int dataIndex = 0; - int i = 0; - int nextSeparatorIndex = CHUNK_SIZE; - int chunksSoFar = 0; - - //log.debug("number of triplets = " + numberTriplets); - for (i = 0; i < numberTriplets; i++) { - dataIndex = i * 3; - b1 = binaryData[dataIndex]; - b2 = binaryData[dataIndex + 1]; - b3 = binaryData[dataIndex + 2]; - - //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3); - - l = (byte) (b2 & 0x0f); - k = (byte) (b1 & 0x03); - - byte val1 = - ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); - byte val2 = - ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); - byte val3 = - ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc); - - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - //log.debug( "val2 = " + val2 ); - //log.debug( "k4 = " + (k<<4) ); - //log.debug( "vak = " + (val2 | (k<<4)) ); - encodedData[encodedIndex + 1] = - lookUpBase64Alphabet[val2 | (k << 4)]; - encodedData[encodedIndex + 2] = - lookUpBase64Alphabet[(l << 2) | val3]; - encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f]; - - encodedIndex += 4; - - // If we are chunking, let's put a chunk separator down. - if (isChunked) { - // this assumes that CHUNK_SIZE % 4 == 0 - if (encodedIndex == nextSeparatorIndex) { - System.arraycopy( - CHUNK_SEPARATOR, - 0, - encodedData, - encodedIndex, - CHUNK_SEPARATOR.length); - chunksSoFar++; - nextSeparatorIndex = - (CHUNK_SIZE * (chunksSoFar + 1)) + - (chunksSoFar * CHUNK_SEPARATOR.length); - encodedIndex += CHUNK_SEPARATOR.length; - } - } - } - - // form integral number of 6-bit groups - dataIndex = i * 3; - - if (fewerThan24bits == EIGHTBIT) { - b1 = binaryData[dataIndex]; - k = (byte) (b1 & 0x03); - //log.debug("b1=" + b1); - //log.debug("b1<<2 = " + (b1>>2) ); - byte val1 = - ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4]; - encodedData[encodedIndex + 2] = PAD; - encodedData[encodedIndex + 3] = PAD; - } else if (fewerThan24bits == SIXTEENBIT) { - - b1 = binaryData[dataIndex]; - b2 = binaryData[dataIndex + 1]; - l = (byte) (b2 & 0x0f); - k = (byte) (b1 & 0x03); - - byte val1 = - ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0); - byte val2 = - ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0); - - encodedData[encodedIndex] = lookUpBase64Alphabet[val1]; - encodedData[encodedIndex + 1] = - lookUpBase64Alphabet[val2 | (k << 4)]; - encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2]; - encodedData[encodedIndex + 3] = PAD; - } - - if (isChunked) { - // we also add a separator to the end of the final chunk. - if (chunksSoFar < nbrChunks) { - System.arraycopy( - CHUNK_SEPARATOR, - 0, - encodedData, - encodedDataLength - CHUNK_SEPARATOR.length, - CHUNK_SEPARATOR.length); - } - } - - return encodedData; - } - - /** - * Decodes Base64 data into octects - * - * @param base64Data Byte array containing Base64 data - * @return Array containing decoded data. - */ - public static byte[] decodeBase64(byte[] base64Data) { - // RFC 2045 requires that we discard ALL non-Base64 characters - base64Data = discardNonBase64(base64Data); - - // handle the edge case, so we don't have to worry about it later - if (base64Data.length == 0) { - return new byte[0]; - } - - int numberQuadruple = base64Data.length / FOURBYTE; - byte decodedData[] = null; - byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0; - - // Throw away anything not in base64Data - - int encodedIndex = 0; - int dataIndex = 0; - { - // this sizes the output array properly - rlw - int lastData = base64Data.length; - // ignore the '=' padding - while (base64Data[lastData - 1] == PAD) { - if (--lastData == 0) { - return new byte[0]; - } - } - decodedData = new byte[lastData - numberQuadruple]; - } - - for (int i = 0; i < numberQuadruple; i++) { - dataIndex = i * 4; - marker0 = base64Data[dataIndex + 2]; - marker1 = base64Data[dataIndex + 3]; - - b1 = base64Alphabet[base64Data[dataIndex]]; - b2 = base64Alphabet[base64Data[dataIndex + 1]]; - - if (marker0 != PAD && marker1 != PAD) { - //No PAD e.g 3cQl - b3 = base64Alphabet[marker0]; - b4 = base64Alphabet[marker1]; - - decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); - decodedData[encodedIndex + 1] = - (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); - decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4); - } else if (marker0 == PAD) { - //Two PAD e.g. 3c[Pad][Pad] - decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); - } else if (marker1 == PAD) { - //One PAD e.g. 3cQ[Pad] - b3 = base64Alphabet[marker0]; - - decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4); - decodedData[encodedIndex + 1] = - (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf)); - } - encodedIndex += 3; - } - return decodedData; - } - - /** - * Discards any whitespace from a base-64 encoded block. - * - * @param data The base-64 encoded data to discard the whitespace - * from. - * @return The data, less whitespace (see RFC 2045). - */ - static byte[] discardWhitespace(byte[] data) { - byte groomedData[] = new byte[data.length]; - int bytesCopied = 0; - - for (int i = 0; i < data.length; i++) { - switch (data[i]) { - case (byte) ' ' : - case (byte) '\n' : - case (byte) '\r' : - case (byte) '\t' : - break; - default: - groomedData[bytesCopied++] = data[i]; - } - } - - byte packedData[] = new byte[bytesCopied]; - - System.arraycopy(groomedData, 0, packedData, 0, bytesCopied); - - return packedData; - } - - /** - * Discards any characters outside of the base64 alphabet, per - * the requirements on page 25 of RFC 2045 - "Any characters - * outside of the base64 alphabet are to be ignored in base64 - * encoded data." - * - * @param data The base-64 encoded data to groom - * @return The data, less non-base64 characters (see RFC 2045). - */ - static byte[] discardNonBase64(byte[] data) { - byte groomedData[] = new byte[data.length]; - int bytesCopied = 0; - - for (int i = 0; i < data.length; i++) { - if (isBase64(data[i])) { - groomedData[bytesCopied++] = data[i]; - } - } - - byte packedData[] = new byte[bytesCopied]; - - System.arraycopy(groomedData, 0, packedData, 0, bytesCopied); - - return packedData; - } - - - // Implementation of the Encoder Interface - - /** - * Encodes an Object using the base64 algorithm. This method - * is provided in order to satisfy the requirements of the - * Encoder interface, and will throw an EncoderException if the - * supplied object is not of type byte[]. - * - * @param pObject Object to encode - * @return An object (of type byte[]) containing the - * base64 encoded data which corresponds to the byte[] supplied. - * @throws EncoderException if the parameter supplied is not - * of type byte[] - */ - public Object encode(Object pObject) throws EncoderException { - if (!(pObject instanceof byte[])) { - throw new EncoderException( - "Parameter supplied to Base64 encode is not a byte[]"); - } - return encode((byte[]) pObject); - } - - /** - * Encodes a byte[] containing binary data, into a byte[] containing - * characters in the Base64 alphabet. - * - * @param pArray a byte array containing binary data - * @return A byte array containing only Base64 character data - */ - public byte[] encode(byte[] pArray) { - return encodeBase64(pArray, false); - } - -} diff --git a/src/org/apache/commons/codec/binary/BinaryCodec.java b/src/org/apache/commons/codec/binary/BinaryCodec.java deleted file mode 100644 index 98c6409ede6e29e69b8065e7850f503e33052555..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/binary/BinaryCodec.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.binary; - -import org.apache.commons.codec.BinaryDecoder; -import org.apache.commons.codec.BinaryEncoder; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.EncoderException; - -/** - * Translates between byte arrays and strings of "0"s and "1"s. - * - * TODO: may want to add more bit vector functions like and/or/xor/nand. - * TODO: also might be good to generate boolean[] - * from byte[] et. cetera. - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id $ - */ -public class BinaryCodec implements BinaryDecoder, BinaryEncoder { - /* - * tried to avoid using ArrayUtils to minimize dependencies while using these empty arrays - dep is just not worth - * it. - */ - /** Empty char array. */ - private static final char[] EMPTY_CHAR_ARRAY = new char[0]; - - /** Empty byte array. */ - private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; - - /** Mask for bit 0 of a byte. */ - private static final int BIT_0 = 1; - - /** Mask for bit 1 of a byte. */ - private static final int BIT_1 = 0x02; - - /** Mask for bit 2 of a byte. */ - private static final int BIT_2 = 0x04; - - /** Mask for bit 3 of a byte. */ - private static final int BIT_3 = 0x08; - - /** Mask for bit 4 of a byte. */ - private static final int BIT_4 = 0x10; - - /** Mask for bit 5 of a byte. */ - private static final int BIT_5 = 0x20; - - /** Mask for bit 6 of a byte. */ - private static final int BIT_6 = 0x40; - - /** Mask for bit 7 of a byte. */ - private static final int BIT_7 = 0x80; - - private static final int[] BITS = {BIT_0, BIT_1, BIT_2, BIT_3, BIT_4, BIT_5, BIT_6, BIT_7}; - - /** - * Converts an array of raw binary data into an array of ascii 0 and 1 characters. - * - * @param raw - * the raw binary data to convert - * @return 0 and 1 ascii character bytes one for each bit of the argument - * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) - */ - public byte[] encode(byte[] raw) { - return toAsciiBytes(raw); - } - - /** - * Converts an array of raw binary data into an array of ascii 0 and 1 chars. - * - * @param raw - * the raw binary data to convert - * @return 0 and 1 ascii character chars one for each bit of the argument - * @throws EncoderException - * if the argument is not a byte[] - * @see org.apache.commons.codec.Encoder#encode(java.lang.Object) - */ - public Object encode(Object raw) throws EncoderException { - if (!(raw instanceof byte[])) { - throw new EncoderException("argument not a byte array"); - } - return toAsciiChars((byte[]) raw); - } - - /** - * Decodes a byte array where each byte represents an ascii '0' or '1'. - * - * @param ascii - * each byte represents an ascii '0' or '1' - * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument - * @throws DecoderException - * if argument is not a byte[], char[] or String - * @see org.apache.commons.codec.Decoder#decode(java.lang.Object) - */ - public Object decode(Object ascii) throws DecoderException { - if (ascii == null) { - return EMPTY_BYTE_ARRAY; - } - if (ascii instanceof byte[]) { - return fromAscii((byte[]) ascii); - } - if (ascii instanceof char[]) { - return fromAscii((char[]) ascii); - } - if (ascii instanceof String) { - return fromAscii(((String) ascii).toCharArray()); - } - throw new DecoderException("argument not a byte array"); - } - - /** - * Decodes a byte array where each byte represents an ascii '0' or '1'. - * - * @param ascii - * each byte represents an ascii '0' or '1' - * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument - * @see org.apache.commons.codec.Decoder#decode(Object) - */ - public byte[] decode(byte[] ascii) { - return fromAscii(ascii); - } - - /** - * Decodes a String where each char of the String represents an ascii '0' or '1'. - * - * @param ascii - * String of '0' and '1' characters - * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument - * @see org.apache.commons.codec.Decoder#decode(Object) - */ - public byte[] toByteArray(String ascii) { - if (ascii == null) { - return EMPTY_BYTE_ARRAY; - } - return fromAscii(ascii.toCharArray()); - } - - // ------------------------------------------------------------------------ - // - // static codec operations - // - // ------------------------------------------------------------------------ - /** - * Decodes a byte array where each char represents an ascii '0' or '1'. - * - * @param ascii - * each char represents an ascii '0' or '1' - * @return the raw encoded binary where each bit corresponds to a char in the char array argument - */ - public static byte[] fromAscii(char[] ascii) { - if (ascii == null || ascii.length == 0) { - return EMPTY_BYTE_ARRAY; - } - // get length/8 times bytes with 3 bit shifts to the right of the length - byte[] l_raw = new byte[ascii.length >> 3]; - /* - * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the - * loop. - */ - for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { - for (int bits = 0; bits < BITS.length; ++bits) { - if (ascii[jj - bits] == '1') { - l_raw[ii] |= BITS[bits]; - } - } - } - return l_raw; - } - - /** - * Decodes a byte array where each byte represents an ascii '0' or '1'. - * - * @param ascii - * each byte represents an ascii '0' or '1' - * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument - */ - public static byte[] fromAscii(byte[] ascii) { - if (ascii == null || ascii.length == 0) { - return EMPTY_BYTE_ARRAY; - } - // get length/8 times bytes with 3 bit shifts to the right of the length - byte[] l_raw = new byte[ascii.length >> 3]; - /* - * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the - * loop. - */ - for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { - for (int bits = 0; bits < BITS.length; ++bits) { - if (ascii[jj - bits] == '1') { - l_raw[ii] |= BITS[bits]; - } - } - } - return l_raw; - } - - /** - * Converts an array of raw binary data into an array of ascii 0 and 1 character bytes - each byte is a truncated - * char. - * - * @param raw - * the raw binary data to convert - * @return an array of 0 and 1 character bytes for each bit of the argument - * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) - */ - public static byte[] toAsciiBytes(byte[] raw) { - if (raw == null || raw.length == 0) { - return EMPTY_BYTE_ARRAY; - } - // get 8 times the bytes with 3 bit shifts to the left of the length - byte[] l_ascii = new byte[raw.length << 3]; - /* - * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the - * loop. - */ - for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { - for (int bits = 0; bits < BITS.length; ++bits) { - if ((raw[ii] & BITS[bits]) == 0) { - l_ascii[jj - bits] = '0'; - } else { - l_ascii[jj - bits] = '1'; - } - } - } - return l_ascii; - } - - /** - * Converts an array of raw binary data into an array of ascii 0 and 1 characters. - * - * @param raw - * the raw binary data to convert - * @return an array of 0 and 1 characters for each bit of the argument - * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) - */ - public static char[] toAsciiChars(byte[] raw) { - if (raw == null || raw.length == 0) { - return EMPTY_CHAR_ARRAY; - } - // get 8 times the bytes with 3 bit shifts to the left of the length - char[] l_ascii = new char[raw.length << 3]; - /* - * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the - * loop. - */ - for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { - for (int bits = 0; bits < BITS.length; ++bits) { - if ((raw[ii] & BITS[bits]) == 0) { - l_ascii[jj - bits] = '0'; - } else { - l_ascii[jj - bits] = '1'; - } - } - } - return l_ascii; - } - - /** - * Converts an array of raw binary data into a String of ascii 0 and 1 characters. - * - * @param raw - * the raw binary data to convert - * @return a String of 0 and 1 characters representing the binary data - * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) - */ - public static String toAsciiString(byte[] raw) { - return new String(toAsciiChars(raw)); - } -} diff --git a/src/org/apache/commons/codec/binary/Hex.java b/src/org/apache/commons/codec/binary/Hex.java deleted file mode 100644 index 78f5510750f7abbcb57c52d21826130782bf0ac1..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/binary/Hex.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.binary; - -import org.apache.commons.codec.BinaryDecoder; -import org.apache.commons.codec.BinaryEncoder; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.EncoderException; - -/** - * Hex encoder and decoder. - * - * @since 1.1 - * @author Apache Software Foundation - * @version $Id: Hex.java,v 1.13 2004/04/18 18:22:33 ggregory Exp $ - */ -public class Hex implements BinaryEncoder, BinaryDecoder { - - /** - * Used building output as Hex - */ - private static final char[] DIGITS = { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - - /** - * Converts an array of characters representing hexidecimal values into an - * array of bytes of those same values. The returned array will be half the - * length of the passed array, as it takes two characters to represent any - * given byte. An exception is thrown if the passed char array has an odd - * number of elements. - * - * @param data An array of characters containing hexidecimal digits - * @return A byte array containing binary data decoded from - * the supplied char array. - * @throws DecoderException Thrown if an odd number or illegal of characters - * is supplied - */ - public static byte[] decodeHex(char[] data) throws DecoderException { - - int len = data.length; - - if ((len & 0x01) != 0) { - throw new DecoderException("Odd number of characters."); - } - - byte[] out = new byte[len >> 1]; - - // two characters form the hex value. - for (int i = 0, j = 0; j < len; i++) { - int f = toDigit(data[j], j) << 4; - j++; - f = f | toDigit(data[j], j); - j++; - out[i] = (byte) (f & 0xFF); - } - - return out; - } - - /** - * Converts a hexadecimal character to an integer. - * - * @param ch A character to convert to an integer digit - * @param index The index of the character in the source - * @return An integer - * @throws DecoderException Thrown if ch is an illegal hex character - */ - protected static int toDigit(char ch, int index) throws DecoderException { - int digit = Character.digit(ch, 16); - if (digit == -1) { - throw new DecoderException("Illegal hexadecimal charcter " + ch + " at index " + index); - } - return digit; - } - - /** - * Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order. - * The returned array will be double the length of the passed array, as it takes two characters to represent any - * given byte. - * - * @param data - * a byte[] to convert to Hex characters - * @return A char[] containing hexidecimal characters - */ - public static char[] encodeHex(byte[] data) { - - int l = data.length; - - char[] out = new char[l << 1]; - - // two characters form the hex value. - for (int i = 0, j = 0; i < l; i++) { - out[j++] = DIGITS[(0xF0 & data[i]) >>> 4 ]; - out[j++] = DIGITS[ 0x0F & data[i] ]; - } - - return out; - } - - /** - * Converts an array of character bytes representing hexidecimal values into an - * array of bytes of those same values. The returned array will be half the - * length of the passed array, as it takes two characters to represent any - * given byte. An exception is thrown if the passed char array has an odd - * number of elements. - * - * @param array An array of character bytes containing hexidecimal digits - * @return A byte array containing binary data decoded from - * the supplied byte array (representing characters). - * @throws DecoderException Thrown if an odd number of characters is supplied - * to this function - * @see #decodeHex(char[]) - */ - public byte[] decode(byte[] array) throws DecoderException { - return decodeHex(new String(array).toCharArray()); - } - - /** - * Converts a String or an array of character bytes representing hexidecimal values into an - * array of bytes of those same values. The returned array will be half the - * length of the passed String or array, as it takes two characters to represent any - * given byte. An exception is thrown if the passed char array has an odd - * number of elements. - * - * @param object A String or, an array of character bytes containing hexidecimal digits - * @return A byte array containing binary data decoded from - * the supplied byte array (representing characters). - * @throws DecoderException Thrown if an odd number of characters is supplied - * to this function or the object is not a String or char[] - * @see #decodeHex(char[]) - */ - public Object decode(Object object) throws DecoderException { - try { - char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; - return decodeHex(charArray); - } catch (ClassCastException e) { - throw new DecoderException(e.getMessage()); - } - } - - /** - * Converts an array of bytes into an array of bytes for the characters representing the - * hexidecimal values of each byte in order. The returned array will be - * double the length of the passed array, as it takes two characters to - * represent any given byte. - * - * @param array a byte[] to convert to Hex characters - * @return A byte[] containing the bytes of the hexidecimal characters - * @see #encodeHex(byte[]) - */ - public byte[] encode(byte[] array) { - return new String(encodeHex(array)).getBytes(); - } - - /** - * Converts a String or an array of bytes into an array of characters representing the - * hexidecimal values of each byte in order. The returned array will be - * double the length of the passed String or array, as it takes two characters to - * represent any given byte. - * - * @param object a String, or byte[] to convert to Hex characters - * @return A char[] containing hexidecimal characters - * @throws EncoderException Thrown if the given object is not a String or byte[] - * @see #encodeHex(byte[]) - */ - public Object encode(Object object) throws EncoderException { - try { - byte[] byteArray = object instanceof String ? ((String) object).getBytes() : (byte[]) object; - return encodeHex(byteArray); - } catch (ClassCastException e) { - throw new EncoderException(e.getMessage()); - } - } - -} - diff --git a/src/org/apache/commons/codec/binary/package.html b/src/org/apache/commons/codec/binary/package.html deleted file mode 100644 index 844d91809cd6937f2c1a7d93de8e25ed401ad48d..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/binary/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Base64, Binary, and Hexadecimal String encoding and decoding. - - diff --git a/src/org/apache/commons/codec/language/DoubleMetaphone.java b/src/org/apache/commons/codec/language/DoubleMetaphone.java deleted file mode 100644 index 1cad99154f5a6a5a64f6b05fb315f553b3096b21..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/language/DoubleMetaphone.java +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.language; - -import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.StringEncoder; - -/** - * Encodes a string into a double metaphone value. - * This Implementation is based on the algorithm by Lawrence Philips. - *obj is a String (like Metaphone).
- *
- * @param obj Object to encode (should be of type String)
- * @return An encoded Object (will be of type String)
- * @throws EncoderException encode parameter is not of type String
- */
- public Object encode(Object obj) throws EncoderException {
- if (!(obj instanceof String)) {
- throw new EncoderException("DoubleMetaphone encode parameter is not of type String");
- }
- return doubleMetaphone((String) obj);
- }
-
- /**
- * Encode the value using DoubleMetaphone.
- *
- * @param value String to encode
- * @return An encoded String
- */
- public String encode(String value) {
- return doubleMetaphone(value);
- }
-
- /**
- * Check if the Double Metaphone values of two String values
- * are equal.
- *
- * @param value1 The left-hand side of the encoded {@link String#equals(Object)}.
- * @param value2 The right-hand side of the encoded {@link String#equals(Object)}.
- * @return true if the encoded Strings are equal;
- * false otherwise.
- * @see #isDoubleMetaphoneEqual(String,String,boolean)
- */
- public boolean isDoubleMetaphoneEqual(String value1, String value2) {
- return isDoubleMetaphoneEqual(value1, value2, false);
- }
-
- /**
- * Check if the Double Metaphone values of two String values
- * are equal, optionally using the alternate value.
- *
- * @param value1 The left-hand side of the encoded {@link String#equals(Object)}.
- * @param value2 The right-hand side of the encoded {@link String#equals(Object)}.
- * @param alternate use the alternate value if true.
- * @return true if the encoded Strings are equal;
- * false otherwise.
- */
- public boolean isDoubleMetaphoneEqual(String value1,
- String value2,
- boolean alternate) {
- return doubleMetaphone(value1, alternate).equals(doubleMetaphone
- (value2, alternate));
- }
-
- /**
- * Returns the maxCodeLen.
- * @return int
- */
- public int getMaxCodeLen() {
- return this.maxCodeLen;
- }
-
- /**
- * Sets the maxCodeLen.
- * @param maxCodeLen The maxCodeLen to set
- */
- public void setMaxCodeLen(int maxCodeLen) {
- this.maxCodeLen = maxCodeLen;
- }
-
- //-- BEGIN HANDLERS --//
-
- /**
- * Handles 'A', 'E', 'I', 'O', 'U', and 'Y' cases
- */
- private int handleAEIOUY(String value, DoubleMetaphoneResult result, int
- index) {
- if (index == 0) {
- result.append('A');
- }
- return index + 1;
- }
-
- /**
- * Handles 'C' cases
- */
- private int handleC(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (conditionC0(value, index)) { // very confusing, moved out
- result.append('K');
- index += 2;
- } else if (index == 0 && contains(value, index, 6, "CAESAR")) {
- result.append('S');
- index += 2;
- } else if (contains(value, index, 2, "CH")) {
- index = handleCH(value, result, index);
- } else if (contains(value, index, 2, "CZ") &&
- !contains(value, index - 2, 4, "WICZ")) {
- //-- "Czerny" --//
- result.append('S', 'X');
- index += 2;
- } else if (contains(value, index + 1, 3, "CIA")) {
- //-- "focaccia" --//
- result.append('X');
- index += 3;
- } else if (contains(value, index, 2, "CC") &&
- !(index == 1 && charAt(value, 0) == 'M')) {
- //-- double "cc" but not "McClelland" --//
- return handleCC(value, result, index);
- } else if (contains(value, index, 2, "CK", "CG", "CQ")) {
- result.append('K');
- index += 2;
- } else if (contains(value, index, 2, "CI", "CE", "CY")) {
- //-- Italian vs. English --//
- if (contains(value, index, 3, "CIO", "CIE", "CIA")) {
- result.append('S', 'X');
- } else {
- result.append('S');
- }
- index += 2;
- } else {
- result.append('K');
- if (contains(value, index + 1, 2, " C", " Q", " G")) {
- //-- Mac Caffrey, Mac Gregor --//
- index += 3;
- } else if (contains(value, index + 1, 1, "C", "K", "Q") &&
- !contains(value, index + 1, 2, "CE", "CI")) {
- index += 2;
- } else {
- index++;
- }
- }
-
- return index;
- }
-
- /**
- * Handles 'CC' cases
- */
- private int handleCC(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (contains(value, index + 2, 1, "I", "E", "H") &&
- !contains(value, index + 2, 2, "HU")) {
- //-- "bellocchio" but not "bacchus" --//
- if ((index == 1 && charAt(value, index - 1) == 'A') ||
- contains(value, index - 1, 5, "UCCEE", "UCCES")) {
- //-- "accident", "accede", "succeed" --//
- result.append("KS");
- } else {
- //-- "bacci", "bertucci", other Italian --//
- result.append('X');
- }
- index += 3;
- } else { // Pierce's rule
- result.append('K');
- index += 2;
- }
-
- return index;
- }
-
- /**
- * Handles 'CH' cases
- */
- private int handleCH(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (index > 0 && contains(value, index, 4, "CHAE")) { // Michael
- result.append('K', 'X');
- return index + 2;
- } else if (conditionCH0(value, index)) {
- //-- Greek roots ("chemistry", "chorus", etc.) --//
- result.append('K');
- return index + 2;
- } else if (conditionCH1(value, index)) {
- //-- Germanic, Greek, or otherwise 'ch' for 'kh' sound --//
- result.append('K');
- return index + 2;
- } else {
- if (index > 0) {
- if (contains(value, 0, 2, "MC")) {
- result.append('K');
- } else {
- result.append('X', 'K');
- }
- } else {
- result.append('X');
- }
- return index + 2;
- }
- }
-
- /**
- * Handles 'D' cases
- */
- private int handleD(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (contains(value, index, 2, "DG")) {
- //-- "Edge" --//
- if (contains(value, index + 2, 1, "I", "E", "Y")) {
- result.append('J');
- index += 3;
- //-- "Edgar" --//
- } else {
- result.append("TK");
- index += 2;
- }
- } else if (contains(value, index, 2, "DT", "DD")) {
- result.append('T');
- index += 2;
- } else {
- result.append('T');
- index++;
- }
- return index;
- }
-
- /**
- * Handles 'G' cases
- */
- private int handleG(String value,
- DoubleMetaphoneResult result,
- int index,
- boolean slavoGermanic) {
- if (charAt(value, index + 1) == 'H') {
- index = handleGH(value, result, index);
- } else if (charAt(value, index + 1) == 'N') {
- if (index == 1 && isVowel(charAt(value, 0)) && !slavoGermanic) {
- result.append("KN", "N");
- } else if (!contains(value, index + 2, 2, "EY") &&
- charAt(value, index + 1) != 'Y' && !slavoGermanic) {
- result.append("N", "KN");
- } else {
- result.append("KN");
- }
- index = index + 2;
- } else if (contains(value, index + 1, 2, "LI") && !slavoGermanic) {
- result.append("KL", "L");
- index += 2;
- } else if (index == 0 && (charAt(value, index + 1) == 'Y' || contains(value, index + 1, 2, ES_EP_EB_EL_EY_IB_IL_IN_IE_EI_ER))) {
- //-- -ges-, -gep-, -gel-, -gie- at beginning --//
- result.append('K', 'J');
- index += 2;
- } else if ((contains(value, index + 1, 2, "ER") ||
- charAt(value, index + 1) == 'Y') &&
- !contains(value, 0, 6, "DANGER", "RANGER", "MANGER") &&
- !contains(value, index - 1, 1, "E", "I") &&
- !contains(value, index - 1, 3, "RGY", "OGY")) {
- //-- -ger-, -gy- --//
- result.append('K', 'J');
- index += 2;
- } else if (contains(value, index + 1, 1, "E", "I", "Y") ||
- contains(value, index - 1, 4, "AGGI", "OGGI")) {
- //-- Italian "biaggi" --//
- if ((contains(value, 0 ,4, "VAN ", "VON ") || contains(value, 0, 3, "SCH")) || contains(value, index + 1, 2, "ET")) {
- //-- obvious germanic --//
- result.append('K');
- } else if (contains(value, index + 1, 4, "IER")) {
- result.append('J');
- } else {
- result.append('J', 'K');
- }
- index += 2;
- } else if (charAt(value, index + 1) == 'G') {
- index += 2;
- result.append('K');
- } else {
- index++;
- result.append('K');
- }
- return index;
- }
-
- /**
- * Handles 'GH' cases
- */
- private int handleGH(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (index > 0 && !isVowel(charAt(value, index - 1))) {
- result.append('K');
- index += 2;
- } else if (index == 0) {
- if (charAt(value, index + 2) == 'I') {
- result.append('J');
- } else {
- result.append('K');
- }
- index += 2;
- } else if ((index > 1 && contains(value, index - 2, 1, "B", "H", "D")) ||
- (index > 2 && contains(value, index - 3, 1, "B", "H", "D")) ||
- (index > 3 && contains(value, index - 4, 1, "B", "H"))) {
- //-- Parker's rule (with some further refinements) - "hugh"
- index += 2;
- } else {
- if (index > 2 && charAt(value, index - 1) == 'U' &&
- contains(value, index - 3, 1, "C", "G", "L", "R", "T")) {
- //-- "laugh", "McLaughlin", "cough", "gough", "rough", "tough"
- result.append('F');
- } else if (index > 0 && charAt(value, index - 1) != 'I') {
- result.append('K');
- }
- index += 2;
- }
- return index;
- }
-
- /**
- * Handles 'H' cases
- */
- private int handleH(String value,
- DoubleMetaphoneResult result,
- int index) {
- //-- only keep if first & before vowel or between 2 vowels --//
- if ((index == 0 || isVowel(charAt(value, index - 1))) &&
- isVowel(charAt(value, index + 1))) {
- result.append('H');
- index += 2;
- //-- also takes car of "HH" --//
- } else {
- index++;
- }
- return index;
- }
-
- /**
- * Handles 'J' cases
- */
- private int handleJ(String value, DoubleMetaphoneResult result, int index,
- boolean slavoGermanic) {
- if (contains(value, index, 4, "JOSE") || contains(value, 0, 4, "SAN ")) {
- //-- obvious Spanish, "Jose", "San Jacinto" --//
- if ((index == 0 && (charAt(value, index + 4) == ' ') ||
- value.length() == 4) || contains(value, 0, 4, "SAN ")) {
- result.append('H');
- } else {
- result.append('J', 'H');
- }
- index++;
- } else {
- if (index == 0 && !contains(value, index, 4, "JOSE")) {
- result.append('J', 'A');
- } else if (isVowel(charAt(value, index - 1)) && !slavoGermanic &&
- (charAt(value, index + 1) == 'A' || charAt(value, index + 1) == 'O')) {
- result.append('J', 'H');
- } else if (index == value.length() - 1) {
- result.append('J', ' ');
- } else if (!contains(value, index + 1, 1, L_T_K_S_N_M_B_Z) && !contains(value, index - 1, 1, "S", "K", "L")) {
- result.append('J');
- }
-
- if (charAt(value, index + 1) == 'J') {
- index += 2;
- } else {
- index++;
- }
- }
- return index;
- }
-
- /**
- * Handles 'L' cases
- */
- private int handleL(String value,
- DoubleMetaphoneResult result,
- int index) {
- result.append('L');
- if (charAt(value, index + 1) == 'L') {
- if (conditionL0(value, index)) {
- result.appendAlternate(' ');
- }
- index += 2;
- } else {
- index++;
- }
- return index;
- }
-
- /**
- * Handles 'P' cases
- */
- private int handleP(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (charAt(value, index + 1) == 'H') {
- result.append('F');
- index += 2;
- } else {
- result.append('P');
- index = contains(value, index + 1, 1, "P", "B") ? index + 2 : index + 1;
- }
- return index;
- }
-
- /**
- * Handles 'R' cases
- */
- private int handleR(String value,
- DoubleMetaphoneResult result,
- int index,
- boolean slavoGermanic) {
- if (index == value.length() - 1 && !slavoGermanic &&
- contains(value, index - 2, 2, "IE") &&
- !contains(value, index - 4, 2, "ME", "MA")) {
- result.appendAlternate('R');
- } else {
- result.append('R');
- }
- return charAt(value, index + 1) == 'R' ? index + 2 : index + 1;
- }
-
- /**
- * Handles 'S' cases
- */
- private int handleS(String value,
- DoubleMetaphoneResult result,
- int index,
- boolean slavoGermanic) {
- if (contains(value, index - 1, 3, "ISL", "YSL")) {
- //-- special cases "island", "isle", "carlisle", "carlysle" --//
- index++;
- } else if (index == 0 && contains(value, index, 5, "SUGAR")) {
- //-- special case "sugar-" --//
- result.append('X', 'S');
- index++;
- } else if (contains(value, index, 2, "SH")) {
- if (contains(value, index + 1, 4,
- "HEIM", "HOEK", "HOLM", "HOLZ")) {
- //-- germanic --//
- result.append('S');
- } else {
- result.append('X');
- }
- index += 2;
- } else if (contains(value, index, 3, "SIO", "SIA") || contains(value, index, 4, "SIAN")) {
- //-- Italian and Armenian --//
- if (slavoGermanic) {
- result.append('S');
- } else {
- result.append('S', 'X');
- }
- index += 3;
- } else if ((index == 0 && contains(value, index + 1, 1, "M", "N", "L", "W")) || contains(value, index + 1, 1, "Z")) {
- //-- german & anglicisations, e.g. "smith" match "schmidt" //
- // "snider" match "schneider" --//
- //-- also, -sz- in slavic language altho in hungarian it //
- // is pronounced "s" --//
- result.append('S', 'X');
- index = contains(value, index + 1, 1, "Z") ? index + 2 : index + 1;
- } else if (contains(value, index, 2, "SC")) {
- index = handleSC(value, result, index);
- } else {
- if (index == value.length() - 1 && contains(value, index - 2,
- 2, "AI", "OI")){
- //-- french e.g. "resnais", "artois" --//
- result.appendAlternate('S');
- } else {
- result.append('S');
- }
- index = contains(value, index + 1, 1, "S", "Z") ? index + 2 : index + 1;
- }
- return index;
- }
-
- /**
- * Handles 'SC' cases
- */
- private int handleSC(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (charAt(value, index + 2) == 'H') {
- //-- Schlesinger's rule --//
- if (contains(value, index + 3,
- 2, "OO", "ER", "EN", "UY", "ED", "EM")) {
- //-- Dutch origin, e.g. "school", "schooner" --//
- if (contains(value, index + 3, 2, "ER", "EN")) {
- //-- "schermerhorn", "schenker" --//
- result.append("X", "SK");
- } else {
- result.append("SK");
- }
- } else {
- if (index == 0 && !isVowel(charAt(value, 3)) && charAt(value, 3) != 'W') {
- result.append('X', 'S');
- } else {
- result.append('X');
- }
- }
- } else if (contains(value, index + 2, 1, "I", "E", "Y")) {
- result.append('S');
- } else {
- result.append("SK");
- }
- return index + 3;
- }
-
- /**
- * Handles 'T' cases
- */
- private int handleT(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (contains(value, index, 4, "TION")) {
- result.append('X');
- index += 3;
- } else if (contains(value, index, 3, "TIA", "TCH")) {
- result.append('X');
- index += 3;
- } else if (contains(value, index, 2, "TH") || contains(value, index,
- 3, "TTH")) {
- if (contains(value, index + 2, 2, "OM", "AM") ||
- //-- special case "thomas", "thames" or germanic --//
- contains(value, 0, 4, "VAN ", "VON ") ||
- contains(value, 0, 3, "SCH")) {
- result.append('T');
- } else {
- result.append('0', 'T');
- }
- index += 2;
- } else {
- result.append('T');
- index = contains(value, index + 1, 1, "T", "D") ? index + 2 : index + 1;
- }
- return index;
- }
-
- /**
- * Handles 'W' cases
- */
- private int handleW(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (contains(value, index, 2, "WR")) {
- //-- can also be in middle of word --//
- result.append('R');
- index += 2;
- } else {
- if (index == 0 && (isVowel(charAt(value, index + 1)) ||
- contains(value, index, 2, "WH"))) {
- if (isVowel(charAt(value, index + 1))) {
- //-- Wasserman should match Vasserman --//
- result.append('A', 'F');
- } else {
- //-- need Uomo to match Womo --//
- result.append('A');
- }
- index++;
- } else if ((index == value.length() - 1 && isVowel(charAt(value, index - 1))) ||
- contains(value, index - 1,
- 5, "EWSKI", "EWSKY", "OWSKI", "OWSKY") ||
- contains(value, 0, 3, "SCH")) {
- //-- Arnow should match Arnoff --//
- result.appendAlternate('F');
- index++;
- } else if (contains(value, index, 4, "WICZ", "WITZ")) {
- //-- Polish e.g. "filipowicz" --//
- result.append("TS", "FX");
- index += 4;
- } else {
- index++;
- }
- }
- return index;
- }
-
- /**
- * Handles 'X' cases
- */
- private int handleX(String value,
- DoubleMetaphoneResult result,
- int index) {
- if (index == 0) {
- result.append('S');
- index++;
- } else {
- if (!((index == value.length() - 1) &&
- (contains(value, index - 3, 3, "IAU", "EAU") ||
- contains(value, index - 2, 2, "AU", "OU")))) {
- //-- French e.g. breaux --//
- result.append("KS");
- }
- index = contains(value, index + 1, 1, "C", "X") ? index + 2 : index + 1;
- }
- return index;
- }
-
- /**
- * Handles 'Z' cases
- */
- private int handleZ(String value, DoubleMetaphoneResult result, int index,
- boolean slavoGermanic) {
- if (charAt(value, index + 1) == 'H') {
- //-- Chinese pinyin e.g. "zhao" or Angelina "Zhang" --//
- result.append('J');
- index += 2;
- } else {
- if (contains(value, index + 1, 2, "ZO", "ZI", "ZA") || (slavoGermanic && (index > 0 && charAt(value, index - 1) != 'T'))) {
- result.append("S", "TS");
- } else {
- result.append('S');
- }
- index = charAt(value, index + 1) == 'Z' ? index + 2 : index + 1;
- }
- return index;
- }
-
- //-- BEGIN CONDITIONS --//
-
- /**
- * Complex condition 0 for 'C'
- */
- private boolean conditionC0(String value, int index) {
- if (contains(value, index, 4, "CHIA")) {
- return true;
- } else if (index <= 1) {
- return false;
- } else if (isVowel(charAt(value, index - 2))) {
- return false;
- } else if (!contains(value, index - 1, 3, "ACH")) {
- return false;
- } else {
- char c = charAt(value, index + 2);
- return (c != 'I' && c != 'E')
- || contains(value, index - 2, 6, "BACHER", "MACHER");
- }
- }
-
- /**
- * Complex condition 0 for 'CH'
- */
- private boolean conditionCH0(String value, int index) {
- if (index != 0) {
- return false;
- } else if (!contains(value, index + 1, 5, "HARAC", "HARIS") &&
- !contains(value, index + 1, 3, "HOR", "HYM", "HIA", "HEM")) {
- return false;
- } else if (contains(value, 0, 5, "CHORE")) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Complex condition 1 for 'CH'
- */
- private boolean conditionCH1(String value, int index) {
- return ((contains(value, 0, 4, "VAN ", "VON ") || contains(value, 0,
- 3, "SCH")) ||
- contains(value, index - 2, 6, "ORCHES", "ARCHIT", "ORCHID") ||
- contains(value, index + 2, 1, "T", "S") ||
- ((contains(value, index - 1, 1, "A", "O", "U", "E") || index == 0) &&
- (contains(value, index + 2, 1, L_R_N_M_B_H_F_V_W_SPACE) || index + 1 == value.length() - 1)));
- }
-
- /**
- * Complex condition 0 for 'L'
- */
- private boolean conditionL0(String value, int index) {
- if (index == value.length() - 3 &&
- contains(value, index - 1, 4, "ILLO", "ILLA", "ALLE")) {
- return true;
- } else if ((contains(value, index - 1, 2, "AS", "OS") ||
- contains(value, value.length() - 1, 1, "A", "O")) &&
- contains(value, index - 1, 4, "ALLE")) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Complex condition 0 for 'M'
- */
- private boolean conditionM0(String value, int index) {
- if (charAt(value, index + 1) == 'M') {
- return true;
- }
- return contains(value, index - 1, 3, "UMB")
- && ((index + 1) == value.length() - 1 || contains(value,
- index + 2, 2, "ER"));
- }
-
- //-- BEGIN HELPER FUNCTIONS --//
-
- /**
- * Determines whether or not a value is of slavo-germanic orgin. A value is
- * of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'.
- */
- private boolean isSlavoGermanic(String value) {
- return value.indexOf('W') > -1 || value.indexOf('K') > -1 ||
- value.indexOf("CZ") > -1 || value.indexOf("WITZ") > -1;
- }
-
- /**
- * Determines whether or not a character is a vowel or not
- */
- private boolean isVowel(char ch) {
- return VOWELS.indexOf(ch) != -1;
- }
-
- /**
- * Determines whether or not the value starts with a silent letter. It will
- * return true if the value starts with any of 'GN', 'KN',
- * 'PN', 'WR' or 'PS'.
- */
- private boolean isSilentStart(String value) {
- boolean result = false;
- for (int i = 0; i < SILENT_START.length; i++) {
- if (value.startsWith(SILENT_START[i])) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- /**
- * Cleans the input
- */
- private String cleanInput(String input) {
- if (input == null) {
- return null;
- }
- input = input.trim();
- if (input.length() == 0) {
- return null;
- }
- return input.toUpperCase();
- }
-
- /**
- * Gets the character at index index if available, otherwise
- * it returns Character.MIN_VALUE so that there is some sort
- * of a default
- */
- protected char charAt(String value, int index) {
- if (index < 0 || index >= value.length()) {
- return Character.MIN_VALUE;
- }
- return value.charAt(index);
- }
-
- /**
- * Shortcut method with 1 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria) {
- return contains(value, start, length,
- new String[] { criteria });
- }
-
- /**
- * Shortcut method with 2 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria1, String criteria2) {
- return contains(value, start, length,
- new String[] { criteria1, criteria2 });
- }
-
- /**
- * Shortcut method with 3 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria1, String criteria2,
- String criteria3) {
- return contains(value, start, length,
- new String[] { criteria1, criteria2, criteria3 });
- }
-
- /**
- * Shortcut method with 4 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria1, String criteria2,
- String criteria3, String criteria4) {
- return contains(value, start, length,
- new String[] { criteria1, criteria2, criteria3,
- criteria4 });
- }
-
- /**
- * Shortcut method with 5 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria1, String criteria2,
- String criteria3, String criteria4,
- String criteria5) {
- return contains(value, start, length,
- new String[] { criteria1, criteria2, criteria3,
- criteria4, criteria5 });
- }
-
- /**
- * Shortcut method with 6 criteria
- */
- private static boolean contains(String value, int start, int length,
- String criteria1, String criteria2,
- String criteria3, String criteria4,
- String criteria5, String criteria6) {
- return contains(value, start, length,
- new String[] { criteria1, criteria2, criteria3,
- criteria4, criteria5, criteria6 });
- }
-
- /**
- * Determines whether value contains any of the criteria
- starting
- * at index start and matching up to length length
- */
- protected static boolean contains(String value, int start, int length,
- String[] criteria) {
- boolean result = false;
- if (start >= 0 && start + length <= value.length()) {
- String target = value.substring(start, start + length);
-
- for (int i = 0; i < criteria.length; i++) {
- if (target.equals(criteria[i])) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- //-- BEGIN INNER CLASSES --//
-
- /**
- * Inner class for storing results, since there is the optional alternate
- * encoding.
- */
- public class DoubleMetaphoneResult {
-
- private StringBuffer primary = new StringBuffer(getMaxCodeLen());
- private StringBuffer alternate = new StringBuffer(getMaxCodeLen());
- private int maxLength;
-
- public DoubleMetaphoneResult(int maxLength) {
- this.maxLength = maxLength;
- }
-
- public void append(char value) {
- appendPrimary(value);
- appendAlternate(value);
- }
-
- public void append(char primary, char alternate) {
- appendPrimary(primary);
- appendAlternate(alternate);
- }
-
- public void appendPrimary(char value) {
- if (this.primary.length() < this.maxLength) {
- this.primary.append(value);
- }
- }
-
- public void appendAlternate(char value) {
- if (this.alternate.length() < this.maxLength) {
- this.alternate.append(value);
- }
- }
-
- public void append(String value) {
- appendPrimary(value);
- appendAlternate(value);
- }
-
- public void append(String primary, String alternate) {
- appendPrimary(primary);
- appendAlternate(alternate);
- }
-
- public void appendPrimary(String value) {
- int addChars = this.maxLength - this.primary.length();
- if (value.length() <= addChars) {
- this.primary.append(value);
- } else {
- this.primary.append(value.substring(0, addChars));
- }
- }
-
- public void appendAlternate(String value) {
- int addChars = this.maxLength - this.alternate.length();
- if (value.length() <= addChars) {
- this.alternate.append(value);
- } else {
- this.alternate.append(value.substring(0, addChars));
- }
- }
-
- public String getPrimary() {
- return this.primary.toString();
- }
-
- public String getAlternate() {
- return this.alternate.toString();
- }
-
- public boolean isComplete() {
- return this.primary.length() >= this.maxLength &&
- this.alternate.length() >= this.maxLength;
- }
- }
-}
diff --git a/src/org/apache/commons/codec/language/Metaphone.java b/src/org/apache/commons/codec/language/Metaphone.java
deleted file mode 100644
index dce2c727bcdd741c6322e0786fcce0f1b86d8b93..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/language/Metaphone.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec.language;
-
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.StringEncoder;
-
-/**
- * Encodes a string into a metaphone value.
- * - * Initial Java implementation by William B. Brogden. December, 1997. - * Permission given by wbrogden for code to be used anywhere. - *
- *- * Hanging on the Metaphone by Lawrence Philips in Computer Language of Dec. 1990, p - * 39. - *
- * - * @author Apache Software Foundation - * @version $Id: Metaphone.java,v 1.20 2004/06/05 18:32:04 ggregory Exp $ - */ -public class Metaphone implements StringEncoder { - - /** - * Five values in the English language - */ - private String vowels = "AEIOU" ; - - /** - * Variable used in Metaphone algorithm - */ - private String frontv = "EIY" ; - - /** - * Variable used in Metaphone algorithm - */ - private String varson = "CSPTG" ; - - /** - * The max code length for metaphone is 4 - */ - private int maxCodeLen = 4 ; - - /** - * Creates an instance of the Metaphone encoder - */ - public Metaphone() { - super(); - } - - /** - * Find the metaphone value of a String. This is similar to the - * soundex algorithm, but better at finding similar sounding words. - * All input is converted to upper case. - * Limitations: Input format is expected to be a single ASCII word - * with only characters in the A - Z range, no punctuation or numbers. - * - * @param txt String to find the metaphone code for - * @return A metaphone code corresponding to the String supplied - */ - public String metaphone(String txt) { - boolean hard = false ; - if ((txt == null) || (txt.length() == 0)) { - return "" ; - } - // single character is itself - if (txt.length() == 1) { - return txt.toUpperCase() ; - } - - char[] inwd = txt.toUpperCase().toCharArray() ; - - StringBuffer local = new StringBuffer(40); // manipulate - StringBuffer code = new StringBuffer(10) ; // output - // handle initial 2 characters exceptions - switch(inwd[0]) { - case 'K' : - case 'G' : - case 'P' : /* looking for KN, etc*/ - if (inwd[1] == 'N') { - local.append(inwd, 1, inwd.length - 1); - } else { - local.append(inwd); - } - break; - case 'A': /* looking for AE */ - if (inwd[1] == 'E') { - local.append(inwd, 1, inwd.length - 1); - } else { - local.append(inwd); - } - break; - case 'W' : /* looking for WR or WH */ - if (inwd[1] == 'R') { // WR -> R - local.append(inwd, 1, inwd.length - 1); - break ; - } - if (inwd[1] == 'H') { - local.append(inwd, 1, inwd.length - 1); - local.setCharAt(0, 'W'); // WH -> W - } else { - local.append(inwd); - } - break; - case 'X' : /* initial X becomes S */ - inwd[0] = 'S'; - local.append(inwd); - break ; - default : - local.append(inwd); - } // now local has working string with initials fixed - - int wdsz = local.length(); - int n = 0 ; - - while ((code.length() < this.getMaxCodeLen()) && - (n < wdsz) ) { // max code size of 4 works well - char symb = local.charAt(n) ; - // remove duplicate letters except C - if ((symb != 'C') && (isPreviousChar( local, n, symb )) ) { - n++ ; - } else { // not dup - switch(symb) { - case 'A' : case 'E' : case 'I' : case 'O' : case 'U' : - if (n == 0) { - code.append(symb); - } - break ; // only use vowel if leading char - case 'B' : - if ( isPreviousChar(local, n, 'M') && - isLastChar(wdsz, n) ) { // B is silent if word ends in MB - break; - } - code.append(symb); - break; - case 'C' : // lots of C special cases - /* discard if SCI, SCE or SCY */ - if ( isPreviousChar(local, n, 'S') && - !isLastChar(wdsz, n) && - (this.frontv.indexOf(local.charAt(n + 1)) >= 0) ) { - break; - } - if (regionMatch(local, n, "CIA")) { // "CIA" -> X - code.append('X'); - break; - } - if (!isLastChar(wdsz, n) && - (this.frontv.indexOf(local.charAt(n + 1)) >= 0)) { - code.append('S'); - break; // CI,CE,CY -> S - } - if (isPreviousChar(local, n, 'S') && - isNextChar(local, n, 'H') ) { // SCH->sk - code.append('K') ; - break ; - } - if (isNextChar(local, n, 'H')) { // detect CH - if ((n == 0) && - (wdsz >= 3) && - isVowel(local,2) ) { // CH consonant -> K consonant - code.append('K'); - } else { - code.append('X'); // CHvowel -> X - } - } else { - code.append('K'); - } - break ; - case 'D' : - if (!isLastChar(wdsz, n + 1) && - isNextChar(local, n, 'G') && - (this.frontv.indexOf(local.charAt(n + 2)) >= 0)) { // DGE DGI DGY -> J - code.append('J'); n += 2 ; - } else { - code.append('T'); - } - break ; - case 'G' : // GH silent at end or before consonant - if (isLastChar(wdsz, n + 1) && - isNextChar(local, n, 'H')) { - break; - } - if (!isLastChar(wdsz, n + 1) && - isNextChar(local,n,'H') && - !isVowel(local,n+2)) { - break; - } - if ((n > 0) && - ( regionMatch(local, n, "GN") || - regionMatch(local, n, "GNED") ) ) { - break; // silent G - } - if (isPreviousChar(local, n, 'G')) { - hard = true ; - } else { - hard = false ; - } - if (!isLastChar(wdsz, n) && - (this.frontv.indexOf(local.charAt(n + 1)) >= 0) && - (!hard)) { - code.append('J'); - } else { - code.append('K'); - } - break ; - case 'H': - if (isLastChar(wdsz, n)) { - break ; // terminal H - } - if ((n > 0) && - (this.varson.indexOf(local.charAt(n - 1)) >= 0)) { - break; - } - if (isVowel(local,n+1)) { - code.append('H'); // Hvowel - } - break; - case 'F': - case 'J' : - case 'L' : - case 'M': - case 'N' : - case 'R' : - code.append(symb); - break; - case 'K' : - if (n > 0) { // not initial - if (!isPreviousChar(local, n, 'C')) { - code.append(symb); - } - } else { - code.append(symb); // initial K - } - break ; - case 'P' : - if (isNextChar(local,n,'H')) { - // PH -> F - code.append('F'); - } else { - code.append(symb); - } - break ; - case 'Q' : - code.append('K'); - break; - case 'S' : - if (regionMatch(local,n,"SH") || - regionMatch(local,n,"SIO") || - regionMatch(local,n,"SIA")) { - code.append('X'); - } else { - code.append('S'); - } - break; - case 'T' : - if (regionMatch(local,n,"TIA") || - regionMatch(local,n,"TIO")) { - code.append('X'); - break; - } - if (regionMatch(local,n,"TCH")) { - // Silent if in "TCH" - break; - } - // substitute numeral 0 for TH (resembles theta after all) - if (regionMatch(local,n,"TH")) { - code.append('0'); - } else { - code.append('T'); - } - break ; - case 'V' : - code.append('F'); break ; - case 'W' : case 'Y' : // silent if not followed by vowel - if (!isLastChar(wdsz,n) && - isVowel(local,n+1)) { - code.append(symb); - } - break ; - case 'X' : - code.append('K'); code.append('S'); - break ; - case 'Z' : - code.append('S'); break ; - } // end switch - n++ ; - } // end else from symb != 'C' - if (code.length() > this.getMaxCodeLen()) { - code.setLength(this.getMaxCodeLen()); - } - } - return code.toString(); - } - - private boolean isVowel(StringBuffer string, int index) { - return (this.vowels.indexOf(string.charAt(index)) >= 0); - } - - private boolean isPreviousChar(StringBuffer string, int index, char c) { - boolean matches = false; - if( index > 0 && - index < string.length() ) { - matches = string.charAt(index - 1) == c; - } - return matches; - } - - private boolean isNextChar(StringBuffer string, int index, char c) { - boolean matches = false; - if( index >= 0 && - index < string.length() - 1 ) { - matches = string.charAt(index + 1) == c; - } - return matches; - } - - private boolean regionMatch(StringBuffer string, int index, String test) { - boolean matches = false; - if( index >= 0 && - (index + test.length() - 1) < string.length() ) { - String substring = string.substring( index, index + test.length()); - matches = substring.equals( test ); - } - return matches; - } - - private boolean isLastChar(int wdsz, int n) { - return n + 1 == wdsz; - } - - - /** - * Encodes an Object using the metaphone algorithm. This method - * is provided in order to satisfy the requirements of the - * Encoder interface, and will throw an EncoderException if the - * supplied object is not of type java.lang.String. - * - * @param pObject Object to encode - * @return An object (or type java.lang.String) containing the - * metaphone code which corresponds to the String supplied. - * @throws EncoderException if the parameter supplied is not - * of type java.lang.String - */ - public Object encode(Object pObject) throws EncoderException { - if (!(pObject instanceof java.lang.String)) { - throw new EncoderException("Parameter supplied to Metaphone encode is not of type java.lang.String"); - } - return metaphone((String) pObject); - } - - /** - * Encodes a String using the Metaphone algorithm. - * - * @param pString String object to encode - * @return The metaphone code corresponding to the String supplied - */ - public String encode(String pString) { - return metaphone(pString); - } - - /** - * Tests is the metaphones of two strings are identical. - * - * @param str1 First of two strings to compare - * @param str2 Second of two strings to compare - * @return true if the metaphones of these strings are identical, - * false otherwise. - */ - public boolean isMetaphoneEqual(String str1, String str2) { - return metaphone(str1).equals(metaphone(str2)); - } - - /** - * Returns the maxCodeLen. - * @return int - */ - public int getMaxCodeLen() { return this.maxCodeLen; } - - /** - * Sets the maxCodeLen. - * @param maxCodeLen The maxCodeLen to set - */ - public void setMaxCodeLen(int maxCodeLen) { this.maxCodeLen = maxCodeLen; } - -} diff --git a/src/org/apache/commons/codec/language/RefinedSoundex.java b/src/org/apache/commons/codec/language/RefinedSoundex.java deleted file mode 100644 index dbf60fea22760b70c11570a0f1bc2a761f014508..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/language/RefinedSoundex.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.language; - -import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.StringEncoder; - -/** - * Encodes a string into a Refined Soundex value. A refined soundex code is - * optimized for spell checking words. Soundex method originally developed by - * Margaret Odell and Robert Russell. - * - * @author Apache Software Foundation - * @version $Id: RefinedSoundex.java,v 1.21 2004/06/05 18:32:04 ggregory Exp $ - */ -public class RefinedSoundex implements StringEncoder { - - /** - * This static variable contains an instance of the RefinedSoundex using - * the US_ENGLISH mapping. - */ - public static final RefinedSoundex US_ENGLISH = new RefinedSoundex(); - - /** - * RefinedSoundex is *refined* for a number of reasons one being that the - * mappings have been altered. This implementation contains default - * mappings for US English. - */ - public static final char[] US_ENGLISH_MAPPING = "01360240043788015936020505".toCharArray(); - - /** - * Every letter of the alphabet is "mapped" to a numerical value. This char - * array holds the values to which each letter is mapped. This - * implementation contains a default map for US_ENGLISH - */ - private char[] soundexMapping; - - /** - * Creates an instance of the RefinedSoundex object using the default US - * English mapping. - */ - public RefinedSoundex() { - this(US_ENGLISH_MAPPING); - } - - /** - * Creates a refined soundex instance using a custom mapping. This - * constructor can be used to customize the mapping, and/or possibly - * provide an internationalized mapping for a non-Western character set. - * - * @param mapping - * Mapping array to use when finding the corresponding code for - * a given character - */ - public RefinedSoundex(char[] mapping) { - this.soundexMapping = mapping; - } - - // BEGIN android-note - // Removed @see reference to SoundexUtils below, since the class isn't - // public. - // END android-note - /** - * Returns the number of characters in the two encoded Strings that are the - * same. This return value ranges from 0 to the length of the shortest - * encoded String: 0 indicates little or no similarity, and 4 out of 4 (for - * example) indicates strong similarity or identical values. For refined - * Soundex, the return value can be greater than 4. - * - * @param s1 - * A String that will be encoded and compared. - * @param s2 - * A String that will be encoded and compared. - * @return The number of characters in the two encoded Strings that are the - * same from 0 to to the length of the shortest encoded String. - * - * @see - * MS T-SQL DIFFERENCE - * - * @throws EncoderException - * if an error occurs encoding one of the strings - * @since 1.3 - */ - public int difference(String s1, String s2) throws EncoderException { - return SoundexUtils.difference(this, s1, s2); - } - - /** - * Encodes an Object using the refined soundex algorithm. This method is - * provided in order to satisfy the requirements of the Encoder interface, - * and will throw an EncoderException if the supplied object is not of type - * java.lang.String. - * - * @param pObject - * Object to encode - * @return An object (or type java.lang.String) containing the refined - * soundex code which corresponds to the String supplied. - * @throws EncoderException - * if the parameter supplied is not of type java.lang.String - */ - public Object encode(Object pObject) throws EncoderException { - if (!(pObject instanceof java.lang.String)) { - throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String"); - } - return soundex((String) pObject); - } - - /** - * Encodes a String using the refined soundex algorithm. - * - * @param pString - * A String object to encode - * @return A Soundex code corresponding to the String supplied - */ - public String encode(String pString) { - return soundex(pString); - } - - /** - * Returns the mapping code for a given character. The mapping codes are - * maintained in an internal char array named soundexMapping, and the - * default values of these mappings are US English. - * - * @param c - * char to get mapping for - * @return A character (really a numeral) to return for the given char - */ - char getMappingCode(char c) { - if (!Character.isLetter(c)) { - return 0; - } - return this.soundexMapping[Character.toUpperCase(c) - 'A']; - } - - /** - * Retreives the Refined Soundex code for a given String object. - * - * @param str - * String to encode using the Refined Soundex algorithm - * @return A soundex code for the String supplied - */ - public String soundex(String str) { - if (str == null) { - return null; - } - str = SoundexUtils.clean(str); - if (str.length() == 0) { - return str; - } - - StringBuffer sBuf = new StringBuffer(); - sBuf.append(str.charAt(0)); - - char last, current; - last = '*'; - - for (int i = 0; i < str.length(); i++) { - - current = getMappingCode(str.charAt(i)); - if (current == last) { - continue; - } else if (current != 0) { - sBuf.append(current); - } - - last = current; - - } - - return sBuf.toString(); - } -} diff --git a/src/org/apache/commons/codec/language/Soundex.java b/src/org/apache/commons/codec/language/Soundex.java deleted file mode 100644 index 61ce440ad2d32f3d7422a7ede01cee165bd3c280..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/language/Soundex.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.language; - -import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.StringEncoder; - -/** - * Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a - * general purpose scheme to find word with similar phonemes. - * - * @author Apache Software Foundation - * @version $Id: Soundex.java,v 1.26 2004/07/07 23:15:24 ggregory Exp $ - */ -public class Soundex implements StringEncoder { - - /** - * An instance of Soundex using the US_ENGLISH_MAPPING mapping. - * - * @see #US_ENGLISH_MAPPING - */ - public static final Soundex US_ENGLISH = new Soundex(); - - /** - * This is a default mapping of the 26 letters used in US English. A value of0 for a letter position
- * means do not encode.
- * - * (This constant is provided as both an implementation convenience and to allow Javadoc to pick - * up the value for the constant values page.) - *
- * - * @see #US_ENGLISH_MAPPING - */ - public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202"; - - /** - * This is a default mapping of the 26 letters used in US English. A value of0 for a letter position
- * means do not encode.
- *
- * @see Soundex#Soundex(char[])
- */
- public static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray();
-
- // BEGIN android-note
- // Removed @see reference to SoundexUtils below, since the class isn't
- // public.
- // END android-note
- /**
- * Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. This
- * return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or
- * identical values.
- *
- * @param s1
- * A String that will be encoded and compared.
- * @param s2
- * A String that will be encoded and compared.
- * @return The number of characters in the two encoded Strings that are the same from 0 to 4.
- *
- * @see MS
- * T-SQL DIFFERENCE
- *
- * @throws EncoderException
- * if an error occurs encoding one of the strings
- * @since 1.3
- */
- public int difference(String s1, String s2) throws EncoderException {
- return SoundexUtils.difference(this, s1, s2);
- }
-
- /**
- * The maximum length of a Soundex code - Soundex codes are only four characters by definition.
- *
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
- */
- private int maxLength = 4;
-
- /**
- * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
- * letter is mapped. This implementation contains a default map for US_ENGLISH
- */
- private char[] soundexMapping;
-
- /**
- * Creates an instance using US_ENGLISH_MAPPING
- *
- * @see Soundex#Soundex(char[])
- * @see Soundex#US_ENGLISH_MAPPING
- */
- public Soundex() {
- this(US_ENGLISH_MAPPING);
- }
-
- /**
- * Creates a soundex instance using the given mapping. This constructor can be used to provide an internationalized
- * mapping for a non-Western character set.
- *
- * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
- * letter is mapped. This implementation contains a default map for US_ENGLISH
- *
- * @param mapping
- * Mapping array to use when finding the corresponding code for a given character
- */
- public Soundex(char[] mapping) {
- this.setSoundexMapping(mapping);
- }
-
- /**
- * Encodes an Object using the soundex algorithm. This method is provided in order to satisfy the requirements of
- * the Encoder interface, and will throw an EncoderException if the supplied object is not of type java.lang.String.
- *
- * @param pObject
- * Object to encode
- * @return An object (or type java.lang.String) containing the soundex code which corresponds to the String
- * supplied.
- * @throws EncoderException
- * if the parameter supplied is not of type java.lang.String
- * @throws IllegalArgumentException
- * if a character is not mapped
- */
- public Object encode(Object pObject) throws EncoderException {
- if (!(pObject instanceof String)) {
- throw new EncoderException("Parameter supplied to Soundex encode is not of type java.lang.String");
- }
- return soundex((String) pObject);
- }
-
- /**
- * Encodes a String using the soundex algorithm.
- *
- * @param pString
- * A String object to encode
- * @return A Soundex code corresponding to the String supplied
- * @throws IllegalArgumentException
- * if a character is not mapped
- */
- public String encode(String pString) {
- return soundex(pString);
- }
-
- /**
- * Used internally by the SoundEx algorithm.
- *
- * Consonants from the same code group separated by W or H are treated as one.
- *
- * @param str
- * the cleaned working string to encode (in upper case).
- * @param index
- * the character position to encode
- * @return Mapping code for a particular character
- * @throws IllegalArgumentException
- * if the character is not mapped
- */
- private char getMappingCode(String str, int index) {
- char mappedChar = this.map(str.charAt(index));
- // HW rule check
- if (index > 1 && mappedChar != '0') {
- char hwChar = str.charAt(index - 1);
- if ('H' == hwChar || 'W' == hwChar) {
- char preHWChar = str.charAt(index - 2);
- char firstCode = this.map(preHWChar);
- if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) {
- return 0;
- }
- }
- }
- return mappedChar;
- }
-
- /**
- * Returns the maxLength. Standard Soundex
- *
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
- * @return int
- */
- public int getMaxLength() {
- return this.maxLength;
- }
-
- /**
- * Returns the soundex mapping.
- *
- * @return soundexMapping.
- */
- private char[] getSoundexMapping() {
- return this.soundexMapping;
- }
-
- /**
- * Maps the given upper-case character to it's Soudex code.
- *
- * @param ch
- * An upper-case character.
- * @return A Soundex code.
- * @throws IllegalArgumentException
- * Thrown if ch is not mapped.
- */
- private char map(char ch) {
- int index = ch - 'A';
- if (index < 0 || index >= this.getSoundexMapping().length) {
- throw new IllegalArgumentException("The character is not mapped: " + ch);
- }
- return this.getSoundexMapping()[index];
- }
-
- /**
- * Sets the maxLength.
- *
- * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
- * @param maxLength
- * The maxLength to set
- */
- public void setMaxLength(int maxLength) {
- this.maxLength = maxLength;
- }
-
- /**
- * Sets the soundexMapping.
- *
- * @param soundexMapping
- * The soundexMapping to set.
- */
- private void setSoundexMapping(char[] soundexMapping) {
- this.soundexMapping = soundexMapping;
- }
-
- /**
- * Retreives the Soundex code for a given String object.
- *
- * @param str
- * String to encode using the Soundex algorithm
- * @return A soundex code for the String supplied
- * @throws IllegalArgumentException
- * if a character is not mapped
- */
- public String soundex(String str) {
- if (str == null) {
- return null;
- }
- str = SoundexUtils.clean(str);
- if (str.length() == 0) {
- return str;
- }
- char out[] = {'0', '0', '0', '0'};
- char last, mapped;
- int incount = 1, count = 1;
- out[0] = str.charAt(0);
- last = getMappingCode(str, 0);
- while ((incount < str.length()) && (count < out.length)) {
- mapped = getMappingCode(str, incount++);
- if (mapped != 0) {
- if ((mapped != '0') && (mapped != last)) {
- out[count++] = mapped;
- }
- last = mapped;
- }
- }
- return new String(out);
- }
-
-}
diff --git a/src/org/apache/commons/codec/language/SoundexUtils.java b/src/org/apache/commons/codec/language/SoundexUtils.java
deleted file mode 100644
index 48f2d8787f175dadd7973294f8b45ce7a71928ce..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/language/SoundexUtils.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec.language;
-
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.StringEncoder;
-
-/**
- * Utility methods for {@link Soundex} and {@link RefinedSoundex} classes.
- *
- * @author Apache Software Foundation
- * @version $Id: SoundexUtils.java,v 1.5 2004/03/17 18:31:35 ggregory Exp $
- * @since 1.3
- */
-final class SoundexUtils {
-
- /**
- * Cleans up the input string before Soundex processing by only returning
- * upper case letters.
- *
- * @param str
- * The String to clean.
- * @return A clean String.
- */
- static String clean(String str) {
- if (str == null || str.length() == 0) {
- return str;
- }
- int len = str.length();
- char[] chars = new char[len];
- int count = 0;
- for (int i = 0; i < len; i++) {
- if (Character.isLetter(str.charAt(i))) {
- chars[count++] = str.charAt(i);
- }
- }
- if (count == len) {
- return str.toUpperCase();
- }
- return new String(chars, 0, count).toUpperCase();
- }
-
- /**
- * Encodes the Strings and returns the number of characters in the two
- * encoded Strings that are the same.
- * - * Identical to the Base64 encoding defined by RFC - * 1521 and allows a character set to be specified. - *
- * - *- * RFC 1522 describes techniques to allow the encoding of non-ASCII - * text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message - * handling software. - *
- * - * @see MIME (Multipurpose Internet Mail Extensions) Part Two: Message - * Header Extensions for Non-ASCII Text - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id: BCodec.java,v 1.5 2004/04/13 22:46:37 ggregory Exp $ - */ -public class BCodec extends RFC1522Codec implements StringEncoder, StringDecoder { - /** - * The default charset used for string decoding and encoding. - */ - private String charset = StringEncodings.UTF8; - - /** - * Default constructor. - */ - public BCodec() { - super(); - } - - /** - * Constructor which allows for the selection of a default charset - * - * @param charset - * the default string charset to use. - * - * @see JRE character - * encoding names - */ - public BCodec(final String charset) { - super(); - this.charset = charset; - } - - protected String getEncoding() { - return "B"; - } - - protected byte[] doEncoding(byte[] bytes) throws EncoderException { - if (bytes == null) { - return null; - } - return Base64.encodeBase64(bytes); - } - - protected byte[] doDecoding(byte[] bytes) throws DecoderException { - if (bytes == null) { - return null; - } - return Base64.decodeBase64(bytes); - } - - /** - * Encodes a string into its Base64 form using the specified charset. Unsafe characters are escaped. - * - * @param value - * string to convert to Base64 form - * @param charset - * the charset for pString - * @return Base64 string - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public String encode(final String value, final String charset) throws EncoderException { - if (value == null) { - return null; - } - try { - return encodeText(value, charset); - } catch (UnsupportedEncodingException e) { - throw new EncoderException(e.getMessage()); - } - } - - /** - * Encodes a string into its Base64 form using the default charset. Unsafe characters are escaped. - * - * @param value - * string to convert to Base64 form - * @return Base64 string - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public String encode(String value) throws EncoderException { - if (value == null) { - return null; - } - return encode(value, getDefaultCharset()); - } - - /** - * Decodes a Base64 string into its original form. Escaped characters are converted back to their original - * representation. - * - * @param value - * Base64 string to convert into its original form - * - * @return original string - * - * @throws DecoderException - * A decoder exception is thrown if a failure condition is encountered during the decode process. - */ - public String decode(String value) throws DecoderException { - if (value == null) { - return null; - } - try { - return decodeText(value); - } catch (UnsupportedEncodingException e) { - throw new DecoderException(e.getMessage()); - } - } - - /** - * Encodes an object into its Base64 form using the default charset. Unsafe characters are escaped. - * - * @param value - * object to convert to Base64 form - * @return Base64 object - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public Object encode(Object value) throws EncoderException { - if (value == null) { - return null; - } else if (value instanceof String) { - return encode((String) value); - } else { - throw new EncoderException("Objects of type " - + value.getClass().getName() - + " cannot be encoded using BCodec"); - } - } - - /** - * Decodes a Base64 object into its original form. Escaped characters are converted back to their original - * representation. - * - * @param value - * Base64 object to convert into its original form - * - * @return original object - * - * @throws DecoderException - * A decoder exception is thrown if a failure condition is encountered during the decode process. - */ - public Object decode(Object value) throws DecoderException { - if (value == null) { - return null; - } else if (value instanceof String) { - return decode((String) value); - } else { - throw new DecoderException("Objects of type " - + value.getClass().getName() - + " cannot be decoded using BCodec"); - } - } - - /** - * The default charset used for string decoding and encoding. - * - * @return the default string charset. - */ - public String getDefaultCharset() { - return this.charset; - } -} diff --git a/src/org/apache/commons/codec/net/QCodec.java b/src/org/apache/commons/codec/net/QCodec.java deleted file mode 100644 index 573608075c3611725bea2e746daf1cba44de5776..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/net/QCodec.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.net; - -import java.io.UnsupportedEncodingException; -import java.util.BitSet; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.StringDecoder; -import org.apache.commons.codec.StringEncoder; - -/** - *- * Similar to the Quoted-Printable content-transfer-encoding defined in RFC 1521 and designed to allow text containing mostly ASCII - * characters to be decipherable on an ASCII terminal without decoding. - *
- * - *- * RFC 1522 describes techniques to allow the encoding of non-ASCII - * text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message - * handling software. - *
- * - * @see MIME (Multipurpose Internet Mail Extensions) Part Two: Message - * Header Extensions for Non-ASCII Text - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id: QCodec.java,v 1.6 2004/05/24 00:24:32 ggregory Exp $ - */ -public class QCodec extends RFC1522Codec implements StringEncoder, StringDecoder { - /** - * The default charset used for string decoding and encoding. - */ - private String charset = StringEncodings.UTF8; - - /** - * BitSet of printable characters as defined in RFC 1522. - */ - private static final BitSet PRINTABLE_CHARS = new BitSet(256); - // Static initializer for printable chars collection - static { - // alpha characters - PRINTABLE_CHARS.set(' '); - PRINTABLE_CHARS.set('!'); - PRINTABLE_CHARS.set('"'); - PRINTABLE_CHARS.set('#'); - PRINTABLE_CHARS.set('$'); - PRINTABLE_CHARS.set('%'); - PRINTABLE_CHARS.set('&'); - PRINTABLE_CHARS.set('\''); - PRINTABLE_CHARS.set('('); - PRINTABLE_CHARS.set(')'); - PRINTABLE_CHARS.set('*'); - PRINTABLE_CHARS.set('+'); - PRINTABLE_CHARS.set(','); - PRINTABLE_CHARS.set('-'); - PRINTABLE_CHARS.set('.'); - PRINTABLE_CHARS.set('/'); - for (int i = '0'; i <= '9'; i++) { - PRINTABLE_CHARS.set(i); - } - PRINTABLE_CHARS.set(':'); - PRINTABLE_CHARS.set(';'); - PRINTABLE_CHARS.set('<'); - PRINTABLE_CHARS.set('>'); - PRINTABLE_CHARS.set('@'); - for (int i = 'A'; i <= 'Z'; i++) { - PRINTABLE_CHARS.set(i); - } - PRINTABLE_CHARS.set('['); - PRINTABLE_CHARS.set('\\'); - PRINTABLE_CHARS.set(']'); - PRINTABLE_CHARS.set('^'); - PRINTABLE_CHARS.set('`'); - for (int i = 'a'; i <= 'z'; i++) { - PRINTABLE_CHARS.set(i); - } - PRINTABLE_CHARS.set('{'); - PRINTABLE_CHARS.set('|'); - PRINTABLE_CHARS.set('}'); - PRINTABLE_CHARS.set('~'); - } - - private static byte BLANK = 32; - - private static byte UNDERSCORE = 95; - - private boolean encodeBlanks = false; - - /** - * Default constructor. - */ - public QCodec() { - super(); - } - - /** - * Constructor which allows for the selection of a default charset - * - * @param charset - * the default string charset to use. - * - * @see JRE character - * encoding names - */ - public QCodec(final String charset) { - super(); - this.charset = charset; - } - - protected String getEncoding() { - return "Q"; - } - - protected byte[] doEncoding(byte[] bytes) throws EncoderException { - if (bytes == null) { - return null; - } - byte[] data = QuotedPrintableCodec.encodeQuotedPrintable(PRINTABLE_CHARS, bytes); - if (this.encodeBlanks) { - for (int i = 0; i < data.length; i++) { - if (data[i] == BLANK) { - data[i] = UNDERSCORE; - } - } - } - return data; - } - - protected byte[] doDecoding(byte[] bytes) throws DecoderException { - if (bytes == null) { - return null; - } - boolean hasUnderscores = false; - for (int i = 0; i < bytes.length; i++) { - if (bytes[i] == UNDERSCORE) { - hasUnderscores = true; - break; - } - } - if (hasUnderscores) { - byte[] tmp = new byte[bytes.length]; - for (int i = 0; i < bytes.length; i++) { - byte b = bytes[i]; - if (b != UNDERSCORE) { - tmp[i] = b; - } else { - tmp[i] = BLANK; - } - } - return QuotedPrintableCodec.decodeQuotedPrintable(tmp); - } - return QuotedPrintableCodec.decodeQuotedPrintable(bytes); - } - - /** - * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. - * - * @param pString - * string to convert to quoted-printable form - * @param charset - * the charset for pString - * @return quoted-printable string - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public String encode(final String pString, final String charset) throws EncoderException { - if (pString == null) { - return null; - } - try { - return encodeText(pString, charset); - } catch (UnsupportedEncodingException e) { - throw new EncoderException(e.getMessage()); - } - } - - /** - * Encodes a string into its quoted-printable form using the default charset. Unsafe characters are escaped. - * - * @param pString - * string to convert to quoted-printable form - * @return quoted-printable string - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public String encode(String pString) throws EncoderException { - if (pString == null) { - return null; - } - return encode(pString, getDefaultCharset()); - } - - /** - * Decodes a quoted-printable string into its original form. Escaped characters are converted back to their original - * representation. - * - * @param pString - * quoted-printable string to convert into its original form - * - * @return original string - * - * @throws DecoderException - * A decoder exception is thrown if a failure condition is encountered during the decode process. - */ - public String decode(String pString) throws DecoderException { - if (pString == null) { - return null; - } - try { - return decodeText(pString); - } catch (UnsupportedEncodingException e) { - throw new DecoderException(e.getMessage()); - } - } - - /** - * Encodes an object into its quoted-printable form using the default charset. Unsafe characters are escaped. - * - * @param pObject - * object to convert to quoted-printable form - * @return quoted-printable object - * - * @throws EncoderException - * thrown if a failure condition is encountered during the encoding process. - */ - public Object encode(Object pObject) throws EncoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof String) { - return encode((String) pObject); - } else { - throw new EncoderException("Objects of type " - + pObject.getClass().getName() - + " cannot be encoded using Q codec"); - } - } - - /** - * Decodes a quoted-printable object into its original form. Escaped characters are converted back to their original - * representation. - * - * @param pObject - * quoted-printable object to convert into its original form - * - * @return original object - * - * @throws DecoderException - * A decoder exception is thrown if a failure condition is encountered during the decode process. - */ - public Object decode(Object pObject) throws DecoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof String) { - return decode((String) pObject); - } else { - throw new DecoderException("Objects of type " - + pObject.getClass().getName() - + " cannot be decoded using Q codec"); - } - } - - /** - * The default charset used for string decoding and encoding. - * - * @return the default string charset. - */ - public String getDefaultCharset() { - return this.charset; - } - - /** - * Tests if optional tranformation of SPACE characters is to be used - * - * @returntrue if SPACE characters are to be transformed, false otherwise
- */
- public boolean isEncodeBlanks() {
- return this.encodeBlanks;
- }
-
- /**
- * Defines whether optional tranformation of SPACE characters is to be used
- *
- * @param b
- * true if SPACE characters are to be transformed, false otherwise
- */
- public void setEncodeBlanks(boolean b) {
- this.encodeBlanks = b;
- }
-}
diff --git a/src/org/apache/commons/codec/net/QuotedPrintableCodec.java b/src/org/apache/commons/codec/net/QuotedPrintableCodec.java
deleted file mode 100644
index c2fcd27eff4aea352e6b883b082c8439b0da4c8e..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/net/QuotedPrintableCodec.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.codec.net;
-
-import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.BitSet;
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.BinaryEncoder;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.StringDecoder;
-import org.apache.commons.codec.StringEncoder;
-
-/**
- * - * Codec for the Quoted-Printable section of RFC 1521 . - *
- *- * The Quoted-Printable encoding is intended to represent data that largely consists of octets that correspond to - * printable characters in the ASCII character set. It encodes the data in such a way that the resulting octets are - * unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the - * data remains largely recognizable by humans. A body which is entirely ASCII may also be encoded in Quoted-Printable - * to ensure the integrity of the data should the message pass through a character- translating, and/or line-wrapping - * gateway. - *
- * - *- * Note: - *
- *- * Rules #3, #4, and #5 of the quoted-printable spec are not implemented yet because the complete quoted-printable spec - * does not lend itself well into the byte[] oriented codec framework. Complete the codec once the steamable codec - * framework is ready. The motivation behind providing the codec in a partial form is that it can already come in handy - * for those applications that do not require quoted-printable line formatting (rules #3, #4, #5), for instance Q codec. - *
- * - * @see RFC 1521 MIME (Multipurpose Internet Mail Extensions) Part One: - * Mechanisms for Specifying and Describing the Format of Internet Message Bodies - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id: QuotedPrintableCodec.java,v 1.7 2004/04/09 22:21:07 ggregory Exp $ - */ -public class QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { - /** - * The default charset used for string decoding and encoding. - */ - private String charset = StringEncodings.UTF8; - - /** - * BitSet of printable characters as defined in RFC 1521. - */ - private static final BitSet PRINTABLE_CHARS = new BitSet(256); - - private static byte ESCAPE_CHAR = '='; - - private static byte TAB = 9; - - private static byte SPACE = 32; - // Static initializer for printable chars collection - static { - // alpha characters - for (int i = 33; i <= 60; i++) { - PRINTABLE_CHARS.set(i); - } - for (int i = 62; i <= 126; i++) { - PRINTABLE_CHARS.set(i); - } - PRINTABLE_CHARS.set(TAB); - PRINTABLE_CHARS.set(SPACE); - } - - /** - * Default constructor. - */ - public QuotedPrintableCodec() { - super(); - } - - /** - * Constructor which allows for the selection of a default charset - * - * @param charset - * the default string charset to use. - */ - public QuotedPrintableCodec(String charset) { - super(); - this.charset = charset; - } - - /** - * Encodes byte into its quoted-printable representation. - * - * @param b - * byte to encode - * @param buffer - * the buffer to write to - */ - private static final void encodeQuotedPrintable(int b, ByteArrayOutputStream buffer) { - buffer.write(ESCAPE_CHAR); - char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, 16)); - char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, 16)); - buffer.write(hex1); - buffer.write(hex2); - } - - /** - * Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521 and is suitable for encoding binary data and unformatted text. - *
- * - * @param printable - * bitset of characters deemed quoted-printable - * @param bytes - * array of bytes to be encoded - * @return array of bytes containing quoted-printable data - */ - public static final byte[] encodeQuotedPrintable(BitSet printable, byte[] bytes) { - if (bytes == null) { - return null; - } - if (printable == null) { - printable = PRINTABLE_CHARS; - } - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - for (int i = 0; i < bytes.length; i++) { - int b = bytes[i]; - if (b < 0) { - b = 256 + b; - } - if (printable.get(b)) { - buffer.write(b); - } else { - encodeQuotedPrintable(b, buffer); - } - } - return buffer.toByteArray(); - } - - /** - * Decodes an array quoted-printable characters into an array of original bytes. Escaped characters are converted - * back to their original representation. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521. - *
- * - * @param bytes - * array of quoted-printable characters - * @return array of original bytes - * @throws DecoderException - * Thrown if quoted-printable decoding is unsuccessful - */ - public static final byte[] decodeQuotedPrintable(byte[] bytes) throws DecoderException { - if (bytes == null) { - return null; - } - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - for (int i = 0; i < bytes.length; i++) { - int b = bytes[i]; - if (b == ESCAPE_CHAR) { - try { - int u = Character.digit((char) bytes[++i], 16); - int l = Character.digit((char) bytes[++i], 16); - if (u == -1 || l == -1) { - throw new DecoderException("Invalid quoted-printable encoding"); - } - buffer.write((char) ((u << 4) + l)); - } catch (ArrayIndexOutOfBoundsException e) { - throw new DecoderException("Invalid quoted-printable encoding"); - } - } else { - buffer.write(b); - } - } - return buffer.toByteArray(); - } - - /** - * Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521 and is suitable for encoding binary data and unformatted text. - *
- * - * @param bytes - * array of bytes to be encoded - * @return array of bytes containing quoted-printable data - */ - public byte[] encode(byte[] bytes) { - return encodeQuotedPrintable(PRINTABLE_CHARS, bytes); - } - - /** - * Decodes an array of quoted-printable characters into an array of original bytes. Escaped characters are converted - * back to their original representation. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521. - *
- * - * @param bytes - * array of quoted-printable characters - * @return array of original bytes - * @throws DecoderException - * Thrown if quoted-printable decoding is unsuccessful - */ - public byte[] decode(byte[] bytes) throws DecoderException { - return decodeQuotedPrintable(bytes); - } - - /** - * Encodes a string into its quoted-printable form using the default string charset. Unsafe characters are escaped. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521 and is suitable for encoding binary data. - *
- * - * @param pString - * string to convert to quoted-printable form - * @return quoted-printable string - * - * @throws EncoderException - * Thrown if quoted-printable encoding is unsuccessful - * - * @see #getDefaultCharset() - */ - public String encode(String pString) throws EncoderException { - if (pString == null) { - return null; - } - try { - return encode(pString, getDefaultCharset()); - } catch (UnsupportedEncodingException e) { - throw new EncoderException(e.getMessage()); - } - } - - /** - * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters - * are converted back to their original representation. - * - * @param pString - * quoted-printable string to convert into its original form - * @param charset - * the original string charset - * @return original string - * @throws DecoderException - * Thrown if quoted-printable decoding is unsuccessful - * @throws UnsupportedEncodingException - * Thrown if charset is not supported - */ - public String decode(String pString, String charset) throws DecoderException, UnsupportedEncodingException { - if (pString == null) { - return null; - } - return new String(decode(pString.getBytes(StringEncodings.US_ASCII)), charset); - } - - /** - * Decodes a quoted-printable string into its original form using the default string charset. Escaped characters are - * converted back to their original representation. - * - * @param pString - * quoted-printable string to convert into its original form - * @return original string - * @throws DecoderException - * Thrown if quoted-printable decoding is unsuccessful - * @throws UnsupportedEncodingException - * Thrown if charset is not supported - * @see #getDefaultCharset() - */ - public String decode(String pString) throws DecoderException { - if (pString == null) { - return null; - } - try { - return decode(pString, getDefaultCharset()); - } catch (UnsupportedEncodingException e) { - throw new DecoderException(e.getMessage()); - } - } - - /** - * Encodes an object into its quoted-printable safe form. Unsafe characters are escaped. - * - * @param pObject - * string to convert to a quoted-printable form - * @return quoted-printable object - * @throws EncoderException - * Thrown if quoted-printable encoding is not applicable to objects of this type or if encoding is - * unsuccessful - */ - public Object encode(Object pObject) throws EncoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof byte[]) { - return encode((byte[]) pObject); - } else if (pObject instanceof String) { - return encode((String) pObject); - } else { - throw new EncoderException("Objects of type " - + pObject.getClass().getName() - + " cannot be quoted-printable encoded"); - } - } - - /** - * Decodes a quoted-printable object into its original form. Escaped characters are converted back to their original - * representation. - * - * @param pObject - * quoted-printable object to convert into its original form - * @return original object - * @throws DecoderException - * Thrown if quoted-printable decoding is not applicable to objects of this type if decoding is - * unsuccessful - */ - public Object decode(Object pObject) throws DecoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof byte[]) { - return decode((byte[]) pObject); - } else if (pObject instanceof String) { - return decode((String) pObject); - } else { - throw new DecoderException("Objects of type " - + pObject.getClass().getName() - + " cannot be quoted-printable decoded"); - } - } - - /** - * Returns the default charset used for string decoding and encoding. - * - * @return the default string charset. - */ - public String getDefaultCharset() { - return this.charset; - } - - /** - * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. - * - *- * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in - * RFC 1521 and is suitable for encoding binary data and unformatted text. - *
- * - * @param pString - * string to convert to quoted-printable form - * @param charset - * the charset for pString - * @return quoted-printable string - * - * @throws UnsupportedEncodingException - * Thrown if the charset is not supported - */ - public String encode(String pString, String charset) throws UnsupportedEncodingException { - if (pString == null) { - return null; - } - return new String(encode(pString.getBytes(charset)), StringEncodings.US_ASCII); - } -} diff --git a/src/org/apache/commons/codec/net/RFC1522Codec.java b/src/org/apache/commons/codec/net/RFC1522Codec.java deleted file mode 100644 index 0acf92107464c863f593064daa6e8364cb5fcaa9..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/net/RFC1522Codec.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.net; - -import java.io.UnsupportedEncodingException; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.EncoderException; - -/** - *- * Implements methods common to all codecs defined in RFC 1522. - *
- * - *- * RFC 1522 - * describes techniques to allow the encoding of non-ASCII text in - * various portions of a RFC 822 [2] message header, in a manner which - * is unlikely to confuse existing message handling software. - *
- - * @see - * MIME (Multipurpose Internet Mail Extensions) Part Two: - * Message Header Extensions for Non-ASCII Text - * - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id: RFC1522Codec.java,v 1.2 2004/04/09 22:21:43 ggregory Exp $ - */ -abstract class RFC1522Codec { - - /** - * Applies an RFC 1522 compliant encoding scheme to the given string of text with the - * given charset. This method constructs the "encoded-word" header common to all the - * RFC 1522 codecs and then invokes {@link #doEncoding(byte [])} method of a concrete - * class to perform the specific enconding. - * - * @param text a string to encode - * @param charset a charset to be used - * - * @return RFC 1522 compliant "encoded-word" - * - * @throws EncoderException thrown if there is an error conidition during the Encoding - * process. - * @throws UnsupportedEncodingException thrown if charset is not supported - * - * @see JRE character - * encoding names - */ - protected String encodeText(final String text, final String charset) - throws EncoderException, UnsupportedEncodingException - { - if (text == null) { - return null; - } - StringBuffer buffer = new StringBuffer(); - buffer.append("=?"); - buffer.append(charset); - buffer.append('?'); - buffer.append(getEncoding()); - buffer.append('?'); - byte [] rawdata = doEncoding(text.getBytes(charset)); - buffer.append(new String(rawdata, StringEncodings.US_ASCII)); - buffer.append("?="); - return buffer.toString(); - } - - /** - * Applies an RFC 1522 compliant decoding scheme to the given string of text. This method - * processes the "encoded-word" header common to all the RFC 1522 codecs and then invokes - * {@link #doEncoding(byte [])} method of a concrete class to perform the specific deconding. - * - * @param text a string to decode - * - * @throws DecoderException thrown if there is an error conidition during the Decoding - * process. - * @throws UnsupportedEncodingException thrown if charset specified in the "encoded-word" - * header is not supported - */ - protected String decodeText(final String text) - throws DecoderException, UnsupportedEncodingException - { - if (text == null) { - return null; - } - if ((!text.startsWith("=?")) || (!text.endsWith("?="))) { - throw new DecoderException("RFC 1522 violation: malformed encoded content"); - } - int termnator = text.length() - 2; - int from = 2; - int to = text.indexOf("?", from); - if ((to == -1) || (to == termnator)) { - throw new DecoderException("RFC 1522 violation: charset token not found"); - } - String charset = text.substring(from, to); - if (charset.equals("")) { - throw new DecoderException("RFC 1522 violation: charset not specified"); - } - from = to + 1; - to = text.indexOf("?", from); - if ((to == -1) || (to == termnator)) { - throw new DecoderException("RFC 1522 violation: encoding token not found"); - } - String encoding = text.substring(from, to); - if (!getEncoding().equalsIgnoreCase(encoding)) { - throw new DecoderException("This codec cannot decode " + - encoding + " encoded content"); - } - from = to + 1; - to = text.indexOf("?", from); - byte[] data = text.substring(from, to).getBytes(StringEncodings.US_ASCII); - data = doDecoding(data); - return new String(data, charset); - } - - /** - * Returns the codec name (referred to as encoding in the RFC 1522) - * - * @return name of the codec - */ - protected abstract String getEncoding(); - - /** - * Encodes an array of bytes using the defined encoding scheme - * - * @param bytes Data to be encoded - * - * @return A byte array containing the encoded data - * - * @throws EncoderException thrown if the Encoder encounters a failure condition - * during the encoding process. - */ - protected abstract byte[] doEncoding(byte[] bytes) throws EncoderException; - - /** - * Decodes an array of bytes using the defined encoding scheme - * - * @param bytes Data to be decoded - * - * @return a byte array that contains decoded data - * - * @throws DecoderException A decoder exception is thrown if a Decoder encounters a - * failure condition during the decode process. - */ - protected abstract byte[] doDecoding(byte[] bytes) throws DecoderException; -} diff --git a/src/org/apache/commons/codec/net/StringEncodings.java b/src/org/apache/commons/codec/net/StringEncodings.java deleted file mode 100644 index e7f6bb85d73ffda6e66433d8ae52d872653faf58..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/net/StringEncodings.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.net; - -/** - * String encodings used in this package. - * - * @author Apache Software Foundation - * @since 1.3 - * @version $Id: StringEncodings.java,v 1.2 2004/04/09 22:21:07 ggregory Exp $ - */ -interface StringEncodings { - /** - *- * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. - *
- *- * Every implementation of the Java platform is required to support this character encoding. - *
- * - * @see JRE character - * encoding names - */ - String US_ASCII = "US-ASCII"; - - /** - *- * Eight-bit Unicode Transformation Format. - *
- *- * Every implementation of the Java platform is required to support this character encoding. - *
- * - * @see JRE character - * encoding names - */ - String UTF8 = "UTF-8"; -} diff --git a/src/org/apache/commons/codec/net/URLCodec.java b/src/org/apache/commons/codec/net/URLCodec.java deleted file mode 100644 index 1bc350778f529aa86c9fa63d020c442a18a0659a..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/net/URLCodec.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.codec.net; - -import java.io.ByteArrayOutputStream; -import java.io.UnsupportedEncodingException; -import java.util.BitSet; - -import org.apache.commons.codec.BinaryDecoder; -import org.apache.commons.codec.BinaryEncoder; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.EncoderException; -import org.apache.commons.codec.StringDecoder; -import org.apache.commons.codec.StringEncoder; - -/** - *Implements the 'www-form-urlencoded' encoding scheme, - * also misleadingly known as URL encoding.
- * - *For more detailed information please refer to - * - * Chapter 17.13.4 'Form content types' of the - * HTML 4.01 Specification
- * - *- * This codec is meant to be a replacement for standard Java classes - * {@link java.net.URLEncoder} and {@link java.net.URLDecoder} - * on older Java platforms, as these classes in Java versions below - * 1.4 rely on the platform's default charset encoding. - *
- * - * @author Apache Software Foundation - * @since 1.2 - * @version $Id: URLCodec.java,v 1.19 2004/03/29 07:59:00 ggregory Exp $ - */ -public class URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { - - /** - * The default charset used for string decoding and encoding. - */ - protected String charset = StringEncodings.UTF8; - - protected static byte ESCAPE_CHAR = '%'; - /** - * BitSet of www-form-url safe characters. - */ - protected static final BitSet WWW_FORM_URL = new BitSet(256); - - // Static initializer for www_form_url - static { - // alpha characters - for (int i = 'a'; i <= 'z'; i++) { - WWW_FORM_URL.set(i); - } - for (int i = 'A'; i <= 'Z'; i++) { - WWW_FORM_URL.set(i); - } - // numeric characters - for (int i = '0'; i <= '9'; i++) { - WWW_FORM_URL.set(i); - } - // special chars - WWW_FORM_URL.set('-'); - WWW_FORM_URL.set('_'); - WWW_FORM_URL.set('.'); - WWW_FORM_URL.set('*'); - // blank to be replaced with + - WWW_FORM_URL.set(' '); - } - - - /** - * Default constructor. - */ - public URLCodec() { - super(); - } - - /** - * Constructor which allows for the selection of a default charset - * - * @param charset the default string charset to use. - */ - public URLCodec(String charset) { - super(); - this.charset = charset; - } - - /** - * Encodes an array of bytes into an array of URL safe 7-bit - * characters. Unsafe characters are escaped. - * - * @param urlsafe bitset of characters deemed URL safe - * @param bytes array of bytes to convert to URL safe characters - * @return array of bytes containing URL safe characters - */ - public static final byte[] encodeUrl(BitSet urlsafe, byte[] bytes) - { - if (bytes == null) { - return null; - } - if (urlsafe == null) { - urlsafe = WWW_FORM_URL; - } - - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - for (int i = 0; i < bytes.length; i++) { - int b = bytes[i]; - if (b < 0) { - b = 256 + b; - } - if (urlsafe.get(b)) { - if (b == ' ') { - b = '+'; - } - buffer.write(b); - } else { - buffer.write('%'); - char hex1 = Character.toUpperCase( - Character.forDigit((b >> 4) & 0xF, 16)); - char hex2 = Character.toUpperCase( - Character.forDigit(b & 0xF, 16)); - buffer.write(hex1); - buffer.write(hex2); - } - } - return buffer.toByteArray(); - } - - - /** - * Decodes an array of URL safe 7-bit characters into an array of - * original bytes. Escaped characters are converted back to their - * original representation. - * - * @param bytes array of URL safe characters - * @return array of original bytes - * @throws DecoderException Thrown if URL decoding is unsuccessful - */ - public static final byte[] decodeUrl(byte[] bytes) - throws DecoderException - { - if (bytes == null) { - return null; - } - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - for (int i = 0; i < bytes.length; i++) { - int b = bytes[i]; - if (b == '+') { - buffer.write(' '); - } else if (b == '%') { - try { - int u = Character.digit((char)bytes[++i], 16); - int l = Character.digit((char)bytes[++i], 16); - if (u == -1 || l == -1) { - throw new DecoderException("Invalid URL encoding"); - } - buffer.write((char)((u << 4) + l)); - } catch(ArrayIndexOutOfBoundsException e) { - throw new DecoderException("Invalid URL encoding"); - } - } else { - buffer.write(b); - } - } - return buffer.toByteArray(); - } - - - /** - * Encodes an array of bytes into an array of URL safe 7-bit - * characters. Unsafe characters are escaped. - * - * @param bytes array of bytes to convert to URL safe characters - * @return array of bytes containing URL safe characters - */ - public byte[] encode(byte[] bytes) { - return encodeUrl(WWW_FORM_URL, bytes); - } - - - /** - * Decodes an array of URL safe 7-bit characters into an array of - * original bytes. Escaped characters are converted back to their - * original representation. - * - * @param bytes array of URL safe characters - * @return array of original bytes - * @throws DecoderException Thrown if URL decoding is unsuccessful - */ - public byte[] decode(byte[] bytes) throws DecoderException { - return decodeUrl(bytes); - } - - - /** - * Encodes a string into its URL safe form using the specified - * string charset. Unsafe characters are escaped. - * - * @param pString string to convert to a URL safe form - * @param charset the charset for pString - * @return URL safe string - * @throws UnsupportedEncodingException Thrown if charset is not - * supported - */ - public String encode(String pString, String charset) - throws UnsupportedEncodingException - { - if (pString == null) { - return null; - } - return new String(encode(pString.getBytes(charset)), StringEncodings.US_ASCII); - } - - - /** - * Encodes a string into its URL safe form using the default string - * charset. Unsafe characters are escaped. - * - * @param pString string to convert to a URL safe form - * @return URL safe string - * @throws EncoderException Thrown if URL encoding is unsuccessful - * - * @see #getDefaultCharset() - */ - public String encode(String pString) throws EncoderException { - if (pString == null) { - return null; - } - try { - return encode(pString, getDefaultCharset()); - } catch(UnsupportedEncodingException e) { - throw new EncoderException(e.getMessage()); - } - } - - - /** - * Decodes a URL safe string into its original form using the - * specified encoding. Escaped characters are converted back - * to their original representation. - * - * @param pString URL safe string to convert into its original form - * @param charset the original string charset - * @return original string - * @throws DecoderException Thrown if URL decoding is unsuccessful - * @throws UnsupportedEncodingException Thrown if charset is not - * supported - */ - public String decode(String pString, String charset) - throws DecoderException, UnsupportedEncodingException - { - if (pString == null) { - return null; - } - return new String(decode(pString.getBytes(StringEncodings.US_ASCII)), charset); - } - - - /** - * Decodes a URL safe string into its original form using the default - * string charset. Escaped characters are converted back to their - * original representation. - * - * @param pString URL safe string to convert into its original form - * @return original string - * @throws DecoderException Thrown if URL decoding is unsuccessful - * - * @see #getDefaultCharset() - */ - public String decode(String pString) throws DecoderException { - if (pString == null) { - return null; - } - try { - return decode(pString, getDefaultCharset()); - } catch(UnsupportedEncodingException e) { - throw new DecoderException(e.getMessage()); - } - } - - /** - * Encodes an object into its URL safe form. Unsafe characters are - * escaped. - * - * @param pObject string to convert to a URL safe form - * @return URL safe object - * @throws EncoderException Thrown if URL encoding is not - * applicable to objects of this type or - * if encoding is unsuccessful - */ - public Object encode(Object pObject) throws EncoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof byte[]) { - return encode((byte[])pObject); - } else if (pObject instanceof String) { - return encode((String)pObject); - } else { - throw new EncoderException("Objects of type " + - pObject.getClass().getName() + " cannot be URL encoded"); - - } - } - - /** - * Decodes a URL safe object into its original form. Escaped - * characters are converted back to their original representation. - * - * @param pObject URL safe object to convert into its original form - * @return original object - * @throws DecoderException Thrown if URL decoding is not - * applicable to objects of this type - * if decoding is unsuccessful - */ - public Object decode(Object pObject) throws DecoderException { - if (pObject == null) { - return null; - } else if (pObject instanceof byte[]) { - return decode((byte[])pObject); - } else if (pObject instanceof String) { - return decode((String)pObject); - } else { - throw new DecoderException("Objects of type " + - pObject.getClass().getName() + " cannot be URL decoded"); - - } - } - - /** - * TheString encoding used for decoding and encoding.
- *
- * @return Returns the encoding.
- *
- * @deprecated use #getDefaultCharset()
- */
- public String getEncoding() {
- return this.charset;
- }
-
- /**
- * The default charset used for string decoding and encoding.
- *
- * @return the default string charset.
- */
- public String getDefaultCharset() {
- return this.charset;
- }
-
-}
diff --git a/src/org/apache/commons/codec/net/package.html b/src/org/apache/commons/codec/net/package.html
deleted file mode 100644
index 4607c5769a06d65d6b46dfe1471da3acd3f1da48..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/codec/net/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- - Network related encoding and decoding. -
- - diff --git a/src/org/apache/commons/codec/overview.html b/src/org/apache/commons/codec/overview.html deleted file mode 100644 index 6b6f6c91b0b3e94948d62ce97bed60cde5fd300e..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/overview.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - --This document is the API specification for the Apache Jakarta Commons Codec Library, version 1.3. -
--This library requires a JRE version of 1.2.2 or greater. -The hypertext links originating from this document point to Sun's version 1.3 API as the 1.2.2 API documentation -is no longer on-line. -
- - diff --git a/src/org/apache/commons/codec/package.html b/src/org/apache/commons/codec/package.html deleted file mode 100644 index b7ccf03eb90d488918a6a0c5dc18ffdabbd03c79..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/codec/package.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - -A small set of interfaces used by - the various implementations in the sub-packages.
- -Definitive implementations of commonly used encoders and decoders.
- -Codec is currently comprised of a modest set of utilities and a - simple framework for String encoding and decoding in three categories: - Binary Encoders, Language Encoders, and Network Encoders.
- -| - - org.apache.commons.codec.binary.Base64 - | -- Provides Base64 content-transfer-encoding as defined in - RFC 2045 - | -Production | -
| - - org.apache.commons.codec.binary.Hex - | -- Converts an array of bytes into an array of characters - representing the hexidecimal values of each byte in order - | -Production | -
- Codec contains a number of commonly used language and phonetic - encoders -
-| - org.apache.commons.codec.language.Soundex - | -Implementation of the Soundex algorithm. | -Production | -
| - org.apache.commons.codec.language.Metaphone - | -Implementation of the Metaphone algorithm. | -Production | -
Codec contains network related encoders
-| - org.apache.commons.codec.net.URLCodec - | -Implements the 'www-form-urlencoded' encoding scheme. | -Production | -
A simple logging interface abstracting logging APIs. In order to be - * instantiated successfully by {@link LogFactory}, classes that implement - * this interface must have a constructor that takes a single String - * parameter representing the "name" of this Log.
- * - * The six logging levels used by Log are (in order):
- *
Performance is often a logging concern. - * By examining the appropriate property, - * a component can avoid expensive operations (producing information - * to be logged).
- * - * For example,
- *
- *
- * if (log.isDebugEnabled()) {
- * ... do something expensive ...
- * log.debug(theResult);
- * }
- *
Configuration of the underlying logging system will generally be done - * external to the Logging APIs, through whatever mechanism is supported by - * that system.
- * - * @author Scott Sanders - * @author Rod Waldhoff - * @version $Id: Log.java 381838 2006-02-28 23:57:11Z skitching $ - */ -public interface Log { - - - // ----------------------------------------------------- Logging Properties - - - /** - *Is debug logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than debug.
Is error logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than error.
Is fatal logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than fatal.
Is info logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than info.
Is trace logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than trace.
Is warn logging currently enabled?
- * - * Call this method to prevent having to perform expensive operations
- * (for example, String concatenation)
- * when the log level is more than warn.
Log a message with trace log level.
- * - * @param message log this message - */ - public void trace(Object message); - - - /** - *Log an error with trace log level.
- * - * @param message log this message - * @param t log this cause - */ - public void trace(Object message, Throwable t); - - - /** - *Log a message with debug log level.
- * - * @param message log this message - */ - public void debug(Object message); - - - /** - *Log an error with debug log level.
- * - * @param message log this message - * @param t log this cause - */ - public void debug(Object message, Throwable t); - - - /** - *Log a message with info log level.
- * - * @param message log this message - */ - public void info(Object message); - - - /** - *Log an error with info log level.
- * - * @param message log this message - * @param t log this cause - */ - public void info(Object message, Throwable t); - - - /** - *Log a message with warn log level.
- * - * @param message log this message - */ - public void warn(Object message); - - - /** - *Log an error with warn log level.
- * - * @param message log this message - * @param t log this cause - */ - public void warn(Object message, Throwable t); - - - /** - *Log a message with error log level.
- * - * @param message log this message - */ - public void error(Object message); - - - /** - *Log an error with error log level.
- * - * @param message log this message - * @param t log this cause - */ - public void error(Object message, Throwable t); - - - /** - *Log a message with fatal log level.
- * - * @param message log this message - */ - public void fatal(Object message); - - - /** - *Log an error with fatal log level.
- * - * @param message log this message - * @param t log this cause - */ - public void fatal(Object message, Throwable t); - - -} diff --git a/src/org/apache/commons/logging/LogConfigurationException.java b/src/org/apache/commons/logging/LogConfigurationException.java deleted file mode 100644 index b34387b956117ae494f24e16fac81fd3c45a576c..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/logging/LogConfigurationException.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.logging; - - -/** - *An exception that is thrown only if a suitable LogFactory
- * or Log instance cannot be created by the corresponding
- * factory methods.
null as its detail message.
- */
- public LogConfigurationException() {
-
- super();
-
- }
-
-
- /**
- * Construct a new exception with the specified detail message.
- *
- * @param message The detail message
- */
- public LogConfigurationException(String message) {
-
- super(message);
-
- }
-
-
- /**
- * Construct a new exception with the specified cause and a derived
- * detail message.
- *
- * @param cause The underlying cause
- */
- public LogConfigurationException(Throwable cause) {
-
- this((cause == null) ? null : cause.toString(), cause);
-
- }
-
-
- /**
- * Construct a new exception with the specified detail message and cause.
- *
- * @param message The detail message
- * @param cause The underlying cause
- */
- public LogConfigurationException(String message, Throwable cause) {
-
- super(message + " (Caused by " + cause + ")");
- this.cause = cause; // Two-argument version requires JDK 1.4 or later
-
- }
-
-
- /**
- * The underlying cause of this exception.
- */
- protected Throwable cause = null;
-
-
- /**
- * Return the underlying cause of this exception (if any).
- */
- public Throwable getCause() {
-
- return (this.cause);
-
- }
-
-
-}
diff --git a/src/org/apache/commons/logging/LogFactory.java b/src/org/apache/commons/logging/LogFactory.java
deleted file mode 100644
index 107d0f78a2a2fdc1a68cc22f785a3dff09c7885d..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/logging/LogFactory.java
+++ /dev/null
@@ -1,1740 +0,0 @@
-/*
- * Copyright 2001-2006 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.logging;
-
-
-import java.io.BufferedReader;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-
-
-/**
- * Factory for creating {@link Log} instances, with discovery and - * configuration features similar to that employed by standard Java APIs - * such as JAXP.
- * - *IMPLEMENTATION NOTE - This implementation is heavily - * based on the SAXParserFactory and DocumentBuilderFactory implementations - * (corresponding to the JAXP pluggability APIs) found in Apache Xerces.
- * - * @author Craig R. McClanahan - * @author Costin Manolache - * @author Richard A. Sitze - * @version $Revision: 399431 $ $Date: 2006-05-03 21:58:34 +0100 (Wed, 03 May 2006) $ - */ - -public abstract class LogFactory { - - - // ----------------------------------------------------- Manifest Constants - - /** - * The name (priority) of the key in the config file used to
- * specify the priority of that particular config file. The associated value
- * is a floating-point number; higher values take priority over lower values.
- */
- public static final String PRIORITY_KEY = "priority";
-
- /**
- * The name (use_tccl) of the key in the config file used
- * to specify whether logging classes should be loaded via the thread
- * context class loader (TCCL), or not. By default, the TCCL is used.
- */
- public static final String TCCL_KEY = "use_tccl";
-
- /**
- * The name (org.apache.commons.logging.LogFactory) of the property
- * used to identify the LogFactory implementation
- * class name. This can be used as a system property, or as an entry in a
- * configuration properties file.
- */
- public static final String FACTORY_PROPERTY =
- "org.apache.commons.logging.LogFactory";
-
- /**
- * The fully qualified class name of the fallback LogFactory
- * implementation class to use, if no other can be found.
- */
- public static final String FACTORY_DEFAULT =
- "org.apache.commons.logging.impl.LogFactoryImpl";
-
- /**
- * The name (commons-logging.properties) of the properties file to search for.
- */
- public static final String FACTORY_PROPERTIES =
- "commons-logging.properties";
-
- /**
- * JDK1.3+
- * 'Service Provider' specification.
- *
- */
- protected static final String SERVICE_ID =
- "META-INF/services/org.apache.commons.logging.LogFactory";
-
- /**
- * The name (org.apache.commons.logging.diagnostics.dest)
- * of the property used to enable internal commons-logging
- * diagnostic output, in order to get information on what logging
- * implementations are being discovered, what classloaders they
- * are loaded through, etc.
- * - * If a system property of this name is set then the value is - * assumed to be the name of a file. The special strings - * STDOUT or STDERR (case-sensitive) indicate output to - * System.out and System.err respectively. - *
- * Diagnostic logging should be used only to debug problematic - * configurations and should not be set in normal production use. - */ - public static final String DIAGNOSTICS_DEST_PROPERTY = - "org.apache.commons.logging.diagnostics.dest"; - - /** - * When null (the usual case), no diagnostic output will be - * generated by LogFactory or LogFactoryImpl. When non-null, - * interesting events will be written to the specified object. - */ - private static PrintStream diagnosticsStream = null; - - /** - * A string that gets prefixed to every message output by the - * logDiagnostic method, so that users can clearly see which - * LogFactory class is generating the output. - */ - private static String diagnosticPrefix; - - /** - *
Setting this system property
- * (org.apache.commons.logging.LogFactory.HashtableImpl)
- * value allows the Hashtable used to store
- * classloaders to be substituted by an alternative implementation.
- *
- * Note: LogFactory will print:
- *
- * to system error and then continue using a standard Hashtable.
- *
- * [ERROR] LogFactory: Load of custom hashtable failed
- *
- * Usage: Set this property when Java is invoked
- * and LogFactory will attempt to load a new instance
- * of the given implementation class.
- * For example, running the following ant scriplet:
- *
- * will mean that
- * <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
- * ...
- * <sysproperty
- * key="org.apache.commons.logging.LogFactory.HashtableImpl"
- * value="org.apache.commons.logging.AltHashtable"/>
- * </java>
- * LogFactory will load an instance of
- * org.apache.commons.logging.AltHashtable.
- *
- * A typical use case is to allow a custom - * Hashtable implementation using weak references to be substituted. - * This will allow classloaders to be garbage collected without - * the need to release them (on 1.3+ JVMs only, of course ;) - *
- */ - public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = - "org.apache.commons.logging.LogFactory.HashtableImpl"; - /** Name used to load the weak hashtable implementation by names */ - private static final String WEAK_HASHTABLE_CLASSNAME = - "org.apache.commons.logging.impl.WeakHashtable"; - - /** - * A reference to the classloader that loaded this class. This is the - * same as LogFactory.class.getClassLoader(). However computing this - * value isn't quite as simple as that, as we potentially need to use - * AccessControllers etc. It's more efficient to compute it once and - * cache it here. - */ - private static ClassLoader thisClassLoader; - - // ----------------------------------------------------------- Constructors - - - /** - * Protected constructor that is not available for public use. - */ - protected LogFactory() { - } - - // --------------------------------------------------------- Public Methods - - - /** - * Return the configuration attribute with the specified name (if any), - * ornull if there is no such attribute.
- *
- * @param name Name of the attribute to return
- */
- public abstract Object getAttribute(String name);
-
-
- /**
- * Return an array containing the names of all currently defined
- * configuration attributes. If there are no such attributes, a zero
- * length array is returned.
- */
- public abstract String[] getAttributeNames();
-
-
- /**
- * Convenience method to derive a name from the specified class and
- * call getInstance(String) with it.
- *
- * @param clazz Class for which a suitable Log name will be derived
- *
- * @exception LogConfigurationException if a suitable Log
- * instance cannot be returned
- */
- public abstract Log getInstance(Class clazz)
- throws LogConfigurationException;
-
-
- /**
- * Construct (if necessary) and return a Log instance,
- * using the factory's current set of configuration attributes.
NOTE - Depending upon the implementation of
- * the LogFactory you are using, the Log
- * instance you are returned may or may not be local to the current
- * application, and may or may not be returned again on a subsequent
- * call with the same name argument.
Log instance to be
- * returned (the meaning of this name is only known to the underlying
- * logging implementation that is being wrapped)
- *
- * @exception LogConfigurationException if a suitable Log
- * instance cannot be returned
- */
- public abstract Log getInstance(String name)
- throws LogConfigurationException;
-
-
- /**
- * Release any internal references to previously created {@link Log}
- * instances returned by this factory. This is useful in environments
- * like servlet containers, which implement application reloading by
- * throwing away a ClassLoader. Dangling references to objects in that
- * class loader would prevent garbage collection.
- */
- public abstract void release();
-
-
- /**
- * Remove any configuration attribute associated with the specified name.
- * If there is no such attribute, no action is taken.
- *
- * @param name Name of the attribute to remove
- */
- public abstract void removeAttribute(String name);
-
-
- /**
- * Set the configuration attribute with the specified name. Calling
- * this with a null value is equivalent to calling
- * removeAttribute(name).
- *
- * @param name Name of the attribute to set
- * @param value Value of the attribute to set, or null
- * to remove any setting for this attribute
- */
- public abstract void setAttribute(String name, Object value);
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The previously constructed LogFactory instances, keyed by
- * the ClassLoader with which it was created.
- */
- protected static Hashtable factories = null;
-
- /**
- * Prevously constructed LogFactory instance as in the
- * factories map, but for the case where
- * getClassLoader returns null.
- * This can happen when:
- * factories is a Hashtable (not a HashMap),
- * and hashtables don't allow null as a key.
- */
- protected static LogFactory nullClassLoaderFactory = null;
-
- /**
- * Create the hashtable which will be used to store a map of
- * (context-classloader -> logfactory-object). Version 1.2+ of Java
- * supports "weak references", allowing a custom Hashtable class
- * to be used which uses only weak references to its keys. Using weak
- * references can fix memory leaks on webapp unload in some cases (though
- * not all). Version 1.1 of Java does not support weak references, so we
- * must dynamically determine which we are using. And just for fun, this
- * code also supports the ability for a system property to specify an
- * arbitrary Hashtable implementation name.
- * - * Note that the correct way to ensure no memory leaks occur is to ensure - * that LogFactory.release(contextClassLoader) is called whenever a - * webapp is undeployed. - */ - private static final Hashtable createFactoryStore() { - Hashtable result = null; - String storeImplementationClass - = System.getProperty(HASHTABLE_IMPLEMENTATION_PROPERTY); - if (storeImplementationClass == null) { - storeImplementationClass = WEAK_HASHTABLE_CLASSNAME; - } - try { - Class implementationClass = Class.forName(storeImplementationClass); - result = (Hashtable) implementationClass.newInstance(); - - } catch (Throwable t) { - // ignore - if (!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) { - // if the user's trying to set up a custom implementation, give a clue - if (isDiagnosticsEnabled()) { - // use internal logging to issue the warning - logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed"); - } else { - // we *really* want this output, even if diagnostics weren't - // explicitly enabled by the user. - System.err.println("[ERROR] LogFactory: Load of custom hashtable failed"); - } - } - } - if (result == null) { - result = new Hashtable(); - } - return result; - } - - - // --------------------------------------------------------- Static Methods - - /** - *
Construct (if necessary) and return a LogFactory
- * instance, using the following ordered lookup procedure to determine
- * the name of the implementation class to be loaded.
org.apache.commons.logging.LogFactory system
- * property.commons-logging.properties
- * file, if found in the class path of this class. The configuration
- * file is in standard java.util.Properties format and
- * contains the fully qualified name of the implementation class
- * with the key being the system property defined above.org.apache.commons.logging.impl.LogFactoryImpl).NOTE - If the properties file method of identifying the
- * LogFactory implementation class is utilized, all of the
- * properties defined in this file will be set as configuration attributes
- * on the corresponding LogFactory instance.
NOTE - In a multithreaded environment it is possible - * that two different instances will be returned for the same - * classloader environment. - *
- * - * @exception LogConfigurationException if the implementation class is not - * available or cannot be instantiated. - */ - public static LogFactory getFactory() throws LogConfigurationException { - // Identify the class loader we will be using - ClassLoader contextClassLoader = getContextClassLoader(); - - if (contextClassLoader == null) { - // This is an odd enough situation to report about. This - // output will be a nuisance on JDK1.1, as the system - // classloader is null in that environment. - if (isDiagnosticsEnabled()) { - logDiagnostic("Context classloader is null."); - } - } - - // Return any previously registered factory for this class loader - LogFactory factory = getCachedFactory(contextClassLoader); - if (factory != null) { - return factory; - } - - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] LogFactory implementation requested for the first time for context classloader " - + objectId(contextClassLoader)); - logHierarchy("[LOOKUP] ", contextClassLoader); - } - - // Load properties file. - // - // If the properties file exists, then its contents are used as - // "attributes" on the LogFactory implementation class. One particular - // property may also control which LogFactory concrete subclass is - // used, but only if other discovery mechanisms fail.. - // - // As the properties file (if it exists) will be used one way or - // another in the end we may as well look for it first. - - Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES); - - // Determine whether we will be using the thread context class loader to - // load logging classes or not by checking the loaded properties file (if any). - ClassLoader baseClassLoader = contextClassLoader; - if (props != null) { - String useTCCLStr = props.getProperty(TCCL_KEY); - if (useTCCLStr != null) { - // The Boolean.valueOf(useTCCLStr).booleanValue() formulation - // is required for Java 1.2 compatability. - if (Boolean.valueOf(useTCCLStr).booleanValue() == false) { - // Don't use current context classloader when locating any - // LogFactory or Log classes, just use the class that loaded - // this abstract class. When this class is deployed in a shared - // classpath of a container, it means webapps cannot deploy their - // own logging implementations. It also means that it is up to the - // implementation whether to load library-specific config files - // from the TCCL or not. - baseClassLoader = thisClassLoader; - } - } - } - - // Determine which concrete LogFactory subclass to use. - // First, try a global system property - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Looking for system property [" + FACTORY_PROPERTY - + "] to define the LogFactory subclass to use..."); - } - - try { - String factoryClass = System.getProperty(FACTORY_PROPERTY); - if (factoryClass != null) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Creating an instance of LogFactory class '" + factoryClass - + "' as specified by system property " + FACTORY_PROPERTY); - } - - factory = newFactory(factoryClass, baseClassLoader, contextClassLoader); - } else { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] No system property [" + FACTORY_PROPERTY - + "] defined."); - } - } - } catch (SecurityException e) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] A security exception occurred while trying to create an" - + " instance of the custom factory class" - + ": [" + e.getMessage().trim() - + "]. Trying alternative implementations..."); - } - ; // ignore - } catch(RuntimeException e) { - // This is not consistent with the behaviour when a bad LogFactory class is - // specified in a services file. - // - // One possible exception that can occur here is a ClassCastException when - // the specified class wasn't castable to this LogFactory type. - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] An exception occurred while trying to create an" - + " instance of the custom factory class" - + ": [" + e.getMessage().trim() - + "] as specified by a system property."); - } - throw e; - } - - - // Second, try to find a service by using the JDK1.3 class - // discovery mechanism, which involves putting a file with the name - // of an interface class in the META-INF/services directory, where the - // contents of the file is a single line specifying a concrete class - // that implements the desired interface. - - if (factory == null) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Looking for a resource file of name [" + SERVICE_ID - + "] to define the LogFactory subclass to use..."); - } - try { - InputStream is = getResourceAsStream(contextClassLoader, - SERVICE_ID); - - if( is != null ) { - // This code is needed by EBCDIC and other strange systems. - // It's a fix for bugs reported in xerces - BufferedReader rd; - try { - rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); - } catch (java.io.UnsupportedEncodingException e) { - rd = new BufferedReader(new InputStreamReader(is)); - } - - String factoryClassName = rd.readLine(); - rd.close(); - - if (factoryClassName != null && - ! "".equals(factoryClassName)) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Creating an instance of LogFactory class " + factoryClassName - + " as specified by file '" + SERVICE_ID - + "' which was present in the path of the context" - + " classloader."); - } - factory = newFactory(factoryClassName, baseClassLoader, contextClassLoader ); - } - } else { - // is == null - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] No resource file with name '" + SERVICE_ID - + "' found."); - } - } - } catch( Exception ex ) { - // note: if the specified LogFactory class wasn't compatible with LogFactory - // for some reason, a ClassCastException will be caught here, and attempts will - // continue to find a compatible class. - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] A security exception occurred while trying to create an" - + " instance of the custom factory class" - + ": [" + ex.getMessage().trim() - + "]. Trying alternative implementations..."); - } - ; // ignore - } - } - - - // Third try looking into the properties file read earlier (if found) - - if (factory == null) { - if (props != null) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Looking in properties file for entry with key '" - + FACTORY_PROPERTY - + "' to define the LogFactory subclass to use..."); - } - String factoryClass = props.getProperty(FACTORY_PROPERTY); - if (factoryClass != null) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Properties file specifies LogFactory subclass '" - + factoryClass + "'"); - } - factory = newFactory(factoryClass, baseClassLoader, contextClassLoader); - - // TODO: think about whether we need to handle exceptions from newFactory - } else { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Properties file has no entry specifying LogFactory subclass."); - } - } - } else { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] No properties file available to determine" - + " LogFactory subclass from.."); - } - } - } - - - // Fourth, try the fallback implementation class - - if (factory == null) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Loading the default LogFactory implementation '" + FACTORY_DEFAULT - + "' via the same classloader that loaded this LogFactory" - + " class (ie not looking in the context classloader)."); - } - - // Note: unlike the above code which can try to load custom LogFactory - // implementations via the TCCL, we don't try to load the default LogFactory - // implementation via the context classloader because: - // * that can cause problems (see comments in newFactory method) - // * no-one should be customising the code of the default class - // Yes, we do give up the ability for the child to ship a newer - // version of the LogFactoryImpl class and have it used dynamically - // by an old LogFactory class in the parent, but that isn't - // necessarily a good idea anyway. - factory = newFactory(FACTORY_DEFAULT, thisClassLoader, contextClassLoader); - } - - if (factory != null) { - /** - * Always cache using context class loader. - */ - cacheFactory(contextClassLoader, factory); - - if( props!=null ) { - Enumeration names = props.propertyNames(); - while (names.hasMoreElements()) { - String name = (String) names.nextElement(); - String value = props.getProperty(name); - factory.setAttribute(name, value); - } - } - } - - return factory; - } - - - /** - * Convenience method to return a named logger, without the application - * having to care about factories. - * - * @param clazz Class from which a log name will be derived - * - * @exception LogConfigurationException if a suitableLog
- * instance cannot be returned
- */
- public static Log getLog(Class clazz)
- throws LogConfigurationException {
-
- // BEGIN android-added
- return getLog(clazz.getName());
- // END android-added
- // BEGIN android-deleted
- //return (getFactory().getInstance(clazz));
- // END android-deleted
-
- }
-
-
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
- * @param name Logical name of the Log instance to be
- * returned (the meaning of this name is only known to the underlying
- * logging implementation that is being wrapped)
- *
- * @exception LogConfigurationException if a suitable Log
- * instance cannot be returned
- */
- public static Log getLog(String name)
- throws LogConfigurationException {
-
- // BEGIN android-added
- return new org.apache.commons.logging.impl.Jdk14Logger(name);
- // END android-added
- // BEGIN android-deleted
- //return (getFactory().getInstance(name));
- // END android-deleted
-
- }
-
-
- /**
- * Release any internal references to previously created {@link LogFactory}
- * instances that have been associated with the specified class loader
- * (if any), after calling the instance method release() on
- * each of them.
- *
- * @param classLoader ClassLoader for which to release the LogFactory
- */
- public static void release(ClassLoader classLoader) {
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Releasing factory for classloader " + objectId(classLoader));
- }
- synchronized (factories) {
- if (classLoader == null) {
- if (nullClassLoaderFactory != null) {
- nullClassLoaderFactory.release();
- nullClassLoaderFactory = null;
- }
- } else {
- LogFactory factory = (LogFactory) factories.get(classLoader);
- if (factory != null) {
- factory.release();
- factories.remove(classLoader);
- }
- }
- }
-
- }
-
-
- /**
- * Release any internal references to previously created {@link LogFactory}
- * instances, after calling the instance method release() on
- * each of them. This is useful in environments like servlet containers,
- * which implement application reloading by throwing away a ClassLoader.
- * Dangling references to objects in that class loader would prevent
- * garbage collection.
- */
- public static void releaseAll() {
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Releasing factory for all classloaders.");
- }
- synchronized (factories) {
- Enumeration elements = factories.elements();
- while (elements.hasMoreElements()) {
- LogFactory element = (LogFactory) elements.nextElement();
- element.release();
- }
- factories.clear();
-
- if (nullClassLoaderFactory != null) {
- nullClassLoaderFactory.release();
- nullClassLoaderFactory = null;
- }
- }
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
- /**
- * Safely get access to the classloader for the specified class.
- * - * Theoretically, calling getClassLoader can throw a security exception, - * and so should be done under an AccessController in order to provide - * maximum flexibility. However in practice people don't appear to use - * security policies that forbid getClassLoader calls. So for the moment - * all code is written to call this method rather than Class.getClassLoader, - * so that we could put AccessController stuff in this method without any - * disruption later if we need to. - *
- * Even when using an AccessController, however, this method can still - * throw SecurityException. Commons-logging basically relies on the - * ability to access classloaders, ie a policy that forbids all - * classloader access will also prevent commons-logging from working: - * currently this method will throw an exception preventing the entire app - * from starting up. Maybe it would be good to detect this situation and - * just disable all commons-logging? Not high priority though - as stated - * above, security policies that prevent classloader access aren't common. - * - * @since 1.1 - */ - protected static ClassLoader getClassLoader(Class clazz) { - try { - return clazz.getClassLoader(); - } catch(SecurityException ex) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "Unable to get classloader for class '" + clazz - + "' due to security restrictions - " + ex.getMessage()); - } - throw ex; - } - } - - /** - * Calls LogFactory.directGetContextClassLoader under the control of an - * AccessController class. This means that java code running under a - * security manager that forbids access to ClassLoaders will still work - * if this class is given appropriate privileges, even when the caller - * doesn't have such privileges. Without using an AccessController, the - * the entire call stack must have the privilege before the call is - * allowed. - * - * @return the context classloader associated with the current thread, - * or null if security doesn't allow it. - * - * @throws LogConfigurationException if there was some weird error while - * attempting to get the context classloader. - * - * @throws SecurityException if the current java security policy doesn't - * allow this class to access the context classloader. - */ - protected static ClassLoader getContextClassLoader() - throws LogConfigurationException { - - return (ClassLoader)AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return directGetContextClassLoader(); - } - }); - } - - /** - * Return the thread context class loader if available; otherwise return - * null. - *
- * Most/all code should call getContextClassLoader rather than calling - * this method directly. - *
- * The thread context class loader is available for JDK 1.2 - * or later, if certain security conditions are met. - *
- * Note that no internal logging is done within this method because
- * this method is called every time LogFactory.getLogger() is called,
- * and we don't want too much output generated here.
- *
- * @exception LogConfigurationException if a suitable class loader
- * cannot be identified.
- *
- * @exception SecurityException if the java security policy forbids
- * access to the context classloader from one of the classes in the
- * current call stack.
- * @since 1.1
- */
- protected static ClassLoader directGetContextClassLoader()
- throws LogConfigurationException
- {
- ClassLoader classLoader = null;
-
- try {
- // Are we running on a JDK 1.2 or later system?
- Method method = Thread.class.getMethod("getContextClassLoader",
- (Class[]) null);
-
- // Get the thread context class loader (if there is one)
- try {
- classLoader = (ClassLoader)method.invoke(Thread.currentThread(),
- (Object[]) null);
- } catch (IllegalAccessException e) {
- throw new LogConfigurationException
- ("Unexpected IllegalAccessException", e);
- } catch (InvocationTargetException e) {
- /**
- * InvocationTargetException is thrown by 'invoke' when
- * the method being invoked (getContextClassLoader) throws
- * an exception.
- *
- * getContextClassLoader() throws SecurityException when
- * the context class loader isn't an ancestor of the
- * calling class's class loader, or if security
- * permissions are restricted.
- *
- * In the first case (not related), we want to ignore and
- * keep going. We cannot help but also ignore the second
- * with the logic below, but other calls elsewhere (to
- * obtain a class loader) will trigger this exception where
- * we can make a distinction.
- */
- if (e.getTargetException() instanceof SecurityException) {
- ; // ignore
- } else {
- // Capture 'e.getTargetException()' exception for details
- // alternate: log 'e.getTargetException()', and pass back 'e'.
- throw new LogConfigurationException
- ("Unexpected InvocationTargetException", e.getTargetException());
- }
- }
- } catch (NoSuchMethodException e) {
- // Assume we are running on JDK 1.1
- classLoader = getClassLoader(LogFactory.class);
-
- // We deliberately don't log a message here to outputStream;
- // this message would be output for every call to LogFactory.getLog()
- // when running on JDK1.1
- //
- // if (outputStream != null) {
- // outputStream.println(
- // "Method Thread.getContextClassLoader does not exist;"
- // + " assuming this is JDK 1.1, and that the context"
- // + " classloader is the same as the class that loaded"
- // + " the concrete LogFactory class.");
- // }
-
- }
-
- // Return the selected class loader
- return classLoader;
- }
-
- /**
- * Check cached factories (keyed by contextClassLoader)
- *
- * @param contextClassLoader is the context classloader associated
- * with the current thread. This allows separate LogFactory objects
- * per component within a container, provided each component has
- * a distinct context classloader set. This parameter may be null
- * in JDK1.1, and in embedded systems where jcl-using code is
- * placed in the bootclasspath.
- *
- * @return the factory associated with the specified classloader if
- * one has previously been created, or null if this is the first time
- * we have seen this particular classloader.
- */
- private static LogFactory getCachedFactory(ClassLoader contextClassLoader)
- {
- LogFactory factory = null;
-
- if (contextClassLoader == null) {
- // We have to handle this specially, as factories is a Hashtable
- // and those don't accept null as a key value.
- //
- // nb: nullClassLoaderFactory might be null. That's ok.
- factory = nullClassLoaderFactory;
- } else {
- factory = (LogFactory) factories.get(contextClassLoader);
- }
-
- return factory;
- }
-
- /**
- * Remember this factory, so later calls to LogFactory.getCachedFactory
- * can return the previously created object (together with all its
- * cached Log objects).
- *
- * @param classLoader should be the current context classloader. Note that
- * this can be null under some circumstances; this is ok.
- *
- * @param factory should be the factory to cache. This should never be null.
- */
- private static void cacheFactory(ClassLoader classLoader, LogFactory factory)
- {
- // Ideally we would assert(factory != null) here. However reporting
- // errors from within a logging implementation is a little tricky!
-
- if (factory != null) {
- if (classLoader == null) {
- nullClassLoaderFactory = factory;
- } else {
- factories.put(classLoader, factory);
- }
- }
- }
-
- /**
- * Return a new instance of the specified LogFactory
- * implementation class, loaded by the specified class loader.
- * If that fails, try the class loader used to load this
- * (abstract) LogFactory.
- *
- *
- * The problem is the same one that can occur when loading a concrete Log - * subclass via a context classloader. - *
- * The problem occurs when code running in the context classloader calls - * class X which was loaded via a parent classloader, and class X then calls - * LogFactory.getFactory (either directly or via LogFactory.getLog). Because - * class X was loaded via the parent, it binds to LogFactory loaded via - * the parent. When the code in this method finds some LogFactoryYYYY - * class in the child (context) classloader, and there also happens to be a - * LogFactory class defined in the child classloader, then LogFactoryYYYY - * will be bound to LogFactory@childloader. It cannot be cast to - * LogFactory@parentloader, ie this method cannot return the object as - * the desired type. Note that it doesn't matter if the LogFactory class - * in the child classloader is identical to the LogFactory class in the - * parent classloader, they are not compatible. - *
- * The solution taken here is to simply print out an error message when - * this occurs then throw an exception. The deployer of the application - * must ensure they remove all occurrences of the LogFactory class from - * the child classloader in order to resolve the issue. Note that they - * do not have to move the custom LogFactory subclass; that is ok as - * long as the only LogFactory class it can find to bind to is in the - * parent classloader. - *
- * @param factoryClass Fully qualified name of the LogFactory
- * implementation class
- * @param classLoader ClassLoader from which to load this class
- * @param contextClassLoader is the context that this new factory will
- * manage logging for.
- *
- * @exception LogConfigurationException if a suitable instance
- * cannot be created
- * @since 1.1
- */
- protected static LogFactory newFactory(final String factoryClass,
- final ClassLoader classLoader,
- final ClassLoader contextClassLoader)
- throws LogConfigurationException
- {
- // Note that any unchecked exceptions thrown by the createFactory
- // method will propagate out of this method; in particular a
- // ClassCastException can be thrown.
- Object result = AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return createFactory(factoryClass, classLoader);
- }
- });
-
- if (result instanceof LogConfigurationException) {
- LogConfigurationException ex = (LogConfigurationException) result;
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "An error occurred while loading the factory class:"
- + ex.getMessage());
- }
- throw ex;
- }
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Created object " + objectId(result)
- + " to manage classloader " + objectId(contextClassLoader));
- }
- return (LogFactory)result;
- }
-
- /**
- * Method provided for backwards compatibility; see newFactory version that
- * takes 3 parameters.
- *
- * This method would only ever be called in some rather odd situation.
- * Note that this method is static, so overriding in a subclass doesn't
- * have any effect unless this method is called from a method in that
- * subclass. However this method only makes sense to use from the
- * getFactory method, and as that is almost always invoked via
- * LogFactory.getFactory, any custom definition in a subclass would be
- * pointless. Only a class with a custom getFactory method, then invoked
- * directly via CustomFactoryImpl.getFactory or similar would ever call
- * this. Anyway, it's here just in case, though the "managed class loader"
- * value output to the diagnostics will not report the correct value.
- */
- protected static LogFactory newFactory(final String factoryClass,
- final ClassLoader classLoader) {
- return newFactory(factoryClass, classLoader, null);
- }
-
- /**
- * Implements the operations described in the javadoc for newFactory.
- *
- * @param factoryClass
- *
- * @param classLoader used to load the specified factory class. This is
- * expected to be either the TCCL or the classloader which loaded this
- * class. Note that the classloader which loaded this class might be
- * "null" (ie the bootloader) for embedded systems.
- *
- * @return either a LogFactory object or a LogConfigurationException object.
- * @since 1.1
- */
- protected static Object createFactory(String factoryClass, ClassLoader classLoader) {
-
- // This will be used to diagnose bad configurations
- // and allow a useful message to be sent to the user
- Class logFactoryClass = null;
- try {
- if (classLoader != null) {
- try {
- // First the given class loader param (thread class loader)
-
- // Warning: must typecast here & allow exception
- // to be generated/caught & recast properly.
- logFactoryClass = classLoader.loadClass(factoryClass);
- if (LogFactory.class.isAssignableFrom(logFactoryClass)) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Loaded class " + logFactoryClass.getName()
- + " from classloader " + objectId(classLoader));
- }
- } else {
- //
- // This indicates a problem with the ClassLoader tree.
- // An incompatible ClassLoader was used to load the
- // implementation.
- // As the same classes
- // must be available in multiple class loaders,
- // it is very likely that multiple JCL jars are present.
- // The most likely fix for this
- // problem is to remove the extra JCL jars from the
- // ClassLoader hierarchy.
- //
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Factory class " + logFactoryClass.getName()
- + " loaded from classloader " + objectId(logFactoryClass.getClassLoader())
- + " does not extend '" + LogFactory.class.getName()
- + "' as loaded by this classloader.");
- logHierarchy("[BAD CL TREE] ", classLoader);
- }
- }
-
- return (LogFactory) logFactoryClass.newInstance();
-
- } catch (ClassNotFoundException ex) {
- if (classLoader == thisClassLoader) {
- // Nothing more to try, onwards.
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Unable to locate any class called '" + factoryClass
- + "' via classloader " + objectId(classLoader));
- }
- throw ex;
- }
- // ignore exception, continue
- } catch (NoClassDefFoundError e) {
- if (classLoader == thisClassLoader) {
- // Nothing more to try, onwards.
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Class '" + factoryClass + "' cannot be loaded"
- + " via classloader " + objectId(classLoader)
- + " - it depends on some other class that cannot"
- + " be found.");
- }
- throw e;
- }
- // ignore exception, continue
- } catch(ClassCastException e) {
- if (classLoader == thisClassLoader) {
- // There's no point in falling through to the code below that
- // tries again with thisClassLoader, because we've just tried
- // loading with that loader (not the TCCL). Just throw an
- // appropriate exception here.
-
- final boolean implementsLogFactory = implementsLogFactory(logFactoryClass);
-
- //
- // Construct a good message: users may not actual expect that a custom implementation
- // has been specified. Several well known containers use this mechanism to adapt JCL
- // to their native logging system.
- //
- String msg =
- "The application has specified that a custom LogFactory implementation should be used but " +
- "Class '" + factoryClass + "' cannot be converted to '"
- + LogFactory.class.getName() + "'. ";
- if (implementsLogFactory) {
- msg = msg + "The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. " +
- "Background can be found in http://jakarta.apache.org/commons/logging/tech.html. " +
- "If you have not explicitly specified a custom LogFactory then it is likely that " +
- "the container has set one without your knowledge. " +
- "In this case, consider using the commons-logging-adapters.jar file or " +
- "specifying the standard LogFactory from the command line. ";
- } else {
- msg = msg + "Please check the custom implementation. ";
- }
- msg = msg + "Help can be found @http://jakarta.apache.org/commons/logging/troubleshooting.html.";
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic(msg);
- }
-
- ClassCastException ex = new ClassCastException(msg);
- throw ex;
- }
-
- // Ignore exception, continue. Presumably the classloader was the
- // TCCL; the code below will try to load the class via thisClassLoader.
- // This will handle the case where the original calling class is in
- // a shared classpath but the TCCL has a copy of LogFactory and the
- // specified LogFactory implementation; we will fall back to using the
- // LogFactory implementation from the same classloader as this class.
- //
- // Issue: this doesn't handle the reverse case, where this LogFactory
- // is in the webapp, and the specified LogFactory implementation is
- // in a shared classpath. In that case:
- // (a) the class really does implement LogFactory (bad log msg above)
- // (b) the fallback code will result in exactly the same problem.
- }
- }
-
- /* At this point, either classLoader == null, OR
- * classLoader was unable to load factoryClass.
- *
- * In either case, we call Class.forName, which is equivalent
- * to LogFactory.class.getClassLoader().load(name), ie we ignore
- * the classloader parameter the caller passed, and fall back
- * to trying the classloader associated with this class. See the
- * javadoc for the newFactory method for more info on the
- * consequences of this.
- *
- * Notes:
- * * LogFactory.class.getClassLoader() may return 'null'
- * if LogFactory is loaded by the bootstrap classloader.
- */
- // Warning: must typecast here & allow exception
- // to be generated/caught & recast properly.
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Unable to load factory class via classloader "
- + objectId(classLoader)
- + " - trying the classloader associated with this LogFactory.");
- }
- logFactoryClass = Class.forName(factoryClass);
- return (LogFactory) logFactoryClass.newInstance();
- } catch (Exception e) {
- // Check to see if we've got a bad configuration
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Unable to create LogFactory instance.");
- }
- if (logFactoryClass != null
- && !LogFactory.class.isAssignableFrom(logFactoryClass)) {
-
- return new LogConfigurationException(
- "The chosen LogFactory implementation does not extend LogFactory."
- + " Please check your configuration.",
- e);
- }
- return new LogConfigurationException(e);
- }
- }
-
- /**
- * Determines whether the given class actually implements LogFactory.
- * Diagnostic information is also logged.
- *
- * Usage: to diagnose whether a classloader conflict is the cause
- * of incompatibility. The test used is whether the class is assignable from
- * the LogFactory class loaded by the class's classloader.
- * @param logFactoryClass Class which may implement LogFactory
- * @return true if the logFactoryClass does extend
- * LogFactory when that class is loaded via the same
- * classloader that loaded the logFactoryClass.
- */
- private static boolean implementsLogFactory(Class logFactoryClass) {
- boolean implementsLogFactory = false;
- if (logFactoryClass != null) {
- try {
- ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
- if (logFactoryClassLoader == null) {
- logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
- } else {
- logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
- Class factoryFromCustomLoader
- = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
- implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
- if (implementsLogFactory) {
- logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName()
- + " implements LogFactory but was loaded by an incompatible classloader.");
- } else {
- logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName()
- + " does not implement LogFactory.");
- }
- }
- } catch (SecurityException e) {
- //
- // The application is running within a hostile security environment.
- // This will make it very hard to diagnose issues with JCL.
- // Consider running less securely whilst debugging this issue.
- //
- logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " +
- "the compatibility was caused by a classloader conflict: "
- + e.getMessage());
- } catch (LinkageError e) {
- //
- // This should be an unusual circumstance.
- // LinkageError's usually indicate that a dependent class has incompatibly changed.
- // Another possibility may be an exception thrown by an initializer.
- // Time for a clean rebuild?
- //
- logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " +
- "the compatibility was caused by a classloader conflict: "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- //
- // LogFactory cannot be loaded by the classloader which loaded the custom factory implementation.
- // The custom implementation is not viable until this is corrected.
- // Ensure that the JCL jar and the custom class are available from the same classloader.
- // Running with diagnostics on should give information about the classloaders used
- // to load the custom factory.
- //
- logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded the " +
- "custom LogFactory implementation. Is the custom factory in the right classloader?");
- }
- }
- return implementsLogFactory;
- }
-
- /**
- * Applets may run in an environment where accessing resources of a loader is
- * a secure operation, but where the commons-logging library has explicitly
- * been granted permission for that operation. In this case, we need to
- * run the operation using an AccessController.
- */
- private static InputStream getResourceAsStream(final ClassLoader loader,
- final String name)
- {
- return (InputStream)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- if (loader != null) {
- return loader.getResourceAsStream(name);
- } else {
- return ClassLoader.getSystemResourceAsStream(name);
- }
- }
- });
- }
-
- /**
- * Given a filename, return an enumeration of URLs pointing to
- * all the occurrences of that filename in the classpath.
- *
- * This is just like ClassLoader.getResources except that the - * operation is done under an AccessController so that this method will - * succeed when this jarfile is privileged but the caller is not. - * This method must therefore remain private to avoid security issues. - *
- * If no instances are found, an Enumeration is returned whose - * hasMoreElements method returns false (ie an "empty" enumeration). - * If resources could not be listed for some reason, null is returned. - */ - private static Enumeration getResources(final ClassLoader loader, - final String name) - { - PrivilegedAction action = - new PrivilegedAction() { - public Object run() { - try { - if (loader != null) { - return loader.getResources(name); - } else { - return ClassLoader.getSystemResources(name); - } - } catch(IOException e) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "Exception while trying to find configuration file " - + name + ":" + e.getMessage()); - } - return null; - } catch(NoSuchMethodError e) { - // we must be running on a 1.1 JVM which doesn't support - // ClassLoader.getSystemResources; just return null in - // this case. - return null; - } - } - }; - Object result = AccessController.doPrivileged(action); - return (Enumeration) result; - } - - /** - * Given a URL that refers to a .properties file, load that file. - * This is done under an AccessController so that this method will - * succeed when this jarfile is privileged but the caller is not. - * This method must therefore remain private to avoid security issues. - *
- * Null is returned if the URL cannot be opened. - */ - private static Properties getProperties(final URL url) { - PrivilegedAction action = - new PrivilegedAction() { - public Object run() { - try { - InputStream stream = url.openStream(); - if (stream != null) { - Properties props = new Properties(); - props.load(stream); - stream.close(); - return props; - } - } catch(IOException e) { - if (isDiagnosticsEnabled()) { - logDiagnostic("Unable to read URL " + url); - } - } - - return null; - } - }; - return (Properties) AccessController.doPrivileged(action); - } - - /** - * Locate a user-provided configuration file. - *
- * The classpath of the specified classLoader (usually the context classloader) - * is searched for properties files of the specified name. If none is found, - * null is returned. If more than one is found, then the file with the greatest - * value for its PRIORITY property is returned. If multiple files have the - * same PRIORITY value then the first in the classpath is returned. - *
- * This differs from the 1.0.x releases; those always use the first one found. - * However as the priority is a new field, this change is backwards compatible. - *
- * The purpose of the priority field is to allow a webserver administrator to - * override logging settings in all webapps by placing a commons-logging.properties - * file in a shared classpath location with a priority > 0; this overrides any - * commons-logging.properties files without priorities which are in the - * webapps. Webapps can also use explicit priorities to override a configuration - * file in the shared classpath if needed. - */ - private static final Properties getConfigurationFile( - ClassLoader classLoader, String fileName) { - - Properties props = null; - double priority = 0.0; - URL propsUrl = null; - try { - Enumeration urls = getResources(classLoader, fileName); - - if (urls == null) { - return null; - } - - while (urls.hasMoreElements()) { - URL url = (URL) urls.nextElement(); - - Properties newProps = getProperties(url); - if (newProps != null) { - if (props == null) { - propsUrl = url; - props = newProps; - String priorityStr = props.getProperty(PRIORITY_KEY); - priority = 0.0; - if (priorityStr != null) { - priority = Double.parseDouble(priorityStr); - } - - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Properties file found at '" + url + "'" - + " with priority " + priority); - } - } else { - String newPriorityStr = newProps.getProperty(PRIORITY_KEY); - double newPriority = 0.0; - if (newPriorityStr != null) { - newPriority = Double.parseDouble(newPriorityStr); - } - - if (newPriority > priority) { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Properties file at '" + url + "'" - + " with priority " + newPriority - + " overrides file at '" + propsUrl + "'" - + " with priority " + priority); - } - - propsUrl = url; - props = newProps; - priority = newPriority; - } else { - if (isDiagnosticsEnabled()) { - logDiagnostic( - "[LOOKUP] Properties file at '" + url + "'" - + " with priority " + newPriority - + " does not override file at '" + propsUrl + "'" - + " with priority " + priority); - } - } - } - - } - } - } catch (SecurityException e) { - if (isDiagnosticsEnabled()) { - logDiagnostic("SecurityException thrown while trying to find/read config files."); - } - } - - if (isDiagnosticsEnabled()) { - if (props == null) { - logDiagnostic( - "[LOOKUP] No properties file of name '" + fileName - + "' found."); - } else { - logDiagnostic( - "[LOOKUP] Properties file of name '" + fileName - + "' found at '" + propsUrl + '"'); - } - } - - return props; - } - - /** - * Determines whether the user wants internal diagnostic output. If so, - * returns an appropriate writer object. Users can enable diagnostic - * output by setting the system property named {@link #DIAGNOSTICS_DEST_PROPERTY} to - * a filename, or the special values STDOUT or STDERR. - */ - private static void initDiagnostics() { - String dest; - try { - dest = System.getProperty(DIAGNOSTICS_DEST_PROPERTY); - if (dest == null) { - return; - } - } catch(SecurityException ex) { - // We must be running in some very secure environment. - // We just have to assume output is not wanted.. - return; - } - - if (dest.equals("STDOUT")) { - diagnosticsStream = System.out; - } else if (dest.equals("STDERR")) { - diagnosticsStream = System.err; - } else { - try { - // open the file in append mode - FileOutputStream fos = new FileOutputStream(dest, true); - diagnosticsStream = new PrintStream(fos); - } catch(IOException ex) { - // We should report this to the user - but how? - return; - } - } - - // In order to avoid confusion where multiple instances of JCL are - // being used via different classloaders within the same app, we - // ensure each logged message has a prefix of form - // [LogFactory from classloader OID] - // - // Note that this prefix should be kept consistent with that - // in LogFactoryImpl. However here we don't need to output info - // about the actual *instance* of LogFactory, as all methods that - // output diagnostics from this class are static. - String classLoaderName; - try { - ClassLoader classLoader = thisClassLoader; - if (thisClassLoader == null) { - classLoaderName = "BOOTLOADER"; - } else { - classLoaderName = objectId(classLoader); - } - } catch(SecurityException e) { - classLoaderName = "UNKNOWN"; - } - diagnosticPrefix = "[LogFactory from " + classLoaderName + "] "; - } - - /** - * Indicates true if the user has enabled internal logging. - *
- * By the way, sorry for the incorrect grammar, but calling this method - * areDiagnosticsEnabled just isn't java beans style. - * - * @return true if calls to logDiagnostic will have any effect. - * @since 1.1 - */ - protected static boolean isDiagnosticsEnabled() { - return diagnosticsStream != null; - } - - /** - * Write the specified message to the internal logging destination. - *
- * Note that this method is private; concrete subclasses of this class - * should not call it because the diagnosticPrefix string this - * method puts in front of all its messages is LogFactory@...., - * while subclasses should put SomeSubClass@... - *
- * Subclasses should instead compute their own prefix, then call - * logRawDiagnostic. Note that calling isDiagnosticsEnabled is - * fine for subclasses. - *
- * Note that it is safe to call this method before initDiagnostics - * is called; any output will just be ignored (as isDiagnosticsEnabled - * will return false). - * - * @param msg is the diagnostic message to be output. - */ - private static final void logDiagnostic(String msg) { - if (diagnosticsStream != null) { - diagnosticsStream.print(diagnosticPrefix); - diagnosticsStream.println(msg); - diagnosticsStream.flush(); - } - } - - /** - * Write the specified message to the internal logging destination. - * - * @param msg is the diagnostic message to be output. - * @since 1.1 - */ - protected static final void logRawDiagnostic(String msg) { - if (diagnosticsStream != null) { - diagnosticsStream.println(msg); - diagnosticsStream.flush(); - } - } - - /** - * Generate useful diagnostics regarding the classloader tree for - * the specified class. - *
- * As an example, if the specified class was loaded via a webapp's - * classloader, then you may get the following output: - *
- * Class com.acme.Foo was loaded via classloader 11111 - * ClassLoader tree: 11111 -> 22222 (SYSTEM) -> 33333 -> BOOT - *- *
- * This method returns immediately if isDiagnosticsEnabled() - * returns false. - * - * @param clazz is the class whose classloader + tree are to be - * output. - */ - private static void logClassLoaderEnvironment(Class clazz) { - if (!isDiagnosticsEnabled()) { - return; - } - - try { - logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir")); - logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path")); - } catch(SecurityException ex) { - logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths."); - } - - String className = clazz.getName(); - ClassLoader classLoader; - - try { - classLoader = getClassLoader(clazz); - } catch(SecurityException ex) { - // not much useful diagnostics we can print here! - logDiagnostic( - "[ENV] Security forbids determining the classloader for " + className); - return; - } - - logDiagnostic( - "[ENV] Class " + className + " was loaded via classloader " - + objectId(classLoader)); - logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader); - } - - /** - * Logs diagnostic messages about the given classloader - * and it's hierarchy. The prefix is prepended to the message - * and is intended to make it easier to understand the logs. - * @param prefix - * @param classLoader - */ - private static void logHierarchy(String prefix, ClassLoader classLoader) { - if (!isDiagnosticsEnabled()) { - return; - } - ClassLoader systemClassLoader; - if (classLoader != null) { - final String classLoaderString = classLoader.toString(); - logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'"); - } - - try { - systemClassLoader = ClassLoader.getSystemClassLoader(); - } catch(SecurityException ex) { - logDiagnostic( - prefix + "Security forbids determining the system classloader."); - return; - } - if (classLoader != null) { - StringBuffer buf = new StringBuffer(prefix + "ClassLoader tree:"); - for(;;) { - buf.append(objectId(classLoader)); - if (classLoader == systemClassLoader) { - buf.append(" (SYSTEM) "); - } - - try { - classLoader = classLoader.getParent(); - } catch(SecurityException ex) { - buf.append(" --> SECRET"); - break; - } - - buf.append(" --> "); - if (classLoader == null) { - buf.append("BOOT"); - break; - } - } - logDiagnostic(buf.toString()); - } - } - - /** - * Returns a string that uniquely identifies the specified object, including - * its class. - *
- * The returned string is of form "classname@hashcode", ie is the same as - * the return value of the Object.toString() method, but works even when - * the specified object's class has overidden the toString method. - * - * @param o may be null. - * @return a string of form classname@hashcode, or "null" if param o is null. - * @since 1.1 - */ - public static String objectId(Object o) { - if (o == null) { - return "null"; - } else { - return o.getClass().getName() + "@" + System.identityHashCode(o); - } - } - - // ---------------------------------------------------------------------- - // Static initialiser block to perform initialisation at class load time. - // - // We can't do this in the class constructor, as there are many - // static methods on this class that can be called before any - // LogFactory instances are created, and they depend upon this - // stuff having been set up. - // - // Note that this block must come after any variable declarations used - // by any methods called from this block, as we want any static initialiser - // associated with the variable to run first. If static initialisers for - // variables run after this code, then (a) their value might be needed - // by methods called from here, and (b) they might *override* any value - // computed here! - // - // So the wisest thing to do is just to place this code at the very end - // of the class file. - // ---------------------------------------------------------------------- - - static { - // note: it's safe to call methods before initDiagnostics. - thisClassLoader = getClassLoader(LogFactory.class); - initDiagnostics(); - logClassLoaderEnvironment(LogFactory.class); - factories = createFactoryStore(); - if (isDiagnosticsEnabled()) { - logDiagnostic("BOOTSTRAP COMPLETED"); - } - } -} diff --git a/src/org/apache/commons/logging/LogSource.java b/src/org/apache/commons/logging/LogSource.java deleted file mode 100644 index e3c0603783c36cc6face729c6704d48d0103de01..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/logging/LogSource.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - -package org.apache.commons.logging; - - -import java.lang.reflect.Constructor; -import java.util.Hashtable; - -import org.apache.commons.logging.impl.NoOpLog; - - -/** - *
Factory for creating {@link Log} instances. Applications should call
- * the makeNewLogInstance() method to instantiate new instances
- * of the configured {@link Log} implementation class.
By default, calling getInstance() will use the following
- * algorithm:
org.apache.commons.logging.impl.Log4JLogger.org.apache.commons.logging.impl.Jdk14Logger.org.apache.commons.logging.impl.NoOpLog.You can change the default behavior in one of two ways:
- *org.apache.commons.logging.log to the name of the
- * org.apache.commons.logging.Log implementation class
- * you want to use.LogSource.setLogImplementation().Log instance by class name */
- static public Log getInstance(String name) {
- Log log = (Log) (logs.get(name));
- if (null == log) {
- log = makeNewLogInstance(name);
- logs.put(name, log);
- }
- return log;
- }
-
-
- /** Get a Log instance by class */
- static public Log getInstance(Class clazz) {
- return getInstance(clazz.getName());
- }
-
-
- /**
- * Create a new {@link Log} implementation, based
- * on the given name.
- * - * The specific {@link Log} implementation returned - * is determined by the value of the - * org.apache.commons.logging.log property. - * The value of org.apache.commons.logging.log may be set to - * the fully specified name of a class that implements - * the {@link Log} interface. This class must also - * have a public constructor that takes a single - * {@link String} argument (containing the name - * of the {@link Log} to be constructed. - *
- * When org.apache.commons.logging.log is not set, - * or when no corresponding class can be found, - * this method will return a Log4JLogger - * if the log4j Logger class is - * available in the {@link LogSource}'s classpath, or a - * Jdk14Logger if we are on a JDK 1.4 or later system, or - * NoOpLog if neither of the above conditions is true. - * - * @param name the log name (or category) - */ - static public Log makeNewLogInstance(String name) { - - Log log = null; - try { - Object[] args = new Object[1]; - args[0] = name; - log = (Log) (logImplctor.newInstance(args)); - } catch (Throwable t) { - log = null; - } - if (null == log) { - log = new NoOpLog(name); - } - return log; - - } - - - /** - * Returns a {@link String} array containing the names of - * all logs known to me. - */ - static public String[] getLogNames() { - return (String[]) (logs.keySet().toArray(new String[logs.size()])); - } - - -} diff --git a/src/org/apache/commons/logging/impl/Jdk14Logger.java b/src/org/apache/commons/logging/impl/Jdk14Logger.java deleted file mode 100644 index d4f840c9758df7117b9048797af5b07252128f54..0000000000000000000000000000000000000000 --- a/src/org/apache/commons/logging/impl/Jdk14Logger.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * 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. - */ - - -package org.apache.commons.logging.impl; - - -import java.io.Serializable; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.commons.logging.Log; - - -/** - *
Implementation of the org.apache.commons.logging.Log
- * interface that wraps the standard JDK logging mechanisms that were
- * introduced in the Merlin release (JDK 1.4).
java.util.logging.Level.FINE.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#debug(Object)
- */
- public void debug(Object message) {
- log(Level.FINE, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.FINE.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#debug(Object, Throwable)
- */
- public void debug(Object message, Throwable exception) {
- log(Level.FINE, String.valueOf(message), exception);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.SEVERE.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#error(Object)
- */
- public void error(Object message) {
- log(Level.SEVERE, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.SEVERE.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#error(Object, Throwable)
- */
- public void error(Object message, Throwable exception) {
- log(Level.SEVERE, String.valueOf(message), exception);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.SEVERE.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#fatal(Object)
- */
- public void fatal(Object message) {
- log(Level.SEVERE, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.SEVERE.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
- */
- public void fatal(Object message, Throwable exception) {
- log(Level.SEVERE, String.valueOf(message), exception);
- }
-
-
- /**
- * Return the native Logger instance we are using.
- */
- public Logger getLogger() {
- if (logger == null) {
- logger = Logger.getLogger(name);
- }
- return (logger);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.INFO.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#info(Object)
- */
- public void info(Object message) {
- log(Level.INFO, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.INFO.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#info(Object, Throwable)
- */
- public void info(Object message, Throwable exception) {
- log(Level.INFO, String.valueOf(message), exception);
- }
-
-
- /**
- * Is debug logging currently enabled?
- */
- public boolean isDebugEnabled() {
- return (getLogger().isLoggable(Level.FINE));
- }
-
-
- /**
- * Is error logging currently enabled?
- */
- public boolean isErrorEnabled() {
- return (getLogger().isLoggable(Level.SEVERE));
- }
-
-
- /**
- * Is fatal logging currently enabled?
- */
- public boolean isFatalEnabled() {
- return (getLogger().isLoggable(Level.SEVERE));
- }
-
-
- /**
- * Is info logging currently enabled?
- */
- public boolean isInfoEnabled() {
- return (getLogger().isLoggable(Level.INFO));
- }
-
-
- /**
- * Is trace logging currently enabled?
- */
- public boolean isTraceEnabled() {
- return (getLogger().isLoggable(Level.FINEST));
- }
-
-
- /**
- * Is warn logging currently enabled?
- */
- public boolean isWarnEnabled() {
- return (getLogger().isLoggable(Level.WARNING));
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.FINEST.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#trace(Object)
- */
- public void trace(Object message) {
- log(Level.FINEST, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.FINEST.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#trace(Object, Throwable)
- */
- public void trace(Object message, Throwable exception) {
- log(Level.FINEST, String.valueOf(message), exception);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.WARNING.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#warn(Object)
- */
- public void warn(Object message) {
- log(Level.WARNING, String.valueOf(message), null);
- }
-
-
- /**
- * Logs a message with java.util.logging.Level.WARNING.
- *
- * @param message to log
- * @param exception log this cause
- * @see org.apache.commons.logging.Log#warn(Object, Throwable)
- */
- public void warn(Object message, Throwable exception) {
- log(Level.WARNING, String.valueOf(message), exception);
- }
-
-
-}
diff --git a/src/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/org/apache/commons/logging/impl/LogFactoryImpl.java
deleted file mode 100644
index 8937b2f6372e936b6c42e862052c8a7c8cfa97b9..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ /dev/null
@@ -1,1400 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-package org.apache.commons.logging.impl;
-
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogConfigurationException;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Concrete subclass of {@link LogFactory} that implements the - * following algorithm to dynamically select a logging implementation - * class to instantiate a wrapper for.
- *org.apache.commons.logging.Log to identify the
- * requested implementation class.org.apache.commons.logging.Log system property
- * to identify the requested implementation class.org.apache.commons.logging.impl.Log4JLogger.org.apache.commons.logging.impl.Jdk14Logger.org.apache.commons.logging.impl.SimpleLog.If the selected {@link Log} implementation class has a
- * setLogFactory() method that accepts a {@link LogFactory}
- * parameter, this method will be called on each newly created instance
- * to identify the associated factory. This makes factory configuration
- * attributes available to the Log instance, if it so desires.
This factory will remember previously created Log instances
- * for the same name, and will return them on repeated requests to the
- * getInstance() method.
org.apache.commons.logging.Log) of the system
- * property identifying our {@link Log} implementation class.
- */
- public static final String LOG_PROPERTY =
- "org.apache.commons.logging.Log";
-
-
- /**
- * The deprecated system property used for backwards compatibility with
- * old versions of JCL.
- */
- protected static final String LOG_PROPERTY_OLD =
- "org.apache.commons.logging.log";
-
- /**
- * The name (org.apache.commons.logging.Log.allowFlawedContext)
- * of the system property which can be set true/false to
- * determine system behaviour when a bad context-classloader is encountered.
- * When set to false, a LogConfigurationException is thrown if
- * LogFactoryImpl is loaded via a child classloader of the TCCL (this
- * should never happen in sane systems).
- *
- * Default behaviour: true (tolerates bad context classloaders)
- *
- * See also method setAttribute.
- */
- public static final String ALLOW_FLAWED_CONTEXT_PROPERTY =
- "org.apache.commons.logging.Log.allowFlawedContext";
-
- /**
- * The name (org.apache.commons.logging.Log.allowFlawedDiscovery)
- * of the system property which can be set true/false to
- * determine system behaviour when a bad logging adapter class is
- * encountered during logging discovery. When set to false, an
- * exception will be thrown and the app will fail to start. When set
- * to true, discovery will continue (though the user might end up
- * with a different logging implementation than they expected).
- *
- * Default behaviour: true (tolerates bad logging adapters)
- *
- * See also method setAttribute.
- */
- public static final String ALLOW_FLAWED_DISCOVERY_PROPERTY =
- "org.apache.commons.logging.Log.allowFlawedDiscovery";
-
- /**
- * The name (org.apache.commons.logging.Log.allowFlawedHierarchy)
- * of the system property which can be set true/false to
- * determine system behaviour when a logging adapter class is
- * encountered which has bound to the wrong Log class implementation.
- * When set to false, an exception will be thrown and the app will fail
- * to start. When set to true, discovery will continue (though the user
- * might end up with a different logging implementation than they expected).
- *
- * Default behaviour: true (tolerates bad Log class hierarchy)
- *
- * See also method setAttribute.
- */
- public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY =
- "org.apache.commons.logging.Log.allowFlawedHierarchy";
-
-
- /**
- * The names of classes that will be tried (in order) as logging
- * adapters. Each class is expected to implement the Log interface,
- * and to throw NoClassDefFound or ExceptionInInitializerError when
- * loaded if the underlying logging library is not available. Any
- * other error indicates that the underlying logging library is available
- * but broken/unusable for some reason.
- */
- private static final String[] classesToDiscover = {
- LOGGING_IMPL_LOG4J_LOGGER,
- "org.apache.commons.logging.impl.Jdk14Logger",
- "org.apache.commons.logging.impl.Jdk13LumberjackLogger",
- "org.apache.commons.logging.impl.SimpleLog"
- };
-
-
- // ----------------------------------------------------- Instance Variables
-
- /**
- * Determines whether logging classes should be loaded using the thread-context
- * classloader, or via the classloader that loaded this LogFactoryImpl class.
- */
- private boolean useTCCL = true;
-
- /**
- * The string prefixed to every message output by the logDiagnostic method.
- */
- private String diagnosticPrefix;
-
-
- /**
- * Configuration attributes.
- */
- protected Hashtable attributes = new Hashtable();
-
-
- /**
- * The {@link org.apache.commons.logging.Log} instances that have
- * already been created, keyed by logger name.
- */
- protected Hashtable instances = new Hashtable();
-
-
- /**
- * Name of the class implementing the Log interface.
- */
- private String logClassName;
-
-
- /**
- * The one-argument constructor of the
- * {@link org.apache.commons.logging.Log}
- * implementation class that will be used to create new instances.
- * This value is initialized by getLogConstructor(),
- * and then returned repeatedly.
- */
- protected Constructor logConstructor = null;
-
-
- /**
- * The signature of the Constructor to be used.
- */
- protected Class logConstructorSignature[] =
- { java.lang.String.class };
-
-
- /**
- * The one-argument setLogFactory method of the selected
- * {@link org.apache.commons.logging.Log} method, if it exists.
- */
- protected Method logMethod = null;
-
-
- /**
- * The signature of the setLogFactory method to be used.
- */
- protected Class logMethodSignature[] =
- { LogFactory.class };
-
- /**
- * See getBaseClassLoader and initConfiguration.
- */
- private boolean allowFlawedContext;
-
- /**
- * See handleFlawedDiscovery and initConfiguration.
- */
- private boolean allowFlawedDiscovery;
-
- /**
- * See handleFlawedHierarchy and initConfiguration.
- */
- private boolean allowFlawedHierarchy;
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return the configuration attribute with the specified name (if any),
- * or null if there is no such attribute.
- *
- * @param name Name of the attribute to return
- */
- public Object getAttribute(String name) {
-
- return (attributes.get(name));
-
- }
-
-
- /**
- * Return an array containing the names of all currently defined
- * configuration attributes. If there are no such attributes, a zero
- * length array is returned.
- */
- public String[] getAttributeNames() {
-
- Vector names = new Vector();
- Enumeration keys = attributes.keys();
- while (keys.hasMoreElements()) {
- names.addElement((String) keys.nextElement());
- }
- String results[] = new String[names.size()];
- for (int i = 0; i < results.length; i++) {
- results[i] = (String) names.elementAt(i);
- }
- return (results);
-
- }
-
-
- /**
- * Convenience method to derive a name from the specified class and
- * call getInstance(String) with it.
- *
- * @param clazz Class for which a suitable Log name will be derived
- *
- * @exception LogConfigurationException if a suitable Log
- * instance cannot be returned
- */
- public Log getInstance(Class clazz) throws LogConfigurationException {
-
- return (getInstance(clazz.getName()));
-
- }
-
-
- /**
- * Construct (if necessary) and return a Log instance,
- * using the factory's current set of configuration attributes.
NOTE - Depending upon the implementation of
- * the LogFactory you are using, the Log
- * instance you are returned may or may not be local to the current
- * application, and may or may not be returned again on a subsequent
- * call with the same name argument.
Log instance to be
- * returned (the meaning of this name is only known to the underlying
- * logging implementation that is being wrapped)
- *
- * @exception LogConfigurationException if a suitable Log
- * instance cannot be returned
- */
- public Log getInstance(String name) throws LogConfigurationException {
-
- Log instance = (Log) instances.get(name);
- if (instance == null) {
- instance = newInstance(name);
- instances.put(name, instance);
- }
- return (instance);
-
- }
-
-
- /**
- * Release any internal references to previously created
- * {@link org.apache.commons.logging.Log}
- * instances returned by this factory. This is useful in environments
- * like servlet containers, which implement application reloading by
- * throwing away a ClassLoader. Dangling references to objects in that
- * class loader would prevent garbage collection.
- */
- public void release() {
-
- logDiagnostic("Releasing all known loggers");
- instances.clear();
- }
-
-
- /**
- * Remove any configuration attribute associated with the specified name.
- * If there is no such attribute, no action is taken.
- *
- * @param name Name of the attribute to remove
- */
- public void removeAttribute(String name) {
-
- attributes.remove(name);
-
- }
-
-
- /**
- * Set the configuration attribute with the specified name. Calling
- * this with a null value is equivalent to calling
- * removeAttribute(name).
- * - * This method can be used to set logging configuration programmatically - * rather than via system properties. It can also be used in code running - * within a container (such as a webapp) to configure behaviour on a - * per-component level instead of globally as system properties would do. - * To use this method instead of a system property, call - *
- * LogFactory.getFactory().setAttribute(...) - *- * This must be done before the first Log object is created; configuration - * changes after that point will be ignored. - *
- * This method is also called automatically if LogFactory detects a
- * commons-logging.properties file; every entry in that file is set
- * automatically as an attribute here.
- *
- * @param name Name of the attribute to set
- * @param value Value of the attribute to set, or null
- * to remove any setting for this attribute
- */
- public void setAttribute(String name, Object value) {
-
- if (logConstructor != null) {
- logDiagnostic("setAttribute: call too late; configuration already performed.");
- }
-
- if (value == null) {
- attributes.remove(name);
- } else {
- attributes.put(name, value);
- }
-
- if (name.equals(TCCL_KEY)) {
- useTCCL = Boolean.valueOf(value.toString()).booleanValue();
- }
-
- }
-
-
- // ------------------------------------------------------
- // Static Methods
- //
- // These methods only defined as workarounds for a java 1.2 bug;
- // theoretically none of these are needed.
- // ------------------------------------------------------
-
- /**
- * Gets the context classloader.
- * This method is a workaround for a java 1.2 compiler bug.
- * @since 1.1
- */
- protected static ClassLoader getContextClassLoader() throws LogConfigurationException {
- return LogFactory.getContextClassLoader();
- }
-
-
- /**
- * Workaround for bug in Java1.2; in theory this method is not needed.
- * See LogFactory.isDiagnosticsEnabled.
- */
- protected static boolean isDiagnosticsEnabled() {
- return LogFactory.isDiagnosticsEnabled();
- }
-
-
- /**
- * Workaround for bug in Java1.2; in theory this method is not needed.
- * See LogFactory.getClassLoader.
- * @since 1.1
- */
- protected static ClassLoader getClassLoader(Class clazz) {
- return LogFactory.getClassLoader(clazz);
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
- /**
- * Calculate and cache a string that uniquely identifies this instance,
- * including which classloader the object was loaded from.
- *
- * This string will later be prefixed to each "internal logging" message - * emitted, so that users can clearly see any unexpected behaviour. - *
- * Note that this method does not detect whether internal logging is - * enabled or not, nor where to output stuff if it is; that is all - * handled by the parent LogFactory class. This method just computes - * its own unique prefix for log messages. - */ - private void initDiagnostics() { - // It would be nice to include an identifier of the context classloader - // that this LogFactoryImpl object is responsible for. However that - // isn't possible as that information isn't available. It is possible - // to figure this out by looking at the logging from LogFactory to - // see the context & impl ids from when this object was instantiated, - // in order to link the impl id output as this object's prefix back to - // the context it is intended to manage. - // Note that this prefix should be kept consistent with that - // in LogFactory. - Class clazz = this.getClass(); - ClassLoader classLoader = getClassLoader(clazz); - String classLoaderName; - try { - if (classLoader == null) { - classLoaderName = "BOOTLOADER"; - } else { - classLoaderName = objectId(classLoader); - } - } catch(SecurityException e) { - classLoaderName = "UNKNOWN"; - } - diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] "; - } - - - /** - * Output a diagnostic message to a user-specified destination (if the - * user has enabled diagnostic logging). - * - * @param msg diagnostic message - * @since 1.1 - */ - protected void logDiagnostic(String msg) { - if (isDiagnosticsEnabled()) { - logRawDiagnostic(diagnosticPrefix + msg); - } - } - - /** - * Return the fully qualified Java classname of the {@link Log} - * implementation we will be using. - * - * @deprecated Never invoked by this class; subclasses should not assume - * it will be. - */ - protected String getLogClassName() { - - if (logClassName == null) { - discoverLogImplementation(getClass().getName()); - } - - return logClassName; - } - - - /** - *
Return the Constructor that can be called to instantiate
- * new {@link org.apache.commons.logging.Log} instances.
IMPLEMENTATION NOTE - Race conditions caused by
- * calling this method from more than one thread are ignored, because
- * the same Constructor instance will ultimately be derived
- * in all circumstances.
Return true if JDK 1.4 or later logging
- * is available. Also checks that the Throwable class
- * supports getStackTrace(), which is required by
- * Jdk14Logger.
- * The attributes associated with this object are checked before
- * system properties in case someone has explicitly called setAttribute,
- * or a configuration property has been set in a commons-logging.properties
- * file.
- *
- * @return the value associated with the property, or null.
- */
- private String getConfigurationValue(String property) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] Trying to get configuration for item " + property);
- }
-
- Object valueObj = getAttribute(property);
- if (valueObj != null) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] Found LogFactory attribute [" + valueObj + "] for " + property);
- }
- return valueObj.toString();
- }
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] No LogFactory attribute found for " + property);
- }
-
- try {
- String value = System.getProperty(property);
- if (value != null) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] Found system property [" + value + "] for " + property);
- }
- return value;
- }
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] No system property found for property " + property);
- }
- } catch (SecurityException e) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] Security prevented reading system property " + property);
- }
- }
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("[ENV] No configuration defined for item " + property);
- }
-
- return null;
- }
-
- /**
- * Get the setting for the user-configurable behaviour specified by key.
- * If nothing has explicitly been set, then return dflt.
- */
- private boolean getBooleanConfiguration(String key, boolean dflt) {
- String val = getConfigurationValue(key);
- if (val == null)
- return dflt;
- return Boolean.valueOf(val).booleanValue();
- }
-
- /**
- * Initialize a number of variables that control the behaviour of this
- * class and that can be tweaked by the user. This is done when the first
- * logger is created, not in the constructor of this class, because we
- * need to give the user a chance to call method setAttribute in order to
- * configure this object.
- */
- private void initConfiguration() {
- allowFlawedContext = getBooleanConfiguration(ALLOW_FLAWED_CONTEXT_PROPERTY, true);
- allowFlawedDiscovery = getBooleanConfiguration(ALLOW_FLAWED_DISCOVERY_PROPERTY, true);
- allowFlawedHierarchy = getBooleanConfiguration(ALLOW_FLAWED_HIERARCHY_PROPERTY, true);
- }
-
-
- /**
- * Attempts to create a Log instance for the given category name.
- * Follows the discovery process described in the class javadoc.
- *
- * @param logCategory the name of the log category
- *
- * @throws LogConfigurationException if an error in discovery occurs,
- * or if no adapter at all can be instantiated
- */
- private Log discoverLogImplementation(String logCategory)
- throws LogConfigurationException
- {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Discovering a Log implementation...");
- }
-
- initConfiguration();
-
- Log result = null;
-
- // See if the user specified the Log implementation to use
- String specifiedLogClassName = findUserSpecifiedLogClassName();
-
- if (specifiedLogClassName != null) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Attempting to load user-specified log class '" +
- specifiedLogClassName + "'...");
- }
-
- result = createLogFromClass(specifiedLogClassName,
- logCategory,
- true);
- if (result == null) {
- StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
- messageBuffer.append(specifiedLogClassName);
- messageBuffer.append("' cannot be found or is not useable.");
-
- // Mistyping or misspelling names is a common fault.
- // Construct a good error message, if we can
- if (specifiedLogClassName != null) {
- informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LOG4J_LOGGER);
- informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_JDK14_LOGGER);
- informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LUMBERJACK_LOGGER);
- informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_SIMPLE_LOGGER);
- }
- throw new LogConfigurationException(messageBuffer.toString());
- }
-
- return result;
- }
-
- // No user specified log; try to discover what's on the classpath
- //
- // Note that we deliberately loop here over classesToDiscover and
- // expect method createLogFromClass to loop over the possible source
- // classloaders. The effect is:
- // for each discoverable log adapter
- // for each possible classloader
- // see if it works
- //
- // It appears reasonable at first glance to do the opposite:
- // for each possible classloader
- // for each discoverable log adapter
- // see if it works
- //
- // The latter certainly has advantages for user-installable logging
- // libraries such as log4j; in a webapp for example this code should
- // first check whether the user has provided any of the possible
- // logging libraries before looking in the parent classloader.
- // Unfortunately, however, Jdk14Logger will always work in jvm>=1.4,
- // and SimpleLog will always work in any JVM. So the loop would never
- // ever look for logging libraries in the parent classpath. Yet many
- // users would expect that putting log4j there would cause it to be
- // detected (and this is the historical JCL behaviour). So we go with
- // the first approach. A user that has bundled a specific logging lib
- // in a webapp should use a commons-logging.properties file or a
- // service file in META-INF to force use of that logging lib anyway,
- // rather than relying on discovery.
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "No user-specified Log implementation; performing discovery" +
- " using the standard supported logging implementations...");
- }
- for(int i=0; (i
- * This method usually returns the context classloader. However if it
- * is discovered that the classloader which loaded this class is a child
- * of the context classloader and the allowFlawedContext option
- * has been set then the classloader which loaded this class is returned
- * instead.
- *
- * The only time when the classloader which loaded this class is a
- * descendant (rather than the same as or an ancestor of the context
- * classloader) is when an app has created custom classloaders but
- * failed to correctly set the context classloader. This is a bug in
- * the calling application; however we provide the option for JCL to
- * simply generate a warning rather than fail outright.
- *
- */
- private ClassLoader getBaseClassLoader() throws LogConfigurationException {
- ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
-
- if (useTCCL == false) {
- return thisClassLoader;
- }
-
- ClassLoader contextClassLoader = getContextClassLoader();
-
- ClassLoader baseClassLoader = getLowestClassLoader(
- contextClassLoader, thisClassLoader);
-
- if (baseClassLoader == null) {
- // The two classloaders are not part of a parent child relationship.
- // In some classloading setups (e.g. JBoss with its
- // UnifiedLoaderRepository) this can still work, so if user hasn't
- // forbidden it, just return the contextClassLoader.
- if (allowFlawedContext) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "[WARNING] the context classloader is not part of a"
- + " parent-child relationship with the classloader that"
- + " loaded LogFactoryImpl.");
- }
- // If contextClassLoader were null, getLowestClassLoader() would
- // have returned thisClassLoader. The fact we are here means
- // contextClassLoader is not null, so we can just return it.
- return contextClassLoader;
- }
- else {
- throw new LogConfigurationException(
- "Bad classloader hierarchy; LogFactoryImpl was loaded via"
- + " a classloader that is not related to the current context"
- + " classloader.");
- }
- }
-
- if (baseClassLoader != contextClassLoader) {
- // We really should just use the contextClassLoader as the starting
- // point for scanning for log adapter classes. However it is expected
- // that there are a number of broken systems out there which create
- // custom classloaders but fail to set the context classloader so
- // we handle those flawed systems anyway.
- if (allowFlawedContext) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic(
- "Warning: the context classloader is an ancestor of the"
- + " classloader that loaded LogFactoryImpl; it should be"
- + " the same or a descendant. The application using"
- + " commons-logging should ensure the context classloader"
- + " is used correctly.");
- }
- } else {
- throw new LogConfigurationException(
- "Bad classloader hierarchy; LogFactoryImpl was loaded via"
- + " a classloader that is not related to the current context"
- + " classloader.");
- }
- }
-
- return baseClassLoader;
- }
-
- /**
- * Given two related classloaders, return the one which is a child of
- * the other.
- *
- * @param c1 is a classloader (including the null classloader)
- * @param c2 is a classloader (including the null classloader)
- *
- * @return c1 if it has c2 as an ancestor, c2 if it has c1 as an ancestor,
- * and null if neither is an ancestor of the other.
- */
- private ClassLoader getLowestClassLoader(ClassLoader c1, ClassLoader c2) {
- // TODO: use AccessController when dealing with classloaders here
-
- if (c1 == null)
- return c2;
-
- if (c2 == null)
- return c1;
-
- ClassLoader current;
-
- // scan c1's ancestors to find c2
- current = c1;
- while (current != null) {
- if (current == c2)
- return c1;
- current = current.getParent();
- }
-
- // scan c2's ancestors to find c1
- current = c2;
- while (current != null) {
- if (current == c1)
- return c2;
- current = current.getParent();
- }
-
- return null;
- }
-
- /**
- * Generates an internal diagnostic logging of the discovery failure and
- * then throws a
- * There are two possible reasons why we successfully loaded the
- * specified log adapter class then failed to cast it to a Log object:
- *
- * Here we try to figure out which case has occurred so we can give the
- * user some reasonable feedback.
- *
- * @param badClassLoader is the classloader we loaded the problem class from,
- * ie it is equivalent to badClass.getClassLoader().
- *
- * @param badClass is a Class object with the desired name, but which
- * does not implement Log correctly.
- *
- * @throws LogConfigurationException when the situation
- * should not be recovered from.
- */
- private void handleFlawedHierarchy(ClassLoader badClassLoader, Class badClass)
- throws LogConfigurationException {
-
- boolean implementsLog = false;
- String logInterfaceName = Log.class.getName();
- Class interfaces[] = badClass.getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- if (logInterfaceName.equals(interfaces[i].getName())) {
- implementsLog = true;
- break;
- }
- }
-
- if (implementsLog) {
- // the class does implement an interface called Log, but
- // it is in the wrong classloader
- if (isDiagnosticsEnabled()) {
- try {
- ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
- logDiagnostic(
- "Class '" + badClass.getName()
- + "' was found in classloader "
- + objectId(badClassLoader)
- + ". It is bound to a Log interface which is not"
- + " the one loaded from classloader "
- + objectId(logInterfaceClassLoader));
- } catch (Throwable t) {
- logDiagnostic(
- "Error while trying to output diagnostics about"
- + " bad class '" + badClass + "'");
- }
- }
-
- if (!allowFlawedHierarchy) {
- StringBuffer msg = new StringBuffer();
- msg.append("Terminating logging for this context ");
- msg.append("due to bad log hierarchy. ");
- msg.append("You have more than one version of '");
- msg.append(Log.class.getName());
- msg.append("' visible.");
- if (isDiagnosticsEnabled()) {
- logDiagnostic(msg.toString());
- }
- throw new LogConfigurationException(msg.toString());
- }
-
- if (isDiagnosticsEnabled()) {
- StringBuffer msg = new StringBuffer();
- msg.append("Warning: bad log hierarchy. ");
- msg.append("You have more than one version of '");
- msg.append(Log.class.getName());
- msg.append("' visible.");
- logDiagnostic(msg.toString());
- }
- } else {
- // this is just a bad adapter class
- if (!allowFlawedDiscovery) {
- StringBuffer msg = new StringBuffer();
- msg.append("Terminating logging for this context. ");
- msg.append("Log class '");
- msg.append(badClass.getName());
- msg.append("' does not implement the Log interface.");
- if (isDiagnosticsEnabled()) {
- logDiagnostic(msg.toString());
- }
-
- throw new LogConfigurationException(msg.toString());
- }
-
- if (isDiagnosticsEnabled()) {
- StringBuffer msg = new StringBuffer();
- msg.append("[WARNING] Log class '");
- msg.append(badClass.getName());
- msg.append("' does not implement the Log interface.");
- logDiagnostic(msg.toString());
- }
- }
- }
-}
diff --git a/src/org/apache/commons/logging/impl/NoOpLog.java b/src/org/apache/commons/logging/impl/NoOpLog.java
deleted file mode 100644
index b6988137aae15ee4cf1102897628291bca6e905d..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/logging/impl/NoOpLog.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-
-
-package org.apache.commons.logging.impl;
-
-
-import java.io.Serializable;
-import org.apache.commons.logging.Log;
-
-
-/**
- * Trivial implementation of Log that throws away all messages. No
- * configurable system properties are supported. Simple implementation of Log that sends all enabled log messages,
- * for all defined loggers, to System.err. The following system properties
- * are supported to configure the behavior of this logger: In addition to looking for system properties with the names specified
- * above, this implementation also checks for a class loader resource named
- * Set logging level. Get logging level. Do the actual logging.
- * This method assembles the message
- * and then calls Write the content of the message accumulated in the specified
- * Are debug messages currently enabled? This allows expensive operations such as Are error messages currently enabled? This allows expensive operations such as Are fatal messages currently enabled? This allows expensive operations such as Are info messages currently enabled? This allows expensive operations such as Are trace messages currently enabled? This allows expensive operations such as Are warn messages currently enabled? This allows expensive operations such as Implementation of This class follows the symantics of Note:
- * This is not intended to be a general purpose hash table replacement.
- * This implementation is also tuned towards a particular purpose: for use as a replacement
- * for
- * Usage: typical use case is as a drop-in replacement
- * for the The reason all this is necessary is due to a issue which
- * arises during hot deploy in a J2EE-like containers.
- * Each component running in the container owns one or more classloaders; when
- * the component loads a LogFactory instance via the component classloader
- * a reference to it gets stored in the static LogFactory.factories member,
- * keyed by the component's classloader so different components don't
- * stomp on each other. When the component is later unloaded, the container
- * sets the component's classloader to null with the intent that all the
- * component's classes get garbage-collected. However there's still a
- * reference to the component's classloader from a key in the "global"
- *
- * Limitations:
- * There is still one (unusual) scenario in which a component will not
- * be correctly unloaded without an explicit release. Though weak references
- * are used for its keys, it is necessary to use strong references for its values.
- * If the abstract class
- * Such a situation occurs when the commons-logging.jar is
- * loaded by a parent classloader (e.g. a server level classloader in a
- * servlet container) and a custom To avoid this scenario, ensure
- * that any custom LogFactory subclass is loaded by the same classloader as
- * the base Concrete implementations of commons-logging wrapper APIs. Simple wrapper API around multiple logging APIs. This package provides an API for logging in server-based applications that
-can be used around a variety of different logging implementations, including
-prebuilt support for the following: For those impatient to just get on with it, the following example
-illustrates the typical declaration and use of a logger that is named (by
-convention) after the calling class:
-
- Unless you configure things differently, all log output will be written
-to System.err. Therefore, you really will want to review the remainder of
-this page in order to understand how to configure logging for your
-application. From an application perspective, the first requirement is to retrieve an
-object reference to the If a Once an implementation class name is selected, the corresponding class is
-loaded from the current Thread context class loader (if there is one), or
-from the class loader that loaded the The Logging Package APIs include a default See the SimpleLog JavaDocs for detailed
-configuration information for this default implementation. The basic principle is that the user is totally responsible for the
-configuration of the underlying logging system.
-Commons-logging should not change the existing configuration. Each individual Log implementation may
-support its own configuration properties. These will be documented in the
-class descriptions for the corresponding implementation class. Finally, some Use of the Logging Package APIs, from the perspective of an application
-component, consists of the following steps: For convenience, into a single method call: For example, you might use the following technique to initialize and
-use a Log instance in an application component: The HTTP header fields follow the same generic format as
- * that given in Section 3.1 of RFC 822. Each header field consists
- * of a name followed by a colon (":") and the field value. Field names
- * are case-insensitive. The field value MAY be preceded by any amount
- * of LWS, though a single SP is preferred.
- *
- *
- * In some places, the JavaDoc distinguishes three kinds of entities,
- * depending on where their {@link #getContent content} originates:
- *
- * This class comforms to the generic grammar and formatting rules outlined in the
- * Section 2.2
- * and
- * Section 3.6
- * of RFC 2616
- *
- * The following rules are used throughout this specification to describe basic parsing constructs.
- * The US-ASCII coded character set is defined by ANSI X3.4-1986.
- *
- * Many HTTP/1.1 header field values consist of words separated by LWS or special
- * characters. These special characters MUST be in a quoted string to be used within
- * a parameter value (as defined in section 3.6).
- *
- *
- * A string of text is parsed as a single word if it is quoted using double-quote marks.
- *
- * The backslash character ("\") MAY be used as a single-character quoting mechanism only
- * within quoted-string and comment constructs.
- *
- * Parameters are in the form of attribute/value pairs.
- *
- * Signals that the target server failed to respond with a valid HTTP response.
- *
- * This class defines a protocol version as a combination of
- * protocol name, major version number, and minor version number.
- * Note that {@link #equals} and {@link #hashCode} are defined as
- * final here, they cannot be overridden in derived classes.
- *
- * @author Oleg Kalnichevski
- * @author Roland Weber
- *
- * @version $Revision: 609106 $
- */
-public class ProtocolVersion implements Serializable, Cloneable {
-
- private static final long serialVersionUID = 8950662842175091068L;
-
-
- /** Name of the protocol. */
- protected final String protocol;
-
- /** Major version number of the protocol */
- protected final int major;
-
- /** Minor version number of the protocol */
- protected final int minor;
-
-
- /**
- * Create a protocol version designator.
- *
- * @param protocol the name of the protocol, for example "HTTP"
- * @param major the major version number of the protocol
- * @param minor the minor version number of the protocol
- */
- public ProtocolVersion(String protocol, int major, int minor) {
- if (protocol == null) {
- throw new IllegalArgumentException
- ("Protocol name must not be null.");
- }
- if (major < 0) {
- throw new IllegalArgumentException
- ("Protocol major version number must not be negative.");
- }
- if (minor < 0) {
- throw new IllegalArgumentException
- ("Protocol minor version number may not be negative");
- }
- this.protocol = protocol;
- this.major = major;
- this.minor = minor;
- }
-
- /**
- * Returns the name of the protocol.
- *
- * @return the protocol name
- */
- public final String getProtocol() {
- return protocol;
- }
-
- /**
- * Returns the major version number of the protocol.
- *
- * @return the major version number.
- */
- public final int getMajor() {
- return major;
- }
-
- /**
- * Returns the minor version number of the HTTP protocol.
- *
- * @return the minor version number.
- */
- public final int getMinor() {
- return minor;
- }
-
-
- /**
- * Obtains a specific version of this protocol.
- * This can be used by derived classes to instantiate themselves instead
- * of the base class, and to define constants for commonly used versions.
- *
- * This interface represents an abstract challenge-response oriented
- * authentication scheme.
- *
- * An authentication scheme should be able to support the following
- * functions:
- * null
- */
- private String findUserSpecifiedLogClassName()
- {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from attribute '" + LOG_PROPERTY + "'");
- }
- String specifiedClass = (String) getAttribute(LOG_PROPERTY);
-
- if (specifiedClass == null) { // @deprecated
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from attribute '" +
- LOG_PROPERTY_OLD + "'");
- }
- specifiedClass = (String) getAttribute(LOG_PROPERTY_OLD);
- }
-
- if (specifiedClass == null) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from system property '" +
- LOG_PROPERTY + "'");
- }
- try {
- specifiedClass = System.getProperty(LOG_PROPERTY);
- } catch (SecurityException e) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("No access allowed to system property '" +
- LOG_PROPERTY + "' - " + e.getMessage());
- }
- }
- }
-
- if (specifiedClass == null) { // @deprecated
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Trying to get log class from system property '" +
- LOG_PROPERTY_OLD + "'");
- }
- try {
- specifiedClass = System.getProperty(LOG_PROPERTY_OLD);
- } catch (SecurityException e) {
- if (isDiagnosticsEnabled()) {
- logDiagnostic("No access allowed to system property '" +
- LOG_PROPERTY_OLD + "' - " + e.getMessage());
- }
- }
- }
-
- // Remove any whitespace; it's never valid in a classname so its
- // presence just means a user mistake. As we know what they meant,
- // we may as well strip the spaces.
- if (specifiedClass != null) {
- specifiedClass = specifiedClass.trim();
- }
-
- return specifiedClass;
- }
-
-
- /**
- * Attempts to load the given class, find a suitable constructor,
- * and instantiate an instance of Log.
- *
- * @param logAdapterClassName classname of the Log implementation
- *
- * @param logCategory argument to pass to the Log implementation's
- * constructor
- *
- * @param affectState true if this object's state should
- * be affected by this method call, false otherwise.
- *
- * @return an instance of the given class, or null if the logging
- * library associated with the specified adapter is not available.
- *
- * @throws LogConfigurationException if there was a serious error with
- * configuration and the handleFlawedDiscovery method decided this
- * problem was fatal.
- */
- private Log createLogFromClass(String logAdapterClassName,
- String logCategory,
- boolean affectState)
- throws LogConfigurationException {
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Attempting to instantiate '" + logAdapterClassName + "'");
- }
-
- Object[] params = { logCategory };
- Log logAdapter = null;
- Constructor constructor = null;
-
- Class logAdapterClass = null;
- ClassLoader currentCL = getBaseClassLoader();
-
- for(;;) {
- // Loop through the classloader hierarchy trying to find
- // a viable classloader.
- logDiagnostic(
- "Trying to load '"
- + logAdapterClassName
- + "' from classloader "
- + objectId(currentCL));
- try {
- if (isDiagnosticsEnabled()) {
- // Show the location of the first occurrence of the .class file
- // in the classpath. This is the location that ClassLoader.loadClass
- // will load the class from -- unless the classloader is doing
- // something weird.
- URL url;
- String resourceName = logAdapterClassName.replace('.', '/') + ".class";
- if (currentCL != null) {
- url = currentCL.getResource(resourceName );
- } else {
- url = ClassLoader.getSystemResource(resourceName + ".class");
- }
-
- if (url == null) {
- logDiagnostic("Class '" + logAdapterClassName + "' [" + resourceName + "] cannot be found.");
- } else {
- logDiagnostic("Class '" + logAdapterClassName + "' was found at '" + url + "'");
- }
- }
-
- Class c = null;
- try {
- c = Class.forName(logAdapterClassName, true, currentCL);
- } catch (ClassNotFoundException originalClassNotFoundException) {
- // The current classloader was unable to find the log adapter
- // in this or any ancestor classloader. There's no point in
- // trying higher up in the hierarchy in this case..
- String msg = "" + originalClassNotFoundException.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is not available via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
- try {
- // Try the class classloader.
- // This may work in cases where the TCCL
- // does not contain the code executed or JCL.
- // This behaviour indicates that the application
- // classloading strategy is not consistent with the
- // Java 1.2 classloading guidelines but JCL can
- // and so should handle this case.
- c = Class.forName(logAdapterClassName);
- } catch (ClassNotFoundException secondaryClassNotFoundException) {
- // no point continuing: this adapter isn't available
- msg = "" + secondaryClassNotFoundException.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is not available via the LogFactoryImpl class classloader: "
- + msg.trim());
- break;
- }
- }
-
- constructor = c.getConstructor(logConstructorSignature);
- Object o = constructor.newInstance(params);
-
- // Note that we do this test after trying to create an instance
- // [rather than testing Log.class.isAssignableFrom(c)] so that
- // we don't complain about Log hierarchy problems when the
- // adapter couldn't be instantiated anyway.
- if (o instanceof Log) {
- logAdapterClass = c;
- logAdapter = (Log) o;
- break;
- }
-
- // Oops, we have a potential problem here. An adapter class
- // has been found and its underlying lib is present too, but
- // there are multiple Log interface classes available making it
- // impossible to cast to the type the caller wanted. We
- // certainly can't use this logger, but we need to know whether
- // to keep on discovering or terminate now.
- //
- // The handleFlawedHierarchy method will throw
- // LogConfigurationException if it regards this problem as
- // fatal, and just return if not.
- handleFlawedHierarchy(currentCL, c);
- } catch (NoClassDefFoundError e) {
- // We were able to load the adapter but it had references to
- // other classes that could not be found. This simply means that
- // the underlying logger library is not present in this or any
- // ancestor classloader. There's no point in trying higher up
- // in the hierarchy in this case..
- String msg = "" + e.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is missing dependencies when loaded via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
- break;
- } catch (ExceptionInInitializerError e) {
- // A static initializer block or the initializer code associated
- // with a static variable on the log adapter class has thrown
- // an exception.
- //
- // We treat this as meaning the adapter's underlying logging
- // library could not be found.
- String msg = "" + e.getMessage();
- logDiagnostic(
- "The log adapter '"
- + logAdapterClassName
- + "' is unable to initialize itself when loaded via classloader "
- + objectId(currentCL)
- + ": "
- + msg.trim());
- break;
- } catch(LogConfigurationException e) {
- // call to handleFlawedHierarchy above must have thrown
- // a LogConfigurationException, so just throw it on
- throw e;
- } catch(Throwable t) {
- // handleFlawedDiscovery will determine whether this is a fatal
- // problem or not. If it is fatal, then a LogConfigurationException
- // will be thrown.
- handleFlawedDiscovery(logAdapterClassName, currentCL, t);
- }
-
- if (currentCL == null) {
- break;
- }
-
- // try the parent classloader
- currentCL = currentCL.getParent();
- }
-
- if ((logAdapter != null) && affectState) {
- // We've succeeded, so set instance fields
- this.logClassName = logAdapterClassName;
- this.logConstructor = constructor;
-
- // Identify the setLogFactory method (if there is one)
- try {
- this.logMethod = logAdapterClass.getMethod("setLogFactory",
- logMethodSignature);
- logDiagnostic("Found method setLogFactory(LogFactory) in '"
- + logAdapterClassName + "'");
- } catch (Throwable t) {
- this.logMethod = null;
- logDiagnostic(
- "[INFO] '" + logAdapterClassName
- + "' from classloader " + objectId(currentCL)
- + " does not declare optional method "
- + "setLogFactory(LogFactory)");
- }
-
- logDiagnostic(
- "Log adapter '" + logAdapterClassName
- + "' from classloader " + objectId(logAdapterClass.getClassLoader())
- + " has been selected for use.");
- }
-
- return logAdapter;
- }
-
-
- /**
- * Return the classloader from which we should try to load the logging
- * adapter classes.
- * LogConfigurationException that wraps
- * the passed Throwable.
- *
- * @param logAdapterClassName is the class name of the Log implementation
- * that could not be instantiated. Cannot be null.
- *
- * @param classLoader is the classloader that we were trying to load the
- * logAdapterClassName from when the exception occurred.
- *
- * @param discoveryFlaw is the Throwable created by the classloader
- *
- * @throws LogConfigurationException ALWAYS
- */
- private void handleFlawedDiscovery(String logAdapterClassName,
- ClassLoader classLoader,
- Throwable discoveryFlaw) {
-
- if (isDiagnosticsEnabled()) {
- logDiagnostic("Could not instantiate Log '"
- + logAdapterClassName + "' -- "
- + discoveryFlaw.getClass().getName() + ": "
- + discoveryFlaw.getLocalizedMessage());
- }
-
- if (!allowFlawedDiscovery) {
- throw new LogConfigurationException(discoveryFlaw);
- }
- }
-
-
- /**
- * Report a problem loading the log adapter, then either return
- * (if the situation is considered recoverable) or throw a
- * LogConfigurationException.
- *
- *
- *
- *
- *
- * org.apache.commons.logging.simplelog.defaultlog -
- * Default logging detail level for all instances of SimpleLog.
- * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
- * If not specified, defaults to "info". org.apache.commons.logging.simplelog.log.xxxxx -
- * Logging detail level for a SimpleLog instance named "xxxxx".
- * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
- * If not specified, the default logging detail level is used.org.apache.commons.logging.simplelog.showlogname -
- * Set to true if you want the Log instance name to be
- * included in output messages. Defaults to false.org.apache.commons.logging.simplelog.showShortLogname -
- * Set to true if you want the last component of the name to be
- * included in output messages. Defaults to true.org.apache.commons.logging.simplelog.showdatetime -
- * Set to true if you want the current date and time
- * to be included in output messages. Default is false.org.apache.commons.logging.simplelog.dateTimeFormat -
- * The date and time format to be used in the output messages.
- * The pattern describing the date and time format is the same that is
- * used in java.text.SimpleDateFormat. If the format is not
- * specified or is invalid, the default format is used.
- * The default format is yyyy/MM/dd HH:mm:ss:SSS zzz."simplelog.properties", and includes any matching definitions
- * from this resource (if it exists).SimpleLog start with this */
- static protected final String systemPrefix =
- "org.apache.commons.logging.simplelog.";
-
- /** Properties loaded from simplelog.properties */
- static protected final Properties simpleLogProps = new Properties();
-
- /** The default format to use when formating dates */
- static protected final String DEFAULT_DATE_TIME_FORMAT =
- "yyyy/MM/dd HH:mm:ss:SSS zzz";
-
- /** Include the instance name in the log message? */
- static protected boolean showLogName = false;
- /** Include the short name ( last component ) of the logger in the log
- * message. Defaults to true - otherwise we'll be lost in a flood of
- * messages without knowing who sends them.
- */
- static protected boolean showShortName = true;
- /** Include the current time in the log message */
- static protected boolean showDateTime = false;
- /** The date and time format to use in the log message */
- static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
- /** Used to format times */
- static protected DateFormat dateFormatter = null;
-
- // ---------------------------------------------------- Log Level Constants
-
-
- /** "Trace" level logging. */
- public static final int LOG_LEVEL_TRACE = 1;
- /** "Debug" level logging. */
- public static final int LOG_LEVEL_DEBUG = 2;
- /** "Info" level logging. */
- public static final int LOG_LEVEL_INFO = 3;
- /** "Warn" level logging. */
- public static final int LOG_LEVEL_WARN = 4;
- /** "Error" level logging. */
- public static final int LOG_LEVEL_ERROR = 5;
- /** "Fatal" level logging. */
- public static final int LOG_LEVEL_FATAL = 6;
-
- /** Enable all logging levels */
- public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1);
-
- /** Enable no logging levels */
- public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1);
-
- // ------------------------------------------------------------ Initializer
-
- private static String getStringProperty(String name) {
- String prop = null;
- try {
- prop = System.getProperty(name);
- } catch (SecurityException e) {
- ; // Ignore
- }
- return (prop == null) ? simpleLogProps.getProperty(name) : prop;
- }
-
- private static String getStringProperty(String name, String dephault) {
- String prop = getStringProperty(name);
- return (prop == null) ? dephault : prop;
- }
-
- private static boolean getBooleanProperty(String name, boolean dephault) {
- String prop = getStringProperty(name);
- return (prop == null) ? dephault : "true".equalsIgnoreCase(prop);
- }
-
- // Initialize class attributes.
- // Load properties file, if found.
- // Override with system properties.
- static {
- // Add props from the resource simplelog.properties
- InputStream in = getResourceAsStream("simplelog.properties");
- if(null != in) {
- try {
- simpleLogProps.load(in);
- in.close();
- } catch(java.io.IOException e) {
- // ignored
- }
- }
-
- showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName);
- showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName);
- showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime);
-
- if(showDateTime) {
- dateTimeFormat = getStringProperty(systemPrefix + "dateTimeFormat",
- dateTimeFormat);
- try {
- dateFormatter = new SimpleDateFormat(dateTimeFormat);
- } catch(IllegalArgumentException e) {
- // If the format pattern is invalid - use the default format
- dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
- dateFormatter = new SimpleDateFormat(dateTimeFormat);
- }
- }
- }
-
-
- // ------------------------------------------------------------- Attributes
-
- /** The name of this simple log instance */
- protected String logName = null;
- /** The current log level */
- protected int currentLogLevel;
- /** The short name of this simple log instance */
- private String shortLogName = null;
-
-
- // ------------------------------------------------------------ Constructor
-
- /**
- * Construct a simple log with given name.
- *
- * @param name log name
- */
- public SimpleLog(String name) {
-
- logName = name;
-
- // Set initial log level
- // Used to be: set default log level to ERROR
- // IMHO it should be lower, but at least info ( costin ).
- setLevel(SimpleLog.LOG_LEVEL_INFO);
-
- // Set log level from properties
- String lvl = getStringProperty(systemPrefix + "log." + logName);
- int i = String.valueOf(name).lastIndexOf(".");
- while(null == lvl && i > -1) {
- name = name.substring(0,i);
- lvl = getStringProperty(systemPrefix + "log." + name);
- i = String.valueOf(name).lastIndexOf(".");
- }
-
- if(null == lvl) {
- lvl = getStringProperty(systemPrefix + "defaultlog");
- }
-
- if("all".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_ALL);
- } else if("trace".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_TRACE);
- } else if("debug".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_DEBUG);
- } else if("info".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_INFO);
- } else if("warn".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_WARN);
- } else if("error".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_ERROR);
- } else if("fatal".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_FATAL);
- } else if("off".equalsIgnoreCase(lvl)) {
- setLevel(SimpleLog.LOG_LEVEL_OFF);
- }
-
- }
-
-
- // -------------------------------------------------------- Properties
-
- /**
- * write() to cause it to be written.StringBuffer to the appropriate output destination. The
- * default implementation writes to System.err.StringBuffer containing the accumulated
- * text to be logged
- */
- protected void write(StringBuffer buffer) {
-
- System.err.println(buffer.toString());
-
- }
-
-
- /**
- * Is the given log level currently enabled?
- *
- * @param logLevel is this level enabled?
- */
- protected boolean isLevelEnabled(int logLevel) {
- // log level are numerically ordered so can use simple numeric
- // comparison
- return (logLevel >= currentLogLevel);
- }
-
-
- // -------------------------------------------------------- Log Implementation
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#debug(Object)
- */
- public final void debug(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
- log(SimpleLog.LOG_LEVEL_DEBUG, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#debug(Object, Throwable)
- */
- public final void debug(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
- log(SimpleLog.LOG_LEVEL_DEBUG, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#trace(Object)
- */
- public final void trace(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
- log(SimpleLog.LOG_LEVEL_TRACE, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#trace(Object, Throwable)
- */
- public final void trace(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
- log(SimpleLog.LOG_LEVEL_TRACE, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#info(Object)
- */
- public final void info(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
- log(SimpleLog.LOG_LEVEL_INFO,message,null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#info(Object, Throwable)
- */
- public final void info(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
- log(SimpleLog.LOG_LEVEL_INFO, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#warn(Object)
- */
- public final void warn(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
- log(SimpleLog.LOG_LEVEL_WARN, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#warn(Object, Throwable)
- */
- public final void warn(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
- log(SimpleLog.LOG_LEVEL_WARN, message, t);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#error(Object)
- */
- public final void error(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
- log(SimpleLog.LOG_LEVEL_ERROR, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#error(Object, Throwable)
- */
- public final void error(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
- log(SimpleLog.LOG_LEVEL_ERROR, message, t);
- }
- }
-
-
- /**
- * Log a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL.
- *
- * @param message to log
- * @see org.apache.commons.logging.Log#fatal(Object)
- */
- public final void fatal(Object message) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
- log(SimpleLog.LOG_LEVEL_FATAL, message, null);
- }
- }
-
-
- /**
- * Logs a message with
- * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL.
- *
- * @param message to log
- * @param t log this cause
- * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
- */
- public final void fatal(Object message, Throwable t) {
-
- if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
- log(SimpleLog.LOG_LEVEL_FATAL, message, t);
- }
- }
-
-
- /**
- * String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. String
- * concatenation to be avoided when the message will be ignored by the
- * logger. Hashtable that uses WeakReference's
- * to hold its keys thus allowing them to be reclaimed by the garbage collector.
- * The associated values are retained using strong references.Hashtable as closely as
- * possible. It therefore does not accept null values or keys.Hashtable in LogFactory. This application requires
- * good liveliness for get and put. Various tradeoffs
- * have been made with this in mind.
- * Hashtable used in LogFactory for J2EE enviroments
- * running 1.3+ JVMs. Use of this class in most cases (see below) will
- * allow classloaders to be collected by the garbage collector without the need
- * to call {@link org.apache.commons.logging.LogFactory#release(ClassLoader) LogFactory.release(ClassLoader)}.
- * org.apache.commons.logging.LogFactory checks whether this class
- * can be supported by the current JVM, and if so then uses it to store
- * references to the LogFactory implementationd it loads
- * (rather than using a standard Hashtable instance).
- * Having this class used instead of Hashtable solves
- * certain issues related to dynamic reloading of applications in J2EE-style
- * environments. However this class requires java 1.3 or later (due to its use
- * of java.lang.ref.WeakReference and associates).
- * And by the way, this extends Hashtable rather than HashMap
- * for backwards compatibility reasons. See the documentation
- * for method LogFactory.createFactoryStore for more details.LogFactory's factories member! If LogFactory.release()
- * is called whenever component is unloaded, the classloaders will be correctly
- * garbage collected; this should be done by any container that
- * bundles commons-logging by default. However, holding the classloader
- * references weakly ensures that the classloader will be garbage collected
- * without the container performing this step. LogFactory is
- * loaded by the container classloader but a subclass of
- * LogFactory [LogFactory1] is loaded by the component's
- * classloader and an instance stored in the static map associated with the
- * base LogFactory class, then there is a strong reference from the LogFactory
- * class to the LogFactory1 instance (as normal) and a strong reference from
- * the LogFactory1 instance to the component classloader via
- * getClass().getClassLoader(). This chain of references will prevent
- * collection of the child classloader.LogFactory implementation is
- * loaded by a child classloader (e.g. a web app classloader).LogFactory. Creating custom LogFactory subclasses is,
- * however, rare. The standard LogFactoryImpl class should be sufficient
- * for most or all users.null
- */
- private Referenced(Object referant) {
- reference = new WeakReference(referant);
- // Calc a permanent hashCode so calls to Hashtable.remove()
- // work if the WeakReference has been cleared
- hashCode = referant.hashCode();
- }
-
- /**
- *
- * @throws NullPointerException if key is null
- */
- private Referenced(Object key, ReferenceQueue queue) {
- reference = new WeakKey(key, queue, this);
- // Calc a permanent hashCode so calls to Hashtable.remove()
- // work if the WeakReference has been cleared
- hashCode = key.hashCode();
-
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- private Object getValue() {
- return reference.get();
- }
-
- public boolean equals(Object o) {
- boolean result = false;
- if (o instanceof Referenced) {
- Referenced otherKey = (Referenced) o;
- Object thisKeyValue = getValue();
- Object otherKeyValue = otherKey.getValue();
- if (thisKeyValue == null) {
- result = (otherKeyValue == null);
-
- // Since our hashcode was calculated from the original
- // non-null referant, the above check breaks the
- // hashcode/equals contract, as two cleared Referenced
- // objects could test equal but have different hashcodes.
- // We can reduce (not eliminate) the chance of this
- // happening by comparing hashcodes.
- if (result == true) {
- result = (this.hashCode() == otherKey.hashCode());
- }
- // In any case, as our c'tor does not allow null referants
- // and Hashtable does not do equality checks between
- // existing keys, normal hashtable operations should never
- // result in an equals comparison between null referants
- }
- else
- {
- result = thisKeyValue.equals(otherKeyValue);
- }
- }
- return result;
- }
- }
-
- /**
- * WeakReference subclass that holds a hard reference to an
- * associated value and also makes accessible
- * the Referenced object holding it.
- */
- private final static class WeakKey extends WeakReference {
-
- private final Referenced referenced;
-
- private WeakKey(Object key,
- ReferenceQueue queue,
- Referenced referenced) {
- super(key, queue);
- this.referenced = referenced;
- }
-
- private Referenced getReferenced() {
- return referenced;
- }
- }
-}
diff --git a/src/org/apache/commons/logging/impl/package.html b/src/org/apache/commons/logging/impl/package.html
deleted file mode 100644
index eb26b76e7efdb565f206466749d666d053f7542e..0000000000000000000000000000000000000000
--- a/src/org/apache/commons/logging/impl/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-Overview
-
-
-
-
-
-java.util.logging.Logger instance.Logger.Quick Start Guide
-
-
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
-
- public class Foo {
-
- private Log log = LogFactory.getLog(Foo.class);
-
- public void foo() {
- ...
- try {
- if (log.isDebugEnabled()) {
- log.debug("About to do something to object " + name);
- }
- name.bar();
- } catch (IllegalStateException e) {
- log.error("Something bad happened to " + name, e);
- }
- ...
- }
-
-
-Configuring the Commons Logging Package
-
-
-Choosing a
-
-LogFactory ImplementationLogFactory instance that will be used
-to create Log instances for this
-application. This is normally accomplished by calling the static
-getFactory() method. This method implements the following
-discovery algorithm to select the name of the LogFactory
-implementation class this application wants to use:
-
-
-org.apache.commons.logging.LogFactory.META-INF/services/org.apache.commons.logging.LogFactory
- whose first line is assumed to contain the desired class name.commons-logging.properties
- visible in the application class path, with a property named
- org.apache.commons.logging.LogFactory defining the
- desired implementation class name.commons-logging.properties file is found, all of the
-properties defined there are also used to set configuration attributes on
-the instantiated LogFactory instance.LogFactory class itself
-otherwise. This allows a copy of commons-logging.jar to be
-shared in a multiple class loader environment (such as a servlet container),
-but still allow each web application to provide its own LogFactory
-implementation, if it so desires. An instance of this class will then be
-created, and cached per class loader.
-
-
-The Default
-
-LogFactory ImplementationLogFactory
-implementation class (
-org.apache.commons.logging.impl.LogFactoryImpl) that is selected if no
-other implementation class name can be discovered. Its primary purpose is
-to create (as necessary) and return Log instances
-in response to calls to the getInstance() method. The default
-implementation uses the following rules:
-
-
-Log instance of the same name will be created.
- Subsequent getInstance() calls to the same
- LogFactory instance, with the same name or Class
- parameter, will return the same Log instance.Log instance must be created, the default
- LogFactory implementation uses the following discovery
- process:
-
-
org.apache.commons.logging.Log (for backwards
- compatibility to pre-1.0 versions of this API, an attribute
- org.apache.commons.logging.log is also consulted).org.apache.commons.logging.Log (for backwards
- compatibility to pre-1.0 versions of this API, a system property
- org.apache.commons.logging.log is also consulted).LogFactory class otherwise.Log
- implementation class, passing the specified name as the single
- argument to its constructor.Configuring the Underlying Logging System
-
-Log implementations (such as the one for Log4J)
-require an external configuration file for the entire logging environment.
-This file should be prepared in a manner that is specific to the actual logging
-technology being used.Using the Logging Package APIs
-
-
-
-
-trace(), debug(),
- info(), warn(), error, and
- fatal()).LogFactory also offers a static method
-getLog() that combines the typical two-step pattern:
- Log log = LogFactory.getFactory().getInstance(Foo.class);
-
-
- Log log = LogFactory.getLog(Foo.class);
-
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class MyComponent {
-
- protected Log log =
- LogFactory.getLog(MyComponent.class);
-
- // Called once at startup time
- public void start() {
- ...
- log.info("MyComponent started");
- ...
- }
-
- // Called once at shutdown time
- public void stop() {
- ...
- log.info("MyComponent stopped");
- ...
- }
-
- // Called repeatedly to process a particular argument value
- // which you want logged if debugging is enabled
- public void process(String value) {
- ...
- // Do the string concatenation only if logging is enabled
- if (log.isDebugEnabled())
- log.debug("MyComponent processing " + value);
- ...
- }
-
-}
-
-
-
diff --git a/src/org/apache/http/ConnectionClosedException.java b/src/org/apache/http/ConnectionClosedException.java
deleted file mode 100644
index fa0e2dbdf1b96bae9516f9f50312910cc62f092b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/ConnectionClosedException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ConnectionClosedException.java $
- * $Revision: 618017 $
- * $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * false, the caller MUST
- * close the connection to correctly implement the HTTP protocol.
- * If it returns true, the caller SHOULD attempt to
- * keep the connection open for reuse with another request.
- *
- * One can use the HTTP context to retrieve additional objects that
- * may be relevant for the keep-alive strategy: the actual HTTP
- * connection, the original HTTP request, target host if known,
- * number of times the connection has been reused already and so on.
- *
- * If the connection is already closed, false is returned.
- * The stale connection check MUST NOT be triggered by a
- * connection reuse strategy.
- *
- * @param response
- * The last response received over that connection.
- * @param context the context in which the connection is being
- * used.
- *
- * @return true if the connection is allowed to be reused, or
- * false if it MUST NOT be reused
- */
- boolean keepAlive(HttpResponse response, HttpContext context);
-
-}
diff --git a/src/org/apache/http/FormattedHeader.java b/src/org/apache/http/FormattedHeader.java
deleted file mode 100644
index 04ea2795a0ebd19d77b5e128ee74cb423fa6184d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/FormattedHeader.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/FormattedHeader.java $
- * $Revision: 569781 $
- * $Date: 2007-08-26 02:05:06 -0700 (Sun, 26 Aug 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- * message-header = field-name ":" [ field-value ]
- * field-name = token
- * field-value = *( field-content | LWS )
- * field-content = <the OCTETs making up the field-value
- * and consisting of either *TEXT or combinations
- * of token, separators, and quoted-string>
- *
- *
- * @author Remy Maucherat
- * @author Oleg Kalnichevski
- * @version $Revision: 569636 $
- */
-public interface Header {
-
- String getName();
-
- String getValue();
-
- HeaderElement[] getElements() throws ParseException;
-
-}
diff --git a/src/org/apache/http/HeaderElement.java b/src/org/apache/http/HeaderElement.java
deleted file mode 100644
index ddc4a9e1ce1daf62d24375fb2002889f7a2d1f8b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HeaderElement.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HeaderElement.java $
- * $Revision: 569828 $
- * $Date: 2007-08-26 08:49:38 -0700 (Sun, 26 Aug 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * true if there is another header element,
- * false otherwise
- */
- boolean hasNext();
-
- /**
- * Obtains the next header element from this iteration.
- * This method should only be called while {@link #hasNext hasNext}
- * is true.
- *
- * @return the next header element in this iteration
- */
- HeaderElement nextElement();
-
-}
diff --git a/src/org/apache/http/HeaderIterator.java b/src/org/apache/http/HeaderIterator.java
deleted file mode 100644
index 688b611b1e7b8ca3faffa2f28ccaa8c95f32e6cf..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HeaderIterator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HeaderIterator.java $
- * $Revision: 581981 $
- * $Date: 2007-10-04 11:26:26 -0700 (Thu, 04 Oct 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * true if there is another header,
- * false otherwise
- */
- boolean hasNext()
- ;
-
-
- /**
- * Obtains the next header from this iteration.
- * This method should only be called while {@link #hasNext hasNext}
- * is true.
- *
- * @return the next header in this iteration
- */
- Header nextHeader()
- ;
-}
diff --git a/src/org/apache/http/HttpClientConnection.java b/src/org/apache/http/HttpClientConnection.java
deleted file mode 100644
index a38c8f3a2192f497f47301d2b708c38e6724f800..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpClientConnection.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpClientConnection.java $
- * $Revision: 542199 $
- * $Date: 2007-05-28 04:23:46 -0700 (Mon, 28 May 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * timeout milliseconds.
- * @throws IOException if an error happens on the connection
- */
- boolean isResponseAvailable(int timeout)
- throws IOException;
-
- /**
- * Sends the request line and all headers over the connection.
- * @param request the request whose headers to send.
- * @throws HttpException
- * @throws IOException
- */
- void sendRequestHeader(HttpRequest request)
- throws HttpException, IOException;
-
- /**
- * Sends the request entity over the connection.
- * @param request the request whose entity to send.
- * @throws HttpException
- * @throws IOException
- */
- void sendRequestEntity(HttpEntityEnclosingRequest request)
- throws HttpException, IOException;
-
- /**
- * Receives the request line and headers of the next response available from
- * this connection. The caller should examine the HttpResponse object to
- * find out if it should try to receive a response entity as well.
- *
- * @return a new HttpResponse object with status line and headers
- * initialized.
- * @throws HttpException
- * @throws IOException
- */
- HttpResponse receiveResponseHeader()
- throws HttpException, IOException;
-
- /**
- * Receives the next response entity available from this connection and
- * attaches it to an existing HttpResponse object.
- *
- * @param response the response to attach the entity to
- * @throws HttpException
- * @throws IOException
- */
- void receiveResponseEntity(HttpResponse response)
- throws HttpException, IOException;
-
- /**
- * Writes out all pending buffered data over the open connection.
- *
- * @throws IOException
- */
- void flush() throws IOException;
-
-}
diff --git a/src/org/apache/http/HttpConnection.java b/src/org/apache/http/HttpConnection.java
deleted file mode 100644
index a3311f8cb2d553d00a76cf77151b2bd8d46c12cd..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpConnection.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpConnection.java $
- * $Revision: 548031 $
- * $Date: 2007-06-17 04:28:38 -0700 (Sun, 17 Jun 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * true if attempts to use this connection are
- * likely to succeed, or false if they are likely
- * to fail and this connection should be closed
- */
- public boolean isStale();
-
- /**
- * Sets the socket timeout value.
- *
- * @param timeout timeout value in milliseconds
- */
- void setSocketTimeout(int timeout);
-
- /**
- * Returns the socket timeout value.
- *
- * @return positive value in milliseconds if a timeout is set,
- * 0 if timeout is disabled or -1 if
- * timeout is undefined.
- */
- int getSocketTimeout();
-
- /**
- * Force-closes this connection.
- * This is the only method of a connection which may be called
- * from a different thread to terminate the connection.
- * This method will not attempt to flush the transmitter's
- * internal buffer prior to closing the underlying socket.
- */
- public void shutdown() throws IOException;
-
- /**
- * Returns a collection of connection metrcis
- * @return HttpConnectionMetrics
- */
- HttpConnectionMetrics getMetrics();
-
-}
diff --git a/src/org/apache/http/HttpConnectionMetrics.java b/src/org/apache/http/HttpConnectionMetrics.java
deleted file mode 100644
index 289dd46a8b07d1baa610262c7870baeb611660d5..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpConnectionMetrics.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpConnectionMetrics.java $
- * $Revision: 548035 $
- * $Date: 2007-06-17 05:17:03 -0700 (Sun, 17 Jun 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null if the metric cannot not found.
- */
- Object getMetric(String metricName);
-
- /**
- * Resets the counts
- *
- */
- void reset();
-
-}
diff --git a/src/org/apache/http/HttpEntity.java b/src/org/apache/http/HttpEntity.java
deleted file mode 100644
index 51ddafc0ee5958d1087c6618463f8c8702a4fbf8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpEntity.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpEntity.java $
- * $Revision: 645824 $
- * $Date: 2008-04-08 03:12:41 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- *
- * This distinction is important for connection management with incoming
- * entities. For entities that are created by an application and only sent
- * using the HTTP components framework, the difference between streamed
- * and self-contained is of little importance. In that case, it is suggested
- * to consider non-repeatable entities as streamed, and those that are
- * repeatable (without a huge effort) as self-contained.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 645824 $
- *
- * @since 4.0
- */
-public interface HttpEntity {
-
- /**
- * Tells if the entity is capable to produce its data more than once.
- * A repeatable entity's getContent() and writeTo(OutputStream) methods
- * can be called more than once whereas a non-repeatable entity's can not.
- * @return true if the entity is repeatable, false otherwise.
- */
- boolean isRepeatable();
-
- /**
- * Tells about chunked encoding for this entity.
- * The primary purpose of this method is to indicate whether
- * chunked encoding should be used when the entity is sent.
- * For entities that are received, it can also indicate whether
- * the entity was received with chunked encoding.
- *
- * The behavior of wrapping entities is implementation dependent,
- * but should respect the primary purpose.
- *
- * @return true if chunked encoding is preferred for this
- * entity, or false if it is not
- */
- boolean isChunked();
-
- /**
- * Tells the length of the content, if known.
- *
- * @return the number of bytes of the content, or
- * a negative number if unknown. If the content length is known
- * but exceeds {@link java.lang.Long#MAX_VALUE Long.MAX_VALUE},
- * a negative number is returned.
- */
- long getContentLength();
-
- /**
- * Obtains the Content-Type header, if known.
- * This is the header that should be used when sending the entity,
- * or the one that was received with the entity. It can include a
- * charset attribute.
- *
- * @return the Content-Type header for this entity, or
- * null if the content type is unknown
- */
- Header getContentType();
-
- /**
- * Obtains the Content-Encoding header, if known.
- * This is the header that should be used when sending the entity,
- * or the one that was received with the entity.
- * Wrapping entities that modify the content encoding should
- * adjust this header accordingly.
- *
- * @return the Content-Encoding header for this entity, or
- * null if the content encoding is unknown
- */
- Header getContentEncoding();
-
- /**
- * Creates a new InputStream object of the entity.
- * It is a programming error
- * to return the same InputStream object more than once.
- * Entities that are not {@link #isRepeatable repeatable}
- * will throw an exception if this method is called multiple times.
- *
- * @return a new input stream that returns the entity data.
- *
- * @throws IOException if the stream could not be created
- * @throws IllegalStateException
- * if this entity is not repeatable and the stream
- * has already been obtained previously
- */
- InputStream getContent() throws IOException, IllegalStateException;
-
- /**
- * Writes the entity content to the output stream.
- *
- * @param outstream the output stream to write entity content to
- *
- * @throws IOException if an I/O error occurs
- */
- void writeTo(OutputStream outstream) throws IOException;
-
- /**
- * Tells whether this entity depends on an underlying stream.
- * Streamed entities should return true until the
- * content has been consumed, false afterwards.
- * Self-contained entities should return false.
- * Wrapping entities should delegate this call to the wrapped entity.
- *
- * The content of a streamed entity is consumed when the stream
- * returned by {@link #getContent getContent} has been read to EOF,
- * or after {@link #consumeContent consumeContent} has been called.
- * If a streamed entity can not detect whether the stream has been
- * read to EOF, it should return true until
- * {@link #consumeContent consumeContent} is called.
- *
- * @return true if the entity content is streamed and
- * not yet consumed, false otherwise
- */
- boolean isStreaming(); // don't expect an exception here
-
- /**
- * TODO: The name of this method is misnomer. It will be renamed to
- * #finish() in the next major release.
- *
- * This method is called to indicate that the content of this entity
- * is no longer required. All entity implementations are expected to
- * release all allocated resources as a result of this method
- * invocation. Content streaming entities are also expected to
- * dispose of the remaining content, if any. Wrapping entities should
- * delegate this call to the wrapped entity.
- *
- * This method is of particular importance for entities being
- * received from a {@link HttpConnection connection}. The entity
- * needs to be consumed completely in order to re-use the connection
- * with keep-alive.
- *
- * @throws IOException if an I/O error occurs.
- * This indicates that connection keep-alive is not possible.
- */
- void consumeContent() throws IOException;
-
-} // interface HttpEntity
diff --git a/src/org/apache/http/HttpEntityEnclosingRequest.java b/src/org/apache/http/HttpEntityEnclosingRequest.java
deleted file mode 100644
index c47c32b282cfb1738c7ef248cebba36e7a4e4a8c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpEntityEnclosingRequest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * $Header: $
- * $Revision: 618017 $
- * $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * -1 indicates the scheme default port.
- * @param scheme the name of the scheme.
- * null indicates the
- * {@link #DEFAULT_SCHEME_NAME default scheme}
- */
- public HttpHost(final String hostname, int port, final String scheme) {
- super();
- if (hostname == null) {
- throw new IllegalArgumentException("Host name may not be null");
- }
- this.hostname = hostname;
- this.lcHostname = hostname.toLowerCase(Locale.ENGLISH);
- if (scheme != null) {
- this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
- } else {
- this.schemeName = DEFAULT_SCHEME_NAME;
- }
- this.port = port;
- }
-
- /**
- * Creates a new {@link HttpHost HttpHost}, with default scheme.
- *
- * @param hostname the hostname (IP or DNS name)
- * @param port the port number.
- * -1 indicates the scheme default port.
- */
- public HttpHost(final String hostname, int port) {
- this(hostname, port, null);
- }
-
- /**
- * Creates a new {@link HttpHost HttpHost}, with default scheme and port.
- *
- * @param hostname the hostname (IP or DNS name)
- */
- public HttpHost(final String hostname) {
- this(hostname, -1, null);
- }
-
- /**
- * Copy constructor for {@link HttpHost HttpHost}.
- *
- * @param httphost the HTTP host to copy details from
- */
- public HttpHost (final HttpHost httphost) {
- this(httphost.hostname, httphost.port, httphost.schemeName);
- }
-
- /**
- * Returns the host name.
- *
- * @return the host name (IP or DNS name)
- */
- public String getHostName() {
- return this.hostname;
- }
-
- /**
- * Returns the port.
- *
- * @return the host port, or -1 if not set
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Returns the scheme name.
- *
- * @return the scheme name
- */
- public String getSchemeName() {
- return this.schemeName;
- }
-
- /**
- * Return the host URI, as a string.
- *
- * @return the host URI
- */
- public String toURI() {
- CharArrayBuffer buffer = new CharArrayBuffer(32);
- buffer.append(this.schemeName);
- buffer.append("://");
- buffer.append(this.hostname);
- if (this.port != -1) {
- buffer.append(':');
- buffer.append(Integer.toString(this.port));
- }
- return buffer.toString();
- }
-
-
- /**
- * Obtains the host string, without scheme prefix.
- *
- * @return the host string, for example localhost:8080
- */
- public String toHostString() {
- CharArrayBuffer buffer = new CharArrayBuffer(32);
- buffer.append(this.hostname);
- if (this.port != -1) {
- buffer.append(':');
- buffer.append(Integer.toString(this.port));
- }
- return buffer.toString();
- }
-
-
- public String toString() {
- return toURI();
- }
-
-
- public boolean equals(final Object obj) {
- if (obj == null) return false;
- if (this == obj) return true;
- if (obj instanceof HttpHost) {
- HttpHost that = (HttpHost) obj;
- return this.lcHostname.equals(that.lcHostname)
- && this.port == that.port
- && this.schemeName.equals(that.schemeName);
- } else {
- return false;
- }
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.lcHostname);
- hash = LangUtils.hashCode(hash, this.port);
- hash = LangUtils.hashCode(hash, this.schemeName);
- return hash;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-}
diff --git a/src/org/apache/http/HttpInetConnection.java b/src/org/apache/http/HttpInetConnection.java
deleted file mode 100644
index 32ac04a03b4f4c6d72cde84d7fa76873080fb4b9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpInetConnection.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpInetConnection.java $
- * $Revision: 613298 $
- * $Date: 2008-01-18 14:09:22 -0800 (Fri, 18 Jan 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * name.
- */
- Header[] getHeaders(String name);
-
- /**
- * Returns the first header with a specified name of this message. Header
- * values are ignored. If there is more than one matching header in the
- * message the first element of {@link #getHeaders(String)} is returned.
- * If there is no matching header in the message null is
- * returned.
- *
- * @param name the name of the header to return.
- * @return the first header whose name property equals name
- * or null if no such header could be found.
- */
- Header getFirstHeader(String name);
-
- /**
- * Returns the last header with a specified name of this message. Header values
- * are ignored. If there is more than one matching header in the message the
- * last element of {@link #getHeaders(String)} is returned. If there is no
- * matching header in the message null is returned.
- *
- * @param name the name of the header to return.
- * @return the last header whose name property equals name.
- * or null if no such header could be found.
- */
- Header getLastHeader(String name);
-
- /**
- * Returns all the headers of this message. Headers are orderd in the sequence
- * they will be sent over a connection.
- *
- * @return all the headers of this message
- */
- Header[] getAllHeaders();
-
- /**
- * Adds a header to this message. The header will be appended to the end of
- * the list.
- *
- * @param header the header to append.
- */
- void addHeader(Header header);
-
- /**
- * Adds a header to this message. The header will be appended to the end of
- * the list.
- *
- * @param name the name of the header.
- * @param value the value of the header.
- */
- void addHeader(String name, String value);
-
- /**
- * Overwrites the first header with the same name. The new header will be appended to
- * the end of the list, if no header with the given name can be found.
- *
- * @param header the header to set.
- */
- void setHeader(Header header);
-
- /**
- * Overwrites the first header with the same name. The new header will be appended to
- * the end of the list, if no header with the given name can be found.
- *
- * @param name the name of the header.
- * @param value the value of the header.
- */
- void setHeader(String name, String value);
-
- /**
- * Overwrites all the headers in the message.
- *
- * @param headers the array of headers to set.
- */
- void setHeaders(Header[] headers);
-
- /**
- * Removes a header from this message.
- *
- * @param header the header to remove.
- */
- void removeHeader(Header header);
-
- /**
- * Removes all headers with a certain name from this message.
- *
- * @param name The name of the headers to remove.
- */
- void removeHeaders(String name);
-
- /**
- * Returns an iterator of all the headers.
- *
- * @return Iterator that returns Header objects in the sequence they are
- * sent over a connection.
- */
- HeaderIterator headerIterator();
-
- /**
- * Returns an iterator of the headers with a given name.
- *
- * @param name the name of the headers over which to iterate, or
- * null for all headers
- *
- * @return Iterator that returns Header objects with the argument name
- * in the sequence they are sent over a connection.
- */
- HeaderIterator headerIterator(String name);
-
- /**
- * Returns the parameters effective for this message as set by
- * {@link #setParams(HttpParams)}.
- */
- HttpParams getParams();
-
- /**
- * Provides parameters to be used for the processing of this message.
- * @param params the parameters
- */
- void setParams(HttpParams params);
-
-}
diff --git a/src/org/apache/http/HttpRequest.java b/src/org/apache/http/HttpRequest.java
deleted file mode 100644
index 8558a9715ed2fb62288b9486580557749a35a55c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpRequest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpRequest.java $
- * $Revision: 528428 $
- * $Date: 2007-04-13 03:26:04 -0700 (Fri, 13 Apr 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null if not yet set
- */
- StatusLine getStatusLine();
-
- /**
- * Sets the status line of this response.
- *
- * @param statusline the status line of this response
- */
- void setStatusLine(StatusLine statusline);
-
- /**
- * Sets the status line of this response.
- * The reason phrase will be determined based on the current
- * {@link #getLocale locale}.
- *
- * @param ver the HTTP version
- * @param code the status code
- */
- void setStatusLine(ProtocolVersion ver, int code);
-
- /**
- * Sets the status line of this response with a reason phrase.
- *
- * @param ver the HTTP version
- * @param code the status code
- * @param reason the reason phrase, or null to omit
- */
- void setStatusLine(ProtocolVersion ver, int code, String reason);
-
- /**
- * Updates the status line of this response with a new status code.
- * The status line can only be updated if it is available. It must
- * have been set either explicitly or in a constructor.
- *
- * The reason phrase will be updated according to the new status code,
- * based on the current {@link #getLocale locale}. It can be set
- * explicitly using {@link #setReasonPhrase setReasonPhrase}.
- *
- * @param code the HTTP status code.
- *
- * @throws IllegalStateException
- * if the status line has not be set
- *
- * @see HttpStatus
- * @see #setStatusLine(StatusLine)
- * @see #setStatusLine(ProtocolVersion,int)
- */
- void setStatusCode(int code)
- throws IllegalStateException;
-
- /**
- * Updates the status line of this response with a new reason phrase.
- * The status line can only be updated if it is available. It must
- * have been set either explicitly or in a constructor.
- *
- * @param reason the new reason phrase as a single-line string, or
- * null to unset the reason phrase
- *
- * @throws IllegalStateException
- * if the status line has not be set
- *
- * @see #setStatusLine(StatusLine)
- * @see #setStatusLine(ProtocolVersion,int)
- */
- void setReasonPhrase(String reason)
- throws IllegalStateException;
-
- /**
- * Obtains the message entity of this response, if any.
- * The entity is provided by calling {@link #setEntity setEntity}.
- *
- * @return the response entity, or
- * null if there is none
- */
- HttpEntity getEntity();
-
- /**
- * Associates a response entity with this response.
- *
- * @param entity the entity to associate with this response, or
- * null to unset
- */
- void setEntity(HttpEntity entity);
-
- /**
- * Obtains the locale of this response.
- * The locale is used to determine the reason phrase
- * for the {@link #setStatusCode status code}.
- * It can be changed using {@link #setLocale setLocale}.
- *
- * @return the locale of this response, never null
- */
- Locale getLocale();
-
- /**
- * Changes the locale of this response.
- * If there is a status line, it's reason phrase will be updated
- * according to the status code and new locale.
- *
- * @param loc the new locale
- *
- * @see #getLocale getLocale
- * @see #setStatusCode setStatusCode
- */
- void setLocale(Locale loc);
-}
diff --git a/src/org/apache/http/HttpResponseFactory.java b/src/org/apache/http/HttpResponseFactory.java
deleted file mode 100644
index 3ed06ff0d2c1ac3ac83c2a0bd6df51e83ee6c826..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpResponseFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpResponseFactory.java $
- * $Revision: 573864 $
- * $Date: 2007-09-08 08:53:25 -0700 (Sat, 08 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null to use the default locale
- *
- * @return the new response with an initialized status line
- */
- HttpResponse newHttpResponse(ProtocolVersion ver, int status,
- HttpContext context);
-
- /**
- * Creates a new response from a status line.
- *
- * @param statusline the status line
- * @param context the context from which to determine the locale
- * for looking up a reason phrase if the status code
- * is updated, or
- * null to use the default locale
- *
- * @return the new response with the argument status line
- */
- HttpResponse newHttpResponse(StatusLine statusline,
- HttpContext context);
-
-}
diff --git a/src/org/apache/http/HttpResponseInterceptor.java b/src/org/apache/http/HttpResponseInterceptor.java
deleted file mode 100644
index cae1526fb1231434f665968d3df6dbcb7c870d6a..0000000000000000000000000000000000000000
--- a/src/org/apache/http/HttpResponseInterceptor.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/HttpResponseInterceptor.java $
- * $Revision: 618367 $
- * $Date: 2008-02-04 10:26:06 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- * OCTET =
- *
- * token = 1*
- *
- * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
- * qdtext =
- *
- * quoted-pair = "\" CHAR
- *
- *
- * parameter = attribute "=" value
- * attribute = token
- * value = token | quoted-string
- *
- *
- * @author Oleg Kalnichevski
- *
- */
-public interface NameValuePair {
-
- String getName();
-
- String getValue();
-
-}
diff --git a/src/org/apache/http/NoHttpResponseException.java b/src/org/apache/http/NoHttpResponseException.java
deleted file mode 100644
index a02ef5a23425bf5ff8afdf3e3c0688e11bbc1b64..0000000000000000000000000000000000000000
--- a/src/org/apache/http/NoHttpResponseException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/NoHttpResponseException.java $
- * $Revision: 618017 $
- * $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null
- */
- public ParseException(String message) {
- super(message);
- }
-
-}
diff --git a/src/org/apache/http/ProtocolException.java b/src/org/apache/http/ProtocolException.java
deleted file mode 100644
index b4c34eee9e7c11b614cc2f5641c456f42308ba84..0000000000000000000000000000000000000000
--- a/src/org/apache/http/ProtocolException.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ProtocolException.java $
- * $Revision: 618017 $
- * $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- * The default implementation in this class returns this
- * if the version matches, and creates a new {@link ProtocolVersion}
- * otherwise.
- *
- * @param major the major version
- * @param minor the minor version
- *
- * @return a protocol version with the same protocol name
- * and the argument version
- */
- public ProtocolVersion forVersion(int major, int minor) {
-
- if ((major == this.major) && (minor == this.minor)) {
- return this;
- }
-
- // argument checking is done in the constructor
- return new ProtocolVersion(this.protocol, major, minor);
- }
-
-
- /**
- * Obtains a hash code consistent with {@link #equals}.
- *
- * @return the hashcode of this protocol version
- */
- public final int hashCode() {
- return this.protocol.hashCode() ^ (this.major * 100000) ^ this.minor;
- }
-
-
- /**
- * Checks equality of this protocol version with an object.
- * The object is equal if it is a protocl version with the same
- * protocol name, major version number, and minor version number.
- * The specific class of the object is not relevant,
- * instances of derived classes with identical attributes are
- * equal to instances of the base class and vice versa.
- *
- * @param obj the object to compare with
- *
- * @return true if the argument is the same protocol version,
- * false otherwise
- */
- public final boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof ProtocolVersion)) {
- return false;
- }
- ProtocolVersion that = (ProtocolVersion) obj;
-
- return ((this.protocol.equals(that.protocol)) &&
- (this.major == that.major) &&
- (this.minor == that.minor));
- }
-
-
- /**
- * Checks whether this protocol can be compared to another one.
- * Only protocol versions with the same protocol name can be
- * {@link #compareToVersion compared}.
- *
- * @param that the protocol version to consider
- *
- * @return true if {@link #compareToVersion compareToVersion}
- * can be called with the argument, false otherwise
- */
- public boolean isComparable(ProtocolVersion that) {
- return (that != null) && this.protocol.equals(that.protocol);
- }
-
-
- /**
- * Compares this protocol version with another one.
- * Only protocol versions with the same protocol name can be compared.
- * This method does not define a total ordering, as it would be
- * required for {@link java.lang.Comparable}.
- *
- * @param that the protocl version to compare with
- *
- * @return a negative integer, zero, or a positive integer
- * as this version is less than, equal to, or greater than
- * the argument version.
- *
- * @throws IllegalArgumentException
- * if the argument has a different protocol name than this object,
- * or if the argument is null
- */
- public int compareToVersion(ProtocolVersion that) {
- if (that == null) {
- throw new IllegalArgumentException
- ("Protocol version must not be null.");
- }
- if (!this.protocol.equals(that.protocol)) {
- throw new IllegalArgumentException
- ("Versions for different protocols cannot be compared. " +
- this + " " + that);
- }
-
- int delta = getMajor() - that.getMajor();
- if (delta == 0) {
- delta = getMinor() - that.getMinor();
- }
- return delta;
- }
-
-
- /**
- * Tests if this protocol version is greater or equal to the given one.
- *
- * @param version the version against which to check this version
- *
- * @return true if this protocol version is
- * {@link #isComparable comparable} to the argument
- * and {@link #compareToVersion compares} as greater or equal,
- * false otherwise
- */
- public final boolean greaterEquals(ProtocolVersion version) {
- return isComparable(version) && (compareToVersion(version) >= 0);
- }
-
-
- /**
- * Tests if this protocol version is less or equal to the given one.
- *
- * @param version the version against which to check this version
- *
- * @return true if this protocol version is
- * {@link #isComparable comparable} to the argument
- * and {@link #compareToVersion compares} as less or equal,
- * false otherwise
- */
- public final boolean lessEquals(ProtocolVersion version) {
- return isComparable(version) && (compareToVersion(version) <= 0);
- }
-
-
- /**
- * Converts this protocol version to a string.
- *
- * @return a protocol version string, like "HTTP/1.1"
- */
- public String toString() {
- CharArrayBuffer buffer = new CharArrayBuffer(16);
- buffer.append(this.protocol);
- buffer.append('/');
- buffer.append(Integer.toString(this.major));
- buffer.append('.');
- buffer.append(Integer.toString(this.minor));
- return buffer.toString();
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-}
diff --git a/src/org/apache/http/ReasonPhraseCatalog.java b/src/org/apache/http/ReasonPhraseCatalog.java
deleted file mode 100644
index 12ad6d95fea66ef8ae5a83b3bc8a15fbd12a0228..0000000000000000000000000000000000000000
--- a/src/org/apache/http/ReasonPhraseCatalog.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/ReasonPhraseCatalog.java $
- * $Revision: 505744 $
- * $Date: 2007-02-10 10:58:45 -0800 (Sat, 10 Feb 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null if unknown
- */
- public String getReason(int status, Locale loc)
- ;
-
-}
diff --git a/src/org/apache/http/RequestLine.java b/src/org/apache/http/RequestLine.java
deleted file mode 100644
index e86592956fedb58cbef018ab010d1bdc0ee2b0a4..0000000000000000000000000000000000000000
--- a/src/org/apache/http/RequestLine.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/RequestLine.java $
- * $Revision: 573864 $
- * $Date: 2007-09-08 08:53:25 -0700 (Sat, 08 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * true if there is another token,
- * false otherwise
- */
- boolean hasNext()
- ;
-
-
- /**
- * Obtains the next token from this iteration.
- * This method should only be called while {@link #hasNext hasNext}
- * is true.
- *
- * @return the next token in this iteration
- */
- String nextToken()
- ;
-}
diff --git a/src/org/apache/http/UnsupportedHttpVersionException.java b/src/org/apache/http/UnsupportedHttpVersionException.java
deleted file mode 100644
index 716d7a54e57bb341f2301e2dd57ef794ac4ab832..0000000000000000000000000000000000000000
--- a/src/org/apache/http/UnsupportedHttpVersionException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * $HeadURL:https://svn.apache.org/repos/asf/jakarta/httpcomponents/trunk/coyote-httpconnector/src/java/org/apache/http/tcconnector/UnsupportedHttpVersionException.java $
- * $Revision:379772 $
- * $Date:2006-02-22 14:52:29 +0100 (Wed, 22 Feb 2006) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- *
- *
- *
- * Authentication schemes may ignore method name and URI parameters - * if they are not relevant for the given authentication mechanism - *
- *- * Authentication schemes may be stateful involving a series of - * challenge-response exchanges - *
- * - * @author Oleg Kalnichevski - * @author Adrian Sutton - * - * @since 4.0 - */ - -public interface AuthScheme { - - /** - * Processes the given challenge token. Some authentication schemes - * may involve multiple challenge-response exchanges. Such schemes must be able - * to maintain the state information when dealing with sequential challenges - * - * @param header the challenge header - */ - void processChallenge(final Header header) throws MalformedChallengeException; - - /** - * Returns textual designation of the given authentication scheme. - * - * @return the name of the given authentication scheme - */ - String getSchemeName(); - - /** - * Returns authentication parameter with the given name, if available. - * - * @param name The name of the parameter to be returned - * - * @return the parameter with the given name - */ - String getParameter(final String name); - - /** - * Returns authentication realm. If the concept of an authentication - * realm is not applicable to the given authentication scheme, returns - *null.
- *
- * @return the authentication realm
- */
- String getRealm();
-
- /**
- * Tests if the authentication scheme is provides authorization on a per
- * connection basis instead of usual per request basis
- *
- * @return true if the scheme is connection based, false
- * if the scheme is request based.
- */
- boolean isConnectionBased();
-
- /**
- * Authentication process may involve a series of challenge-response exchanges.
- * This method tests if the authorization process has been completed, either
- * successfully or unsuccessfully, that is, all the required authorization
- * challenges have been processed in their entirety.
- *
- * @return true if the authentication process has been completed,
- * false otherwise.
- */
- boolean isComplete();
-
- /**
- * Produces an authorization string for the given set of {@link Credentials}.
- *
- * @param credentials The set of credentials to be used for athentication
- * @param request The request being authenticated
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return the authorization string
- */
- Header authenticate(Credentials credentials, HttpRequest request)
- throws AuthenticationException;
-
-}
diff --git a/src/org/apache/http/auth/AuthSchemeFactory.java b/src/org/apache/http/auth/AuthSchemeFactory.java
deleted file mode 100644
index 8f985b0df8f640f3ccb33342580ce7bcd4bd78f7..0000000000000000000000000000000000000000
--- a/src/org/apache/http/auth/AuthSchemeFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/AuthSchemeFactory.java $
- * $Revision: 527900 $
- * $Date: 2007-04-12 05:35:25 -0700 (Thu, 12 Apr 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * - * Please note that custom authentication preferences, if used, need to be updated accordingly - * for the new {@link AuthScheme authentication scheme} to take effect. - *
- * - * @param name the identifier for this scheme - * @param factory the {@link AuthSchemeFactory} class to register - * - * @see #getAuthScheme - */ - public synchronized void register( - final String name, - final AuthSchemeFactory factory) { - if (name == null) { - throw new IllegalArgumentException("Name may not be null"); - } - if (factory == null) { - throw new IllegalArgumentException("Authentication scheme factory may not be null"); - } - registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory); - } - - /** - * Unregisters the class implementing an {@link AuthScheme authentication scheme} with - * the given name. - * - * @param name the identifier of the class to unregister - */ - public synchronized void unregister(final String name) { - if (name == null) { - throw new IllegalArgumentException("Name may not be null"); - } - registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH)); - } - - /** - * Gets the {@link AuthScheme authentication scheme} with the given name. - * - * @param name the {@link AuthScheme authentication scheme} identifier - * @param params the {@link HttpParams HTTP parameters} for the authentication - * scheme. - * - * @return {@link AuthScheme authentication scheme} - * - * @throws IllegalStateException if a scheme with the given name cannot be found - */ - public synchronized AuthScheme getAuthScheme(final String name, final HttpParams params) - throws IllegalStateException { - - if (name == null) { - throw new IllegalArgumentException("Name may not be null"); - } - AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH)); - if (factory != null) { - return factory.newInstance(params); - } else { - throw new IllegalStateException("Unsupported authentication scheme: " + name); - } - } - - /** - * Obtains a list containing names of all registered {@link AuthScheme authentication - * schemes} in their default order. - * - * @return list of registered scheme names - */ - public synchronized Listnullnull.
- *
- */
-
-package org.apache.http.auth;
-
-import org.apache.http.ProtocolException;
-
-/**
- * Signals a failure in authentication process
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class AuthenticationException extends ProtocolException {
-
- private static final long serialVersionUID = -6794031905674764776L;
-
- /**
- * Creates a new AuthenticationException with a null detail message.
- */
- public AuthenticationException() {
- super();
- }
-
- /**
- * Creates a new AuthenticationException with the specified message.
- *
- * @param message the exception detail message
- */
- public AuthenticationException(String message) {
- super(message);
- }
-
- /**
- * Creates a new AuthenticationException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the Throwable that caused this exception, or null
- * if the cause is unavailable, unknown, or not a Throwable
- */
- public AuthenticationException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/src/org/apache/http/auth/BasicUserPrincipal.java b/src/org/apache/http/auth/BasicUserPrincipal.java
deleted file mode 100644
index 248501115749290b6d62b2391cad50736d641ba9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/auth/BasicUserPrincipal.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/BasicUserPrincipal.java $
- * $Revision: 658430 $
- * $Date: 2008-05-20 14:04:27 -0700 (Tue, 20 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * - * This parameter expects a value of type {@link String}. - * If not defined, then - * {@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET - * HttpProtocolParams.HTTP_ELEMENT_CHARSET} - * should be used. - *
- */ - public static final String CREDENTIAL_CHARSET = "http.auth.credential-charset"; - -} diff --git a/src/org/apache/http/auth/params/AuthParamBean.java b/src/org/apache/http/auth/params/AuthParamBean.java deleted file mode 100644 index 5b273285893863aae554e419f337eea5468d9530..0000000000000000000000000000000000000000 --- a/src/org/apache/http/auth/params/AuthParamBean.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/auth/params/AuthParamBean.java $ - * $Revision: 632313 $ - * $Date: 2008-02-29 05:19:50 -0800 (Fri, 29 Feb 2008) $ - * - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *null to use the default context
- *
- * @return the response to the request. This is always a final response,
- * never an intermediate response with an 1xx status code.
- * Whether redirects or authentication challenges will be returned
- * or handled automatically depends on the implementation and
- * configuration of this client.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- HttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException
- ;
-
-
- /**
- * Executes a request to the target using the default context.
- *
- * @param target the target host for the request.
- * Implementations may accept null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- *
- * @return the response to the request. This is always a final response,
- * never an intermediate response with an 1xx status code.
- * Whether redirects or authentication challenges will be returned
- * or handled automatically depends on the implementation and
- * configuration of this client.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- HttpResponse execute(HttpHost target, HttpRequest request)
- throws IOException, ClientProtocolException
- ;
-
- /**
- * Executes a request to the target using the given context.
- *
- * @param target the target host for the request.
- * Implementations may accept null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param context the context to use for the execution, or
- * null to use the default context
- *
- * @return the response to the request. This is always a final response,
- * never an intermediate response with an 1xx status code.
- * Whether redirects or authentication challenges will be returned
- * or handled automatically depends on the implementation and
- * configuration of this client.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- HttpResponse execute(HttpHost target, HttpRequest request,
- HttpContext context)
- throws IOException, ClientProtocolException
- ;
-
- /**
- * Executes a request using the default context and processes the
- * response using the given response handler.
- *
- * @param request the request to execute
- * @param responseHandler the response handler
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param responseHandler the response handler
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param responseHandler the response handler
- * @param context the context to use for the execution, or
- * null to use the default context
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- - * Classes implementing this interface must synchronize access to shared - * data as methods of this interfrace may be executed from multiple threads - *
- * - * @author Michael Becke - * @author Oleg Kalnichevski - */ -public interface HttpRequestRetryHandler { - - /** - * Determines if a method should be retried after an IOException - * occurs during execution. - * - * @param exception the exception that occurred - * @param executionCount the number of times this method has been - * unsuccessfully executed - * @param context the context for the request execution - * - * @returntrue if the method should be retried, false
- * otherwise
- */
- boolean retryRequest(IOException exception, int executionCount, HttpContext context);
-
-}
diff --git a/src/org/apache/http/client/HttpResponseException.java b/src/org/apache/http/client/HttpResponseException.java
deleted file mode 100644
index 4d8de91a1e24e13876dd08402831bdab679f180b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/HttpResponseException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/HttpResponseException.java $
- * $Revision: 672425 $
- * $Date: 2008-06-27 16:33:05 -0700 (Fri, 27 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * - * Classes implementing this interface must synchronize access to shared - * data as methods of this interfrace may be executed from multiple threads - *
- * - * @author Oleg Kalnichevski - */ -public interface RedirectHandler { - - /** - * Determines if a request should be redirected to a new location - * given the response from the target server. - * - * @param response the response received from the target server - * @param context the context for the request execution - * - * @returntrue if the request should be redirected, false
- * otherwise
- */
- boolean isRedirectRequested(HttpResponse response, HttpContext context);
-
- /**
- * Determines the location request is expected to be redirected to
- * given the response from the target server and the current request
- * execution context.
- *
- * @param response the response received from the target server
- * @param context the context for the request execution
- *
- * @return redirect URI
- */
- URI getLocationURI(HttpResponse response, HttpContext context)
- throws ProtocolException;
-
-}
diff --git a/src/org/apache/http/client/RequestDirector.java b/src/org/apache/http/client/RequestDirector.java
deleted file mode 100644
index 924c312f3ac78dd18559ea5d8730b89f8ab2b19f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/RequestDirector.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/RequestDirector.java $
- * $Revision: 676020 $
- * $Date: 2008-07-11 09:38:49 -0700 (Fri, 11 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * HttpMethodDirector
- * in HttpClient 3.
- *
- * @param target the target host for the request.
- * Implementations may accept null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param context the context for executing the request
- *
- * @return the final response to the request.
- * This is never an intermediate response with status code 1xx.
- *
- * @throws HttpException in case of a problem
- * @throws IOException in case of an IO problem
- * or if the connection was aborted
- */
- HttpResponse execute(HttpHost target, HttpRequest request,
- HttpContext context)
- throws HttpException, IOException
- ;
-
-} // class ClientRequestDirector
diff --git a/src/org/apache/http/client/ResponseHandler.java b/src/org/apache/http/client/ResponseHandler.java
deleted file mode 100644
index 33a3391f0f207213eb59eb9ab03b9d36b23f1673..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/ResponseHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/ResponseHandler.java $
- * $Revision: 677240 $
- * $Date: 2008-07-16 04:25:47 -0700 (Wed, 16 Jul 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * null if the context does not contain any resources or details
- * specific to the current user.
- *
- * The user token will be used to ensure that user specific resouces will not
- * shared with or reused by other users.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface UserTokenHandler {
-
- /**
- * The token object returned by this method is expected to uniquely
- * identify the current user if the context is user specific or to be
- * null if it is not.
- *
- * @param context the execution context
- *
- * @return user token that uniquely identifies the user or
- * null if the context is not user specific.
- */
- Object getUserToken(HttpContext context);
-
-}
diff --git a/src/org/apache/http/client/entity/UrlEncodedFormEntity.java b/src/org/apache/http/client/entity/UrlEncodedFormEntity.java
deleted file mode 100644
index 89b9c457a7c39aedd471ac156974281278b140df..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/entity/UrlEncodedFormEntity.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntity.java $
- * $Revision: 655107 $
- * $Date: 2008-05-10 08:20:42 -0700 (Sat, 10 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.entity;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.protocol.HTTP;
-
-/**
- * An entity composed of a list of url-encoded pairs.
- * This is typically useful while sending an HTTP POST request.
- */
-public class UrlEncodedFormEntity extends StringEntity {
-
- /**
- * Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters in the specified encoding.
- *
- * @param parameters list of name/value pairs
- * @param encoding encoding the name/value pairs be encoded with
- * @throws UnsupportedEncodingException if the encoding isn't supported
- */
- public UrlEncodedFormEntity (
- final List extends NameValuePair> parameters,
- final String encoding) throws UnsupportedEncodingException {
- super(URLEncodedUtils.format(parameters, encoding),
- encoding);
- setContentType(URLEncodedUtils.CONTENT_TYPE);
- }
-
- /**
- * Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters with the default encoding of {@link HTTP#DEFAULT_CONTENT_CHARSET}
- *
- * @param parameters list of name/value pairs
- * @throws UnsupportedEncodingException if the default encoding isn't supported
- */
- public UrlEncodedFormEntity (
- final List extends NameValuePair> parameters) throws UnsupportedEncodingException {
- super(URLEncodedUtils.format(parameters, HTTP.DEFAULT_CONTENT_CHARSET),
- HTTP.DEFAULT_CONTENT_CHARSET);
- setContentType(URLEncodedUtils.CONTENT_TYPE);
- }
-
-}
diff --git a/src/org/apache/http/client/methods/AbortableHttpRequest.java b/src/org/apache/http/client/methods/AbortableHttpRequest.java
deleted file mode 100644
index c4026095b9683f840dbd7ac172c53127479d477e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/AbortableHttpRequest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java $
- * $Revision: 639600 $
- * $Date: 2008-03-21 04:28:15 -0700 (Fri, 21 Mar 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.io.IOException;
-
-import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.ConnectionReleaseTrigger;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-
-/**
- * Interface representing an HTTP request that can be aborted by shutting
- * down the underlying HTTP connection.
- *
- * @author Oleg Kalnichevski
- *
- *
- * @version $Revision: 639600 $
- *
- * @since 4.0
- */
-public interface AbortableHttpRequest {
-
- /**
- * Sets the {@link ClientConnectionRequest} callback that can be
- * used to abort a long-lived request for a connection.
- * If the request is already aborted, throws an {@link IOException}.
- *
- * @see ClientConnectionManager
- * @see ThreadSafeClientConnManager
- */
- void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
-
- /**
- * Sets the {@link ConnectionReleaseTrigger} callback that can
- * be used to abort an active connection.
- * Typically, this will be the {@link ManagedClientConnection} itself.
- * If the request is already aborted, throws an {@link IOException}.
- */
- void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
-
- /**
- * Aborts this http request. Any active execution of this method should
- * return immediately. If the request has not started, it will abort after
- * the next execution. Aborting this request will cause all subsequent
- * executions with this request to fail.
- *
- * @see HttpClient#execute(HttpUriRequest)
- * @see HttpClient#execute(org.apache.http.HttpHost,
- * org.apache.http.HttpRequest)
- * @see HttpClient#execute(HttpUriRequest,
- * org.apache.http.protocol.HttpContext)
- * @see HttpClient#execute(org.apache.http.HttpHost,
- * org.apache.http.HttpRequest, org.apache.http.protocol.HttpContext)
- */
- void abort();
-
-}
-
diff --git a/src/org/apache/http/client/methods/HttpDelete.java b/src/org/apache/http/client/methods/HttpDelete.java
deleted file mode 100644
index 4a0fb77fcb15280cb9ed0af6d33e92f454006c19..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpDelete.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpDelete.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP DELETE method
- *
- * The HTTP DELETE method is defined in section 9.7 of
- * RFC2616:
- *
- * The DELETE method requests that the origin server delete the resource
- * identified by the Request-URI. [...] The client cannot
- * be guaranteed that the operation has been carried out, even if the
- * status code returned from the origin server indicates that the action
- * has been completed successfully.
- *
- */
-public class HttpDelete extends HttpRequestBase {
-
- public final static String METHOD_NAME = "DELETE";
-
-
- public HttpDelete() {
- super();
- }
-
- public HttpDelete(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpDelete(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java b/src/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
deleted file mode 100644
index 8ac6f013e5b44ce06e241de7a995e7d57d4e8ec3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.client.utils.CloneUtils;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Basic implementation of an HTTP request that can be modified.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 674186 $
- *
- * @since 4.0
- */
-public abstract class HttpEntityEnclosingRequestBase
- extends HttpRequestBase implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
-
- public HttpEntityEnclosingRequestBase() {
- super();
- }
-
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- public void setEntity(final HttpEntity entity) {
- this.entity = entity;
- }
-
- public boolean expectContinue() {
- Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- HttpEntityEnclosingRequestBase clone =
- (HttpEntityEnclosingRequestBase) super.clone();
- if (this.entity != null) {
- clone.entity = (HttpEntity) CloneUtils.clone(this.entity);
- }
- return clone;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpGet.java b/src/org/apache/http/client/methods/HttpGet.java
deleted file mode 100644
index 2908f1d192a7936e19235d1842f667fb5249ee9c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpGet.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpGet.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP GET method.
- *
- * The HTTP GET method is defined in section 9.3 of
- * RFC2616:
- *
- * The GET method means retrieve whatever information (in the form of an
- * entity) is identified by the Request-URI. If the Request-URI refers
- * to a data-producing process, it is the produced data which shall be
- * returned as the entity in the response and not the source text of the
- * process, unless that text happens to be the output of the process.
- *
- *
- *
- * GetMethods will follow redirect requests from the http server by default.
- * This behavour can be disabled by calling setFollowRedirects(false).
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpGet extends HttpRequestBase {
-
- public final static String METHOD_NAME = "GET";
-
- public HttpGet() {
- super();
- }
-
- public HttpGet(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpGet(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpHead.java b/src/org/apache/http/client/methods/HttpHead.java
deleted file mode 100644
index 29e58a372648d3b22683c76fc77a44347964d9bc..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpHead.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpHead.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP HEAD method.
- *
- * The HTTP HEAD method is defined in section 9.4 of
- * RFC2616:
- *
- * The HEAD method is identical to GET except that the server MUST NOT
- * return a message-body in the response. The metainformation contained
- * in the HTTP headers in response to a HEAD request SHOULD be identical
- * to the information sent in response to a GET request. This method can
- * be used for obtaining metainformation about the entity implied by the
- * request without transferring the entity-body itself. This method is
- * often used for testing hypertext links for validity, accessibility,
- * and recent modification.
- *
- *
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpHead extends HttpRequestBase {
-
- public final static String METHOD_NAME = "HEAD";
-
- public HttpHead() {
- super();
- }
-
- public HttpHead(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpHead(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpOptions.java b/src/org/apache/http/client/methods/HttpOptions.java
deleted file mode 100644
index 375836037e49d2ded560c9dcb3084b720405eb8a..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpOptions.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpResponse;
-
-/**
- * HTTP OPTIONS method.
- *
- * The HTTP OPTIONS method is defined in section 9.2 of
- * RFC2616:
- *
- * The OPTIONS method represents a request for information about the
- * communication options available on the request/response chain
- * identified by the Request-URI. This method allows the client to
- * determine the options and/or requirements associated with a resource,
- * or the capabilities of a server, without implying a resource action
- * or initiating a resource retrieval.
- *
- *
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpOptions extends HttpRequestBase {
-
- public final static String METHOD_NAME = "OPTIONS";
-
- public HttpOptions() {
- super();
- }
-
- public HttpOptions(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpOptions(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
- public Set getAllowedMethods(final HttpResponse response) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
-
- HeaderIterator it = response.headerIterator("Allow");
- Set methods = new HashSet();
- while (it.hasNext()) {
- Header header = it.nextHeader();
- HeaderElement[] elements = header.getElements();
- for (HeaderElement element : elements) {
- methods.add(element.getName());
- }
- }
- return methods;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpPost.java b/src/org/apache/http/client/methods/HttpPost.java
deleted file mode 100644
index bc58803b97799069e065944d8c9925106bb99f88..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpPost.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpPost.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP POST method.
- *
- * The HTTP POST method is defined in section 9.5 of
- * RFC2616:
- *
- * The POST method is used to request that the origin server accept the entity
- * enclosed in the request as a new subordinate of the resource identified by
- * the Request-URI in the Request-Line. POST is designed to allow a uniform
- * method to cover the following functions:
- *
- * - Annotation of existing resources
- * - Posting a message to a bulletin board, newsgroup, mailing list, or
- * similar group of articles
- * - Providing a block of data, such as the result of submitting a form,
- * to a data-handling process
- * - Extending a database through an append operation
- *
- *
- *
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpPost extends HttpEntityEnclosingRequestBase {
-
- public final static String METHOD_NAME = "POST";
-
- public HttpPost() {
- super();
- }
-
- public HttpPost(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpPost(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpPut.java b/src/org/apache/http/client/methods/HttpPut.java
deleted file mode 100644
index 5b501354d663ee4a51eb7b17d8943731cd3d24c2..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpPut.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpPut.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP PUT method.
- *
- * The HTTP PUT method is defined in section 9.6 of
- * RFC2616:
- *
- * The PUT method requests that the enclosed entity be stored under the
- * supplied Request-URI. If the Request-URI refers to an already
- * existing resource, the enclosed entity SHOULD be considered as a
- * modified version of the one residing on the origin server.
- *
- *
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpPut extends HttpEntityEnclosingRequestBase {
-
- public final static String METHOD_NAME = "PUT";
-
- public HttpPut() {
- super();
- }
-
- public HttpPut(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpPut(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpRequestBase.java b/src/org/apache/http/client/methods/HttpRequestBase.java
deleted file mode 100644
index 8938ea0288e17a8bae46b6ce35a0086445ae15e8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpRequestBase.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpRequestBase.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.client.utils.CloneUtils;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.ConnectionReleaseTrigger;
-import org.apache.http.message.AbstractHttpMessage;
-import org.apache.http.message.BasicRequestLine;
-import org.apache.http.message.HeaderGroup;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-
-/**
- * Basic implementation of an HTTP request that can be modified.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 674186 $
- *
- * @since 4.0
- */
-public abstract class HttpRequestBase extends AbstractHttpMessage
- implements HttpUriRequest, AbortableHttpRequest, Cloneable {
-
- private Lock abortLock;
-
- private boolean aborted;
-
- private URI uri;
- private ClientConnectionRequest connRequest;
- private ConnectionReleaseTrigger releaseTrigger;
-
- public HttpRequestBase() {
- super();
- this.abortLock = new ReentrantLock();
- }
-
- public abstract String getMethod();
-
- public ProtocolVersion getProtocolVersion() {
- return HttpProtocolParams.getVersion(getParams());
- }
-
- public URI getURI() {
- return this.uri;
- }
-
- public RequestLine getRequestLine() {
- String method = getMethod();
- ProtocolVersion ver = getProtocolVersion();
- URI uri = getURI();
- String uritext = null;
- if (uri != null) {
- uritext = uri.toASCIIString();
- }
- if (uritext == null || uritext.length() == 0) {
- uritext = "/";
- }
- return new BasicRequestLine(method, uritext, ver);
- }
-
- public void setURI(final URI uri) {
- this.uri = uri;
- }
-
- public void setConnectionRequest(final ClientConnectionRequest connRequest)
- throws IOException {
- this.abortLock.lock();
- try {
- if (this.aborted) {
- throw new IOException("Request already aborted");
- }
-
- this.releaseTrigger = null;
- this.connRequest = connRequest;
- } finally {
- this.abortLock.unlock();
- }
- }
-
- public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger)
- throws IOException {
- this.abortLock.lock();
- try {
- if (this.aborted) {
- throw new IOException("Request already aborted");
- }
-
- this.connRequest = null;
- this.releaseTrigger = releaseTrigger;
- } finally {
- this.abortLock.unlock();
- }
- }
-
- public void abort() {
- ClientConnectionRequest localRequest;
- ConnectionReleaseTrigger localTrigger;
-
- this.abortLock.lock();
- try {
- if (this.aborted) {
- return;
- }
- this.aborted = true;
-
- localRequest = connRequest;
- localTrigger = releaseTrigger;
- } finally {
- this.abortLock.unlock();
- }
-
- // Trigger the callbacks outside of the lock, to prevent
- // deadlocks in the scenario where the callbacks have
- // their own locks that may be used while calling
- // setReleaseTrigger or setConnectionRequest.
- if (localRequest != null) {
- localRequest.abortRequest();
- }
- if (localTrigger != null) {
- try {
- localTrigger.abortConnection();
- } catch (IOException ex) {
- // ignore
- }
- }
- }
-
- public boolean isAborted() {
- return this.aborted;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- HttpRequestBase clone = (HttpRequestBase) super.clone();
- clone.abortLock = new ReentrantLock();
- clone.aborted = false;
- clone.releaseTrigger = null;
- clone.connRequest = null;
- clone.headergroup = (HeaderGroup) CloneUtils.clone(this.headergroup);
- clone.params = (HttpParams) CloneUtils.clone(this.params);
- return clone;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpTrace.java b/src/org/apache/http/client/methods/HttpTrace.java
deleted file mode 100644
index 94f18ffd3f7e83ff359536df3ac6eb9ae836b057..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpTrace.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpTrace.java $
- * $Revision: 664505 $
- * $Date: 2008-06-08 06:21:20 -0700 (Sun, 08 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-/**
- * HTTP TRACE method.
- *
- * The HTTP TRACE method is defined in section 9.6 of
- * RFC2616:
- *
- * The TRACE method is used to invoke a remote, application-layer loop-
- * back of the request message. The final recipient of the request
- * SHOULD reflect the message received back to the client as the
- * entity-body of a 200 (OK) response. The final recipient is either the
- * origin server or the first proxy or gateway to receive a Max-Forwards
- * value of zero (0) in the request (see section 14.31). A TRACE request
- * MUST NOT include an entity.
- *
- *
- *
- * @version $Revision: 664505 $
- *
- * @since 4.0
- */
-public class HttpTrace extends HttpRequestBase {
-
- public final static String METHOD_NAME = "TRACE";
-
- public HttpTrace() {
- super();
- }
-
- public HttpTrace(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpTrace(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/src/org/apache/http/client/methods/HttpUriRequest.java b/src/org/apache/http/client/methods/HttpUriRequest.java
deleted file mode 100644
index 56d064ad1e6dcbddad4e4affd21b7f05789ff176..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/HttpUriRequest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/methods/HttpUriRequest.java $
- * $Revision: 659191 $
- * $Date: 2008-05-22 11:26:53 -0700 (Thu, 22 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.HttpRequest;
-
-/**
- * Extended version of the {@link HttpRequest} interface that provides
- * convenience methods to access request properties such as request URI
- * and method type.
- *
- * @author Oleg Kalnichevski
- *
- *
- * @version $Revision: 659191 $
- *
- * @since 4.0
- */
-public interface HttpUriRequest extends HttpRequest {
-
- /**
- * Returns the HTTP method this request uses, such as GET,
- * PUT, POST, or other.
- */
- String getMethod();
-
- /**
- * Returns the URI this request uses, such as
- * http://example.org/path/to/file.
- */
- URI getURI();
-
- /**
- * Aborts execution of the request.
- *
- * @throws UnsupportedOperationException if the abort operation
- * is not supported / cannot be implemented.
- */
- void abort() throws UnsupportedOperationException;
-
- /**
- * Tests if the request execution has been aborted.
- *
- * @return true if the request execution has been aborted,
- * false otherwise.
- */
- boolean isAborted();
-
-}
diff --git a/src/org/apache/http/client/methods/package.html b/src/org/apache/http/client/methods/package.html
deleted file mode 100644
index c2a602a8a72a0538aba3b6dd2cbf0e97d8b5f1e3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/methods/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Request implementations for the various HTTP methods like GET and POST.
-
-
-
diff --git a/src/org/apache/http/client/package.html b/src/org/apache/http/client/package.html
deleted file mode 100644
index 64c7287c2e60dad8f451973165359f550cc10d23..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/package.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-The API for client-side HTTP communication and
-entry point to the HttpClient module.
-
-
-
diff --git a/src/org/apache/http/client/params/AllClientPNames.java b/src/org/apache/http/client/params/AllClientPNames.java
deleted file mode 100644
index e55bca7908f8b0496483e919ccca3c510a8f514d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/AllClientPNames.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/AllClientPNames.java $
- * $Revision: 576078 $
- * $Date: 2007-09-16 04:50:41 -0700 (Sun, 16 Sep 2007) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.cookie.params.CookieSpecPNames;
-import org.apache.http.conn.params.ConnManagerPNames;
-import org.apache.http.conn.params.ConnConnectionPNames;
-import org.apache.http.conn.params.ConnRoutePNames;
-
-
-/**
- * Collected parameter names for the HttpClient module.
- * This interface combines the parameter definitions of the HttpClient
- * module and all dependency modules or informational units.
- * It does not define additional parameter names, but references
- * other interfaces defining parameter names.
- *
- * This interface is meant as a navigation aid for developers.
- * When referring to parameter names, you should use the interfaces
- * in which the respective constants are actually defined.
- *
- * @version $Revision: 576078 $
- *
- * @since 4.0
- */
-public interface AllClientPNames extends
- CoreConnectionPNames, CoreProtocolPNames,
- ClientPNames, AuthPNames, CookieSpecPNames,
- ConnConnectionPNames, ConnManagerPNames, ConnRoutePNames {
-
- // no additional definitions
-}
-
diff --git a/src/org/apache/http/client/params/AuthPolicy.java b/src/org/apache/http/client/params/AuthPolicy.java
deleted file mode 100644
index 5bcdd386144562d2b50d4ab04fe4950cf6359a9e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/AuthPolicy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/AuthPolicy.java $
- * $Revision: 534839 $
- * $Date: 2007-05-03 06:03:41 -0700 (Thu, 03 May 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-public final class AuthPolicy {
-
- private AuthPolicy() {
- super();
- }
-
- /**
- * The NTLM scheme is a proprietary Microsoft Windows Authentication
- * protocol (considered to be the most secure among currently supported
- * authentication schemes).
- */
- public static final String NTLM = "NTLM";
-
- /**
- * Digest authentication scheme as defined in RFC2617.
- */
- public static final String DIGEST = "Digest";
-
- /**
- * Basic authentication scheme as defined in RFC2617 (considered inherently
- * insecure, but most widely supported)
- */
- public static final String BASIC = "Basic";
-
-}
diff --git a/src/org/apache/http/client/params/ClientPNames.java b/src/org/apache/http/client/params/ClientPNames.java
deleted file mode 100644
index f98eeb7c984dbd241042be81cce1de4b317c0eae..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/ClientPNames.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/ClientPNames.java $
- * $Revision: 659595 $
- * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-
-/**
- * Parameter names for the HttpClient module.
- * This does not include parameters for informational units
- * HttpAuth, HttpCookie, or HttpConn.
- *
- * @version $Revision: 659595 $
- *
- * @since 4.0
- */
-public interface ClientPNames {
-
- /**
- * Defines the class name of the default {@link org.apache.http.conn.ClientConnectionManager}
- *
- * This parameter expects a value of type {@link String}.
- *
- */
- public static final String CONNECTION_MANAGER_FACTORY_CLASS_NAME = "http.connection-manager.factory-class-name";
-
- /**
- * Defines the factory to create a default {@link org.apache.http.conn.ClientConnectionManager}.
- *
- * This parameters expects a value of type {@link org.apache.http.conn.ClientConnectionManagerFactory}.
- *
- */
- public static final String CONNECTION_MANAGER_FACTORY = "http.connection-manager.factory-object";
-
- /**
- * Defines whether redirects should be handled automatically
- *
- * This parameter expects a value of type {@link Boolean}.
- *
- */
- public static final String HANDLE_REDIRECTS = "http.protocol.handle-redirects";
-
- /**
- * Defines whether relative redirects should be rejected.
- *
- * This parameter expects a value of type {@link Boolean}.
- *
- */
- public static final String REJECT_RELATIVE_REDIRECT = "http.protocol.reject-relative-redirect";
-
- /**
- * Defines the maximum number of redirects to be followed.
- * The limit on number of redirects is intended to prevent infinite loops.
- *
- * This parameter expects a value of type {@link Integer}.
- *
- */
- public static final String MAX_REDIRECTS = "http.protocol.max-redirects";
-
- /**
- * Defines whether circular redirects (redirects to the same location) should be allowed.
- * The HTTP spec is not sufficiently clear whether circular redirects are permitted,
- * therefore optionally they can be enabled
- *
- * This parameter expects a value of type {@link Boolean}.
- *
- */
- public static final String ALLOW_CIRCULAR_REDIRECTS = "http.protocol.allow-circular-redirects";
-
- /**
- * Defines whether authentication should be handled automatically.
- *
- * This parameter expects a value of type {@link Boolean}.
- *
- */
- public static final String HANDLE_AUTHENTICATION = "http.protocol.handle-authentication";
-
- /**
- * Defines the name of the cookie specification to be used for HTTP state management.
- *
- * This parameter expects a value of type {@link String}.
- *
- */
- public static final String COOKIE_POLICY = "http.protocol.cookie-policy";
-
- /**
- * Defines the virtual host name.
- *
- * This parameter expects a value of type {@link org.apache.http.HttpHost}.
- *
- */
- public static final String VIRTUAL_HOST = "http.virtual-host";
-
- /**
- * Defines the request headers to be sent per default with each request.
- *
- * This parameter expects a value of type {@link java.util.Collection}. The
- * collection is expected to contain {@link org.apache.http.Header}s.
- *
- */
- public static final String DEFAULT_HEADERS = "http.default-headers";
-
- /**
- * Defines the default host. The default value will be used if the target host is
- * not explicitly specified in the request URI.
- *
- * This parameter expects a value of type {@link org.apache.http.HttpHost}.
- *
- */
- public static final String DEFAULT_HOST = "http.default-host";
-
-}
-
diff --git a/src/org/apache/http/client/params/ClientParamBean.java b/src/org/apache/http/client/params/ClientParamBean.java
deleted file mode 100644
index 76431a7af53d2f2116af82f137e2f98049cda38c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/ClientParamBean.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/ClientParamBean.java $
- * $Revision: 659595 $
- * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-import java.util.Collection;
-
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.conn.ClientConnectionManagerFactory;
-import org.apache.http.params.HttpAbstractParamBean;
-import org.apache.http.params.HttpParams;
-
-public class ClientParamBean extends HttpAbstractParamBean {
-
- public ClientParamBean (final HttpParams params) {
- super(params);
- }
-
- public void setConnectionManagerFactoryClassName (final String factory) {
- params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, factory);
- }
-
- public void setConnectionManagerFactory(ClientConnectionManagerFactory factory) {
- params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY, factory);
- }
-
- public void setHandleRedirects (final boolean handle) {
- params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, handle);
- }
-
- public void setRejectRelativeRedirect (final boolean reject) {
- params.setBooleanParameter(ClientPNames.REJECT_RELATIVE_REDIRECT, reject);
- }
-
- public void setMaxRedirects (final int maxRedirects) {
- params.setIntParameter(ClientPNames.MAX_REDIRECTS, maxRedirects);
- }
-
- public void setAllowCircularRedirects (final boolean allow) {
- params.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, allow);
- }
-
- public void setHandleAuthentication (final boolean handle) {
- params.setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, handle);
- }
-
- public void setCookiePolicy (final String policy) {
- params.setParameter(ClientPNames.COOKIE_POLICY, policy);
- }
-
- public void setVirtualHost (final HttpHost host) {
- params.setParameter(ClientPNames.VIRTUAL_HOST, host);
- }
-
- public void setDefaultHeaders (final Collection headers) {
- params.setParameter(ClientPNames.DEFAULT_HEADERS, headers);
- }
-
- public void setDefaultHost (final HttpHost host) {
- params.setParameter(ClientPNames.DEFAULT_HOST, host);
- }
-
-}
diff --git a/src/org/apache/http/client/params/CookiePolicy.java b/src/org/apache/http/client/params/CookiePolicy.java
deleted file mode 100644
index 04a131d8684f31471e82326b3d2bec43544808c6..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/CookiePolicy.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/CookiePolicy.java $
- * $Revision: 613865 $
- * $Date: 2008-01-21 04:04:30 -0800 (Mon, 21 Jan 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-public final class CookiePolicy {
-
- /**
- * The policy that provides high degree of compatibilty
- * with common cookie management of popular HTTP agents.
- */
- public static final String BROWSER_COMPATIBILITY = "compatibility";
-
- /**
- * The Netscape cookie draft compliant policy.
- */
- public static final String NETSCAPE = "netscape";
-
- /**
- * The RFC 2109 compliant policy.
- */
- public static final String RFC_2109 = "rfc2109";
-
- /**
- * The RFC 2965 compliant policy.
- */
- public static final String RFC_2965 = "rfc2965";
-
- /**
- * The default 'best match' policy.
- */
- public static final String BEST_MATCH = "best-match";
-
- private CookiePolicy() {
- super();
- }
-
-}
diff --git a/src/org/apache/http/client/params/HttpClientParams.java b/src/org/apache/http/client/params/HttpClientParams.java
deleted file mode 100644
index c21e2b0de28b2f73e7e8c1ca4e7d443c56d0807b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/HttpClientParams.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/params/HttpClientParams.java $
- * $Revision: 659595 $
- * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-import org.apache.http.params.HttpParams;
-
-/**
- * An adaptor for accessing HTTP client parameters in {@link HttpParams}.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 659595 $
- *
- * @since 4.0
- */
-public class HttpClientParams {
-
- private HttpClientParams() {
- super();
- }
-
- public static boolean isRedirecting(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- return params.getBooleanParameter
- (ClientPNames.HANDLE_REDIRECTS, true);
- }
-
- public static void setRedirecting(final HttpParams params, boolean value) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setBooleanParameter
- (ClientPNames.HANDLE_REDIRECTS, value);
- }
-
- public static boolean isAuthenticating(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- return params.getBooleanParameter
- (ClientPNames.HANDLE_AUTHENTICATION, true);
- }
-
- public static void setAuthenticating(final HttpParams params, boolean value) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setBooleanParameter
- (ClientPNames.HANDLE_AUTHENTICATION, value);
- }
-
- public static String getCookiePolicy(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- String cookiePolicy = (String)
- params.getParameter(ClientPNames.COOKIE_POLICY);
- if (cookiePolicy == null) {
- return CookiePolicy.BEST_MATCH;
- }
- return cookiePolicy;
- }
-
- public static void setCookiePolicy(final HttpParams params, final String cookiePolicy) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setParameter(ClientPNames.COOKIE_POLICY, cookiePolicy);
- }
-
-}
diff --git a/src/org/apache/http/client/params/package.html b/src/org/apache/http/client/params/package.html
deleted file mode 100644
index b66cdfb5a5c453c19c3941ccee56fa351838ade0..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/params/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Parameters for configuring HttpClient.
-
-
-
diff --git a/src/org/apache/http/client/protocol/ClientContext.java b/src/org/apache/http/client/protocol/ClientContext.java
deleted file mode 100644
index 1859f9e0a153b4d00a25be60e91ef6e61502e729..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/ClientContext.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ClientContext.java $
- * $Revision: 658759 $
- * $Date: 2008-05-21 10:06:17 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-
-/**
- * {@link org.apache.http.protocol.HttpContext Context}
- * attribute names for client.
- */
-public interface ClientContext {
-
- public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry";
- public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry";
- public static final String COOKIE_STORE = "http.cookie-store";
- public static final String COOKIE_SPEC = "http.cookie-spec";
- public static final String COOKIE_ORIGIN = "http.cookie-origin";
- public static final String CREDS_PROVIDER = "http.auth.credentials-provider";
- public static final String TARGET_AUTH_STATE = "http.auth.target-scope";
- public static final String PROXY_AUTH_STATE = "http.auth.proxy-scope";
- public static final String AUTH_SCHEME_PREF = "http.auth.scheme-pref";
- public static final String USER_TOKEN = "http.user-token";
-
-}
diff --git a/src/org/apache/http/client/protocol/ClientContextConfigurer.java b/src/org/apache/http/client/protocol/ClientContextConfigurer.java
deleted file mode 100644
index f2ced6356f2c6b4d270c2b37385a01cd4925aaa3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/ClientContextConfigurer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ClientContextConfigurer.java $
- * $Revision: 654886 $
- * $Date: 2008-05-09 10:06:12 -0700 (Fri, 09 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.util.List;
-
-import org.apache.http.auth.AuthSchemeRegistry;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.cookie.CookieSpecRegistry;
-import org.apache.http.protocol.HttpContext;
-
-public class ClientContextConfigurer implements ClientContext {
-
- private final HttpContext context;
-
- public ClientContextConfigurer (final HttpContext context) {
- if (context == null)
- throw new IllegalArgumentException("HTTP context may not be null");
- this.context = context;
- }
-
- public void setCookieSpecRegistry(final CookieSpecRegistry registry) {
- this.context.setAttribute(COOKIESPEC_REGISTRY, registry);
- }
-
- public void setAuthSchemeRegistry(final AuthSchemeRegistry registry) {
- this.context.setAttribute(AUTHSCHEME_REGISTRY, registry);
- }
-
- public void setCookieStore(final CookieStore store) {
- this.context.setAttribute(COOKIE_STORE, store);
- }
-
- public void setCredentialsProvider(final CredentialsProvider provider) {
- this.context.setAttribute(CREDS_PROVIDER, provider);
- }
-
- public void setAuthSchemePref(final List list) {
- this.context.setAttribute(AUTH_SCHEME_PREF, list);
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/RequestAddCookies.java b/src/org/apache/http/client/protocol/RequestAddCookies.java
deleted file mode 100644
index 0de8c4037bb7dc7e88f43fb32822d293a523b7e0..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/RequestAddCookies.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.ProtocolException;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.params.HttpClientParams;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.CookieSpecRegistry;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.ExecutionContext;
-
-/**
- * Request interceptor that matches cookies available in the current
- * {@link CookieStore} to the request being executed and generates
- * corresponding cookierequest headers.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class RequestAddCookies implements HttpRequestInterceptor {
-
- private final Log log = LogFactory.getLog(getClass());
-
- public RequestAddCookies() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- // Obtain cookie store
- CookieStore cookieStore = (CookieStore) context.getAttribute(
- ClientContext.COOKIE_STORE);
- if (cookieStore == null) {
- this.log.info("Cookie store not available in HTTP context");
- return;
- }
-
- // Obtain the registry of cookie specs
- CookieSpecRegistry registry= (CookieSpecRegistry) context.getAttribute(
- ClientContext.COOKIESPEC_REGISTRY);
- if (registry == null) {
- this.log.info("CookieSpec registry not available in HTTP context");
- return;
- }
-
- // Obtain the target host (required)
- HttpHost targetHost = (HttpHost) context.getAttribute(
- ExecutionContext.HTTP_TARGET_HOST);
- if (targetHost == null) {
- throw new IllegalStateException("Target host not specified in HTTP context");
- }
-
- // Obtain the client connection (required)
- ManagedClientConnection conn = (ManagedClientConnection) context.getAttribute(
- ExecutionContext.HTTP_CONNECTION);
- if (conn == null) {
- throw new IllegalStateException("Client connection not specified in HTTP context");
- }
-
- String policy = HttpClientParams.getCookiePolicy(request.getParams());
- if (this.log.isDebugEnabled()) {
- this.log.debug("CookieSpec selected: " + policy);
- }
-
- URI requestURI;
- if (request instanceof HttpUriRequest) {
- requestURI = ((HttpUriRequest) request).getURI();
- } else {
- try {
- requestURI = new URI(request.getRequestLine().getUri());
- } catch (URISyntaxException ex) {
- throw new ProtocolException("Invalid request URI: " +
- request.getRequestLine().getUri(), ex);
- }
- }
-
- String hostName = targetHost.getHostName();
- int port = targetHost.getPort();
- if (port < 0) {
- port = conn.getRemotePort();
- }
-
- CookieOrigin cookieOrigin = new CookieOrigin(
- hostName,
- port,
- requestURI.getPath(),
- conn.isSecure());
-
- // Get an instance of the selected cookie policy
- CookieSpec cookieSpec = registry.getCookieSpec(policy, request.getParams());
- // Get all cookies available in the HTTP state
- List cookies = new ArrayList(cookieStore.getCookies());
- // Find cookies matching the given origin
- List matchedCookies = new ArrayList();
- for (Cookie cookie : cookies) {
- if (cookieSpec.match(cookie, cookieOrigin)) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Cookie " + cookie + " match " + cookieOrigin);
- }
- matchedCookies.add(cookie);
- }
- }
- // Generate Cookie request headers
- if (!matchedCookies.isEmpty()) {
- List headers = cookieSpec.formatCookies(matchedCookies);
- for (Header header : headers) {
- request.addHeader(header);
- }
- }
-
- int ver = cookieSpec.getVersion();
- if (ver > 0) {
- boolean needVersionHeader = false;
- for (Cookie cookie : matchedCookies) {
- if (ver != cookie.getVersion()) {
- needVersionHeader = true;
- }
- }
-
- if (needVersionHeader) {
- Header header = cookieSpec.getVersionHeader();
- if (header != null) {
- // Advertise cookie version support
- request.addHeader(header);
- }
- }
- }
-
- // Stick the CookieSpec and CookieOrigin instances to the HTTP context
- // so they could be obtained by the response interceptor
- context.setAttribute(ClientContext.COOKIE_SPEC, cookieSpec);
- context.setAttribute(ClientContext.COOKIE_ORIGIN, cookieOrigin);
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/RequestDefaultHeaders.java b/src/org/apache/http/client/protocol/RequestDefaultHeaders.java
deleted file mode 100644
index 27d5cc7695cdd435158a0ed171b8604bf54a59cb..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/RequestDefaultHeaders.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Request interceptor that adds default request headers.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 653041 $
- *
- * @since 4.0
- */
-public class RequestDefaultHeaders implements HttpRequestInterceptor {
-
- public RequestDefaultHeaders() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- // Add default headers
- Collection> defHeaders = (Collection>) request.getParams().getParameter(
- ClientPNames.DEFAULT_HEADERS);
- if (defHeaders != null) {
- for (Object defHeader : defHeaders) {
- request.addHeader((Header) defHeader);
- }
- }
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/RequestProxyAuthentication.java b/src/org/apache/http/client/protocol/RequestProxyAuthentication.java
deleted file mode 100644
index b4dfe763362c259a2eed75ce11f9f337a72de719..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/RequestProxyAuthentication.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class RequestProxyAuthentication implements HttpRequestInterceptor {
-
- private final Log log = LogFactory.getLog(getClass());
-
- public RequestProxyAuthentication() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
- return;
- }
-
- // Obtain authentication state
- AuthState authState = (AuthState) context.getAttribute(
- ClientContext.PROXY_AUTH_STATE);
- if (authState == null) {
- return;
- }
-
- AuthScheme authScheme = authState.getAuthScheme();
- if (authScheme == null) {
- return;
- }
-
- Credentials creds = authState.getCredentials();
- if (creds == null) {
- this.log.debug("User credentials not available");
- return;
- }
- if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
- try {
- request.addHeader(authScheme.authenticate(creds, request));
- } catch (AuthenticationException ex) {
- if (this.log.isErrorEnabled()) {
- this.log.error("Proxy authentication error: " + ex.getMessage());
- }
- }
- }
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/RequestTargetAuthentication.java b/src/org/apache/http/client/protocol/RequestTargetAuthentication.java
deleted file mode 100644
index c14018325ef478214dfc7e9a59eda7f2e9221711..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/RequestTargetAuthentication.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class RequestTargetAuthentication implements HttpRequestInterceptor {
-
- private final Log log = LogFactory.getLog(getClass());
-
- public RequestTargetAuthentication() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- if (request.containsHeader(AUTH.WWW_AUTH_RESP)) {
- return;
- }
-
- // Obtain authentication state
- AuthState authState = (AuthState) context.getAttribute(
- ClientContext.TARGET_AUTH_STATE);
- if (authState == null) {
- return;
- }
-
- AuthScheme authScheme = authState.getAuthScheme();
- if (authScheme == null) {
- return;
- }
-
- Credentials creds = authState.getCredentials();
- if (creds == null) {
- this.log.debug("User credentials not available");
- return;
- }
-
- if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
- try {
- request.addHeader(authScheme.authenticate(creds, request));
- } catch (AuthenticationException ex) {
- if (this.log.isErrorEnabled()) {
- this.log.error("Authentication error: " + ex.getMessage());
- }
- }
- }
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/ResponseProcessCookies.java b/src/org/apache/http/client/protocol/ResponseProcessCookies.java
deleted file mode 100644
index 0689e9342cd93fc066157d13322bc96572520a16..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/ResponseProcessCookies.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SM;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Response interceptor that populates the current {@link CookieStore} with data
- * contained in response cookies received in the given the HTTP response.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class ResponseProcessCookies implements HttpResponseInterceptor {
-
- private final Log log = LogFactory.getLog(getClass());
-
- public ResponseProcessCookies() {
- super();
- }
-
- public void process(final HttpResponse response, final HttpContext context)
- throws HttpException, IOException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- // Obtain cookie store
- CookieStore cookieStore = (CookieStore) context.getAttribute(
- ClientContext.COOKIE_STORE);
- if (cookieStore == null) {
- this.log.info("Cookie store not available in HTTP context");
- return;
- }
- // Obtain actual CookieSpec instance
- CookieSpec cookieSpec = (CookieSpec) context.getAttribute(
- ClientContext.COOKIE_SPEC);
- if (cookieSpec == null) {
- this.log.info("CookieSpec not available in HTTP context");
- return;
- }
- // Obtain actual CookieOrigin instance
- CookieOrigin cookieOrigin = (CookieOrigin) context.getAttribute(
- ClientContext.COOKIE_ORIGIN);
- if (cookieOrigin == null) {
- this.log.info("CookieOrigin not available in HTTP context");
- return;
- }
- HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
- processCookies(it, cookieSpec, cookieOrigin, cookieStore);
-
- // see if the cookie spec supports cookie versioning.
- if (cookieSpec.getVersion() > 0) {
- // process set-cookie2 headers.
- // Cookie2 will replace equivalent Cookie instances
- it = response.headerIterator(SM.SET_COOKIE2);
- processCookies(it, cookieSpec, cookieOrigin, cookieStore);
- }
- }
-
- private void processCookies(
- final HeaderIterator iterator,
- final CookieSpec cookieSpec,
- final CookieOrigin cookieOrigin,
- final CookieStore cookieStore) {
- while (iterator.hasNext()) {
- Header header = iterator.nextHeader();
- try {
- List cookies = cookieSpec.parse(header, cookieOrigin);
- for (Cookie cookie : cookies) {
- try {
- cookieSpec.validate(cookie, cookieOrigin);
- cookieStore.addCookie(cookie);
-
- if (this.log.isDebugEnabled()) {
- this.log.debug("Cookie accepted: \""
- + cookie + "\". ");
- }
- } catch (MalformedCookieException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Cookie rejected: \""
- + cookie + "\". " + ex.getMessage());
- }
- }
- }
- } catch (MalformedCookieException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Invalid cookie header: \""
- + header + "\". " + ex.getMessage());
- }
- }
- }
- }
-
-}
diff --git a/src/org/apache/http/client/protocol/package.html b/src/org/apache/http/client/protocol/package.html
deleted file mode 100644
index 43dd0d611fd345acfbb7589cfb53ae1cbbecf532..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/protocol/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Additional request and response interceptors.
-
-
-
diff --git a/src/org/apache/http/client/utils/CloneUtils.java b/src/org/apache/http/client/utils/CloneUtils.java
deleted file mode 100644
index fec534bc593ff509d83b5f69f68343ff6e763e08..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/utils/CloneUtils.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.utils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * A collection of utilities to workaround limitations of Java clone framework.
- */
-public class CloneUtils {
-
- public static Object clone(final Object obj) throws CloneNotSupportedException {
- if (obj == null) {
- return null;
- }
- if (obj instanceof Cloneable) {
- Class> clazz = obj.getClass ();
- Method m;
- try {
- m = clazz.getMethod("clone", (Class[]) null);
- } catch (NoSuchMethodException ex) {
- throw new NoSuchMethodError(ex.getMessage());
- }
- try {
- return m.invoke(obj, (Object []) null);
- } catch (InvocationTargetException ex) {
- Throwable cause = ex.getCause();
- if (cause instanceof CloneNotSupportedException) {
- throw ((CloneNotSupportedException) cause);
- } else {
- throw new Error("Unexpected exception", cause);
- }
- } catch (IllegalAccessException ex) {
- throw new IllegalAccessError(ex.getMessage());
- }
- } else {
- throw new CloneNotSupportedException();
- }
- }
-
- /**
- * This class should not be instantiated.
- */
- private CloneUtils() {
- }
-
-}
diff --git a/src/org/apache/http/client/utils/URIUtils.java b/src/org/apache/http/client/utils/URIUtils.java
deleted file mode 100644
index 1cbb9af0083448a1f6209abfc3f5e80daa12991f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/utils/URIUtils.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.utils;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.HttpHost;
-
-/**
- * A collection of utilities for {@link URI URIs}, to workaround
- * bugs within the class or for ease-of-use features.
- */
-public class URIUtils {
-
- /**
- * Constructs a {@link URI} using all the parameters. This should be
- * used instead of
- * {@link URI#URI(String, String, String, int, String, String, String)}
- * or any of the other URI multi-argument URI constructors.
- *
- * See HTTPCLIENT-730
- * for more information.
- *
- * @param scheme
- * Scheme name
- * @param host
- * Host name
- * @param port
- * Port number
- * @param path
- * Path
- * @param query
- * Query
- * @param fragment
- * Fragment
- *
- * @throws URISyntaxException
- * If both a scheme and a path are given but the path is
- * relative, if the URI string constructed from the given
- * components violates RFC 2396, or if the authority
- * component of the string is present but cannot be parsed
- * as a server-based authority
- */
- public static URI createURI(
- final String scheme,
- final String host,
- int port,
- final String path,
- final String query,
- final String fragment) throws URISyntaxException {
-
- StringBuilder buffer = new StringBuilder();
- if (host != null) {
- if (scheme != null) {
- buffer.append(scheme);
- buffer.append("://");
- }
- buffer.append(host);
- if (port > 0) {
- buffer.append(':');
- buffer.append(port);
- }
- }
- if (path == null || !path.startsWith("/")) {
- buffer.append('/');
- }
- if (path != null) {
- buffer.append(path);
- }
- if (query != null) {
- buffer.append('?');
- buffer.append(query);
- }
- if (fragment != null) {
- buffer.append('#');
- buffer.append(fragment);
- }
- return new URI(buffer.toString());
- }
-
- /**
- * A convenience method for creating a new {@link URI} whose scheme, host
- * and port are taken from the target host, but whose path, query and
- * fragment are taken from the existing URI. The fragment is only used if
- * dropFragment is false.
- *
- * @param uri
- * Contains the path, query and fragment to use.
- * @param target
- * Contains the scheme, host and port to use.
- * @param dropFragment
- * True if the fragment should not be copied.
- *
- * @throws URISyntaxException
- * If the resulting URI is invalid.
- */
- public static URI rewriteURI(
- final URI uri,
- final HttpHost target,
- boolean dropFragment) throws URISyntaxException {
- if (uri == null) {
- throw new IllegalArgumentException("URI may nor be null");
- }
- if (target != null) {
- return URIUtils.createURI(
- target.getSchemeName(),
- target.getHostName(),
- target.getPort(),
- uri.getRawPath(),
- uri.getRawQuery(),
- dropFragment ? null : uri.getRawFragment());
- } else {
- return URIUtils.createURI(
- null,
- null,
- -1,
- uri.getRawPath(),
- uri.getRawQuery(),
- dropFragment ? null : uri.getRawFragment());
- }
- }
-
- /**
- * A convenience method for
- * {@link URIUtils#rewriteURI(URI, HttpHost, boolean)} that always keeps the
- * fragment.
- */
- public static URI rewriteURI(
- final URI uri,
- final HttpHost target) throws URISyntaxException {
- return rewriteURI(uri, target, false);
- }
-
- /**
- * Resolves a URI reference against a base URI. Work-around for bug in
- * java.net.URI ()
- *
- * @param baseURI the base URI
- * @param reference the URI reference
- * @return the resulting URI
- */
- public static URI resolve(final URI baseURI, final String reference) {
- return URIUtils.resolve(baseURI, URI.create(reference));
- }
-
- /**
- * Resolves a URI reference against a base URI. Work-around for bug in
- * java.net.URI ()
- *
- * @param baseURI the base URI
- * @param reference the URI reference
- * @return the resulting URI
- */
- public static URI resolve(final URI baseURI, URI reference){
- if (baseURI == null) {
- throw new IllegalArgumentException("Base URI may nor be null");
- }
- if (reference == null) {
- throw new IllegalArgumentException("Reference URI may nor be null");
- }
- boolean emptyReference = reference.toString().length() == 0;
- if (emptyReference) {
- reference = URI.create("#");
- }
- URI resolved = baseURI.resolve(reference);
- if (emptyReference) {
- String resolvedString = resolved.toString();
- resolved = URI.create(resolvedString.substring(0,
- resolvedString.indexOf('#')));
- }
- return resolved;
- }
-
- /**
- * This class should not be instantiated.
- */
- private URIUtils() {
- }
-
-}
diff --git a/src/org/apache/http/client/utils/URLEncodedUtils.java b/src/org/apache/http/client/utils/URLEncodedUtils.java
deleted file mode 100644
index 8b08f9061bbb811077ae3e250c3c5840e9f68b63..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/utils/URLEncodedUtils.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java $
- * $Revision: 655107 $
- * $Date: 2008-05-10 08:20:42 -0700 (Sat, 10 May 2008) $
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.utils;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Scanner;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-
-/**
- * A collection of utilities for encoding URLs.
- */
-public class URLEncodedUtils {
-
- public static final String CONTENT_TYPE = "application/x-www-form-urlencoded";
- private static final String PARAMETER_SEPARATOR = "&";
- private static final String NAME_VALUE_SEPARATOR = "=";
-
- /**
- * Returns a list of {@link NameValuePair NameValuePairs} as built from the
- * URI's query portion. For example, a URI of
- * http://example.org/path/to/file?a=1&b=2&c=3 would return a list of three
- * NameValuePairs, one for a=1, one for b=2, and one for c=3.
- *
- * This is typically useful while parsing an HTTP PUT.
- *
- * @param uri
- * uri to parse
- * @param encoding
- * encoding to use while parsing the query
- */
- public static List parse (final URI uri, final String encoding) {
- List result = Collections.emptyList();
- final String query = uri.getRawQuery();
- if (query != null && query.length() > 0) {
- result = new ArrayList ();
- parse(result, new Scanner(query), encoding);
- }
- return result;
- }
-
- /**
- * Returns a list of {@link NameValuePair NameValuePairs} as parsed from an
- * {@link HttpEntity}. The encoding is taken from the entity's
- * Content-Encoding header.
- *
- * This is typically used while parsing an HTTP POST.
- *
- * @param entity
- * The entity to parse
- * @throws IOException
- * If there was an exception getting the entity's data.
- */
- public static List parse (
- final HttpEntity entity) throws IOException {
- List result = Collections.emptyList();
- if (isEncoded(entity)) {
- final String content = EntityUtils.toString(entity);
- final Header encoding = entity.getContentEncoding();
- if (content != null && content.length() > 0) {
- result = new ArrayList ();
- parse(result, new Scanner(content),
- encoding != null ? encoding.getValue() : null);
- }
- }
- return result;
- }
-
- /**
- * Returns true if the entity's Content-Type header is
- * application/x-www-form-urlencoded.
- */
- public static boolean isEncoded (final HttpEntity entity) {
- final Header contentType = entity.getContentType();
- return (contentType != null && contentType.getValue().equalsIgnoreCase(CONTENT_TYPE));
- }
-
- /**
- * Adds all parameters within the Scanner to the list of
- * parameters, as encoded by encoding. For
- * example, a scanner containing the string a=1&b=2&c=3 would
- * add the {@link NameValuePair NameValuePairs} a=1, b=2, and c=3 to the
- * list of parameters.
- *
- * @param parameters
- * List to add parameters to.
- * @param scanner
- * Input that contains the parameters to parse.
- * @param encoding
- * Encoding to use when decoding the parameters.
- */
- public static void parse (
- final List parameters,
- final Scanner scanner,
- final String encoding) {
- scanner.useDelimiter(PARAMETER_SEPARATOR);
- while (scanner.hasNext()) {
- final String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR);
- if (nameValue.length == 0 || nameValue.length > 2)
- throw new IllegalArgumentException("bad parameter");
-
- final String name = decode(nameValue[0], encoding);
- String value = null;
- if (nameValue.length == 2)
- value = decode(nameValue[1], encoding);
- parameters.add(new BasicNameValuePair(name, value));
- }
- }
-
- /**
- * Returns a String that is suitable for use as an application/x-www-form-urlencoded
- * list of parameters in an HTTP PUT or HTTP POST.
- *
- * @param parameters The parameters to include.
- * @param encoding The encoding to use.
- */
- public static String format (
- final List extends NameValuePair> parameters,
- final String encoding) {
- final StringBuilder result = new StringBuilder();
- for (final NameValuePair parameter : parameters) {
- final String encodedName = encode(parameter.getName(), encoding);
- final String value = parameter.getValue();
- final String encodedValue = value != null ? encode(value, encoding) : "";
- if (result.length() > 0)
- result.append(PARAMETER_SEPARATOR);
- result.append(encodedName);
- result.append(NAME_VALUE_SEPARATOR);
- result.append(encodedValue);
- }
- return result.toString();
- }
-
- private static String decode (final String content, final String encoding) {
- try {
- return URLDecoder.decode(content,
- encoding != null ? encoding : HTTP.DEFAULT_CONTENT_CHARSET);
- } catch (UnsupportedEncodingException problem) {
- throw new IllegalArgumentException(problem);
- }
- }
-
- private static String encode (final String content, final String encoding) {
- try {
- return URLEncoder.encode(content,
- encoding != null ? encoding : HTTP.DEFAULT_CONTENT_CHARSET);
- } catch (UnsupportedEncodingException problem) {
- throw new IllegalArgumentException(problem);
- }
- }
-
-}
diff --git a/src/org/apache/http/client/utils/package.html b/src/org/apache/http/client/utils/package.html
deleted file mode 100644
index 7abeb9379810338636a3c0a9ce64cdc030f73846..0000000000000000000000000000000000000000
--- a/src/org/apache/http/client/utils/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Helpers and utility classes for HttpClient.
-
-
-
diff --git a/src/org/apache/http/conn/BasicEofSensorWatcher.java b/src/org/apache/http/conn/BasicEofSensorWatcher.java
deleted file mode 100644
index 9a9f3c5fe70c9f47d7afdc16c52e58880318ef6c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/BasicEofSensorWatcher.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/BasicEofSensorWatcher.java $
- * $Revision $
- * $Date: 2008-06-27 12:49:20 -0700 (Fri, 27 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-
-/**
- * Basic implementation of {@link EofSensorWatcher EofSensorWatcher}.
- * The underlying connection is released on close or EOF.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 672367 $
- *
- * @since 4.0
- */
-public class BasicEofSensorWatcher implements EofSensorWatcher {
-
-
- /** The connection to auto-release. */
- protected ManagedClientConnection managedConn;
-
- /** Whether to keep the connection alive. */
- protected boolean attemptReuse;
-
-
-
- /**
- * Creates a new watcher for auto-releasing a connection.
- *
- * @param conn the connection to auto-release
- * @param reuse whether the connection should be re-used
- */
- public BasicEofSensorWatcher(ManagedClientConnection conn,
- boolean reuse) {
- if (conn == null)
- throw new IllegalArgumentException
- ("Connection may not be null.");
-
- managedConn = conn;
- attemptReuse = reuse;
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean eofDetected(InputStream wrapped)
- throws IOException {
-
- try {
- if (attemptReuse) {
- // there may be some cleanup required, such as
- // reading trailers after the response body:
- wrapped.close();
- managedConn.markReusable();
- }
- } finally {
- managedConn.releaseConnection();
- }
- return false;
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean streamClosed(InputStream wrapped)
- throws IOException {
-
- try {
- if (attemptReuse) {
- // this assumes that closing the stream will
- // consume the remainder of the response body:
- wrapped.close();
- managedConn.markReusable();
- }
- } finally {
- managedConn.releaseConnection();
- }
- return false;
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean streamAbort(InputStream wrapped)
- throws IOException {
-
- managedConn.abortConnection();
- return false;
- }
-
-} // class BasicEofSensorWatcher
diff --git a/src/org/apache/http/conn/BasicManagedEntity.java b/src/org/apache/http/conn/BasicManagedEntity.java
deleted file mode 100644
index 9719e1ae2dcc58fa0ce8c2f3a2aadb72fe5fdf6c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/BasicManagedEntity.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/BasicManagedEntity.java $
- * $Revision $
- * $Date: 2008-06-27 12:49:20 -0700 (Fri, 27 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapper;
-
-
-/**
- * An entity that releases a {@link ManagedClientConnection connection}.
- * A {@link ManagedClientConnection} will
- * typically not return a managed entity, but you can replace
- * the unmanaged entity in the response with a managed one.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 672367 $
- *
- * @since 4.0
- */
-public class BasicManagedEntity extends HttpEntityWrapper
- implements ConnectionReleaseTrigger, EofSensorWatcher {
-
- /** The connection to release. */
- protected ManagedClientConnection managedConn;
-
- /** Whether to keep the connection alive. */
- protected final boolean attemptReuse;
-
-
- /**
- * Creates a new managed entity that can release a connection.
- *
- * @param entity the entity of which to wrap the content.
- * Note that the argument entity can no longer be used
- * afterwards, since the content will be taken by this
- * managed entity.
- * @param conn the connection to release
- * @param reuse whether the connection should be re-used
- */
- public BasicManagedEntity(HttpEntity entity,
- ManagedClientConnection conn,
- boolean reuse) {
- super(entity);
-
- if (conn == null)
- throw new IllegalArgumentException
- ("Connection may not be null.");
-
- this.managedConn = conn;
- this.attemptReuse = reuse;
- }
-
-
- // non-javadoc, see interface HttpEntity
- @Override
- public boolean isRepeatable() {
- return false;
- }
-
-
- // non-javadoc, see interface HttpEntity
- @Override
- public InputStream getContent() throws IOException {
-
- return new EofSensorInputStream(wrappedEntity.getContent(), this);
- }
-
-
- // non-javadoc, see interface HttpEntity
- @Override
- public void consumeContent() throws IOException {
-
- if (managedConn == null)
- return;
-
- try {
- if (attemptReuse) {
- // this will not trigger a callback from EofSensorInputStream
- wrappedEntity.consumeContent();
- managedConn.markReusable();
- }
- } finally {
- releaseManagedConnection();
- }
- }
-
-
- // non-javadoc, see interface HttpEntity
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- super.writeTo(outstream);
- consumeContent();
- }
-
-
- // non-javadoc, see interface ConnectionReleaseTrigger
- public void releaseConnection()
- throws IOException {
-
- this.consumeContent();
- }
-
-
- // non-javadoc, see interface ConnectionReleaseTrigger
- public void abortConnection()
- throws IOException {
-
- if (managedConn != null) {
- try {
- managedConn.abortConnection();
- } finally {
- managedConn = null;
- }
- }
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean eofDetected(InputStream wrapped)
- throws IOException {
-
- try {
- if (attemptReuse && (managedConn != null)) {
- // there may be some cleanup required, such as
- // reading trailers after the response body:
- wrapped.close();
- managedConn.markReusable();
- }
- } finally {
- releaseManagedConnection();
- }
- return false;
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean streamClosed(InputStream wrapped)
- throws IOException {
-
- try {
- if (attemptReuse && (managedConn != null)) {
- // this assumes that closing the stream will
- // consume the remainder of the response body:
- wrapped.close();
- managedConn.markReusable();
- }
- } finally {
- releaseManagedConnection();
- }
- return false;
- }
-
-
- // non-javadoc, see interface EofSensorWatcher
- public boolean streamAbort(InputStream wrapped)
- throws IOException {
-
- if (managedConn != null) {
- managedConn.abortConnection();
- }
- return false;
- }
-
-
- /**
- * Releases the connection gracefully.
- * The connection attribute will be nullified.
- * Subsequent invocations are no-ops.
- *
- * @throws IOException in case of an IO problem.
- * The connection attribute will be nullified anyway.
- */
- protected void releaseManagedConnection()
- throws IOException {
-
- if (managedConn != null) {
- try {
- managedConn.releaseConnection();
- } finally {
- managedConn = null;
- }
- }
- }
-
-} // class BasicManagedEntity
diff --git a/src/org/apache/http/conn/ClientConnectionManager.java b/src/org/apache/http/conn/ClientConnectionManager.java
deleted file mode 100644
index e3375e115f18119b54b69db4b5e9950a3e36cefe..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ClientConnectionManager.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManager.java $
- * $Revision: 671717 $
- * $Date: 2008-06-25 21:03:24 -0700 (Wed, 25 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.scheme.SchemeRegistry;
-
-/**
- * Management interface for {@link ManagedClientConnection client connections}.
- *
- * @author Michael Becke
- * @author Mike Bowler
- * @author Oleg Kalnichevski
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 671717 $
- *
- * @since 4.0
- */
-public interface ClientConnectionManager {
-
- /**
- * Obtains the scheme registry used by this manager.
- *
- * @return the scheme registry, never null
- */
- SchemeRegistry getSchemeRegistry()
- ;
-
-
- /**
- * Returns a new {@link ClientConnectionRequest}, from which a
- * {@link ManagedClientConnection} can be obtained or the request can be
- * aborted.
- */
- ClientConnectionRequest requestConnection(HttpRoute route, Object state)
- ;
-
-
- /**
- * Releases a connection for use by others.
- * You may optionally specify how long the connection is valid
- * to be reused. Values <= 0 are considered to be valid forever.
- * If the connection is not marked as reusable, the connection will
- * not be reused regardless of the valid duration.
- *
- * If the connection has been released before,
- * the call will be ignored.
- *
- * @param conn the connection to release
- * @param validDuration the duration of time this connection is valid for reuse
- * @param timeUnit the unit of time validDuration is measured in
- *
- * @see #closeExpiredConnections()
- */
- void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit)
- ;
-
-
- /**
- * Closes idle connections in the pool.
- * Open connections in the pool that have not been used for the
- * timespan given by the argument will be closed.
- * Currently allocated connections are not subject to this method.
- * Times will be checked with milliseconds precision
- *
- * All expired connections will also be closed.
- *
- * @param idletime the idle time of connections to be closed
- * @param tunit the unit for the idletime
- *
- * @see #closeExpiredConnections()
- */
- void closeIdleConnections(long idletime, TimeUnit tunit)
- ;
-
- /**
- * Closes all expired connections in the pool.
- * Open connections in the pool that have not been used for
- * the timespan defined when the connection was released will be closed.
- * Currently allocated connections are not subject to this method.
- * Times will be checked with milliseconds precision.
- */
- void closeExpiredConnections();
-
- /**
- * Shuts down this connection manager and releases allocated resources.
- * This includes closing all connections, whether they are currently
- * used or not.
- */
- void shutdown()
- ;
-
-
-} // interface ClientConnectionManager
diff --git a/src/org/apache/http/conn/ClientConnectionManagerFactory.java b/src/org/apache/http/conn/ClientConnectionManagerFactory.java
deleted file mode 100644
index 4bedc4ee90951a7c6dfe1c66b263518ff9426a28..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ClientConnectionManagerFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionManagerFactory.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.params.HttpParams;
-
-/**
- * A factory for creating new {@link ClientConnectionManager} instances.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface ClientConnectionManagerFactory {
-
- ClientConnectionManager newInstance(
- HttpParams params,
- SchemeRegistry schemeRegistry);
-
-}
diff --git a/src/org/apache/http/conn/ClientConnectionOperator.java b/src/org/apache/http/conn/ClientConnectionOperator.java
deleted file mode 100644
index 980b8677519a287813efb056e93b567946f6bb57..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ClientConnectionOperator.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionOperator.java $
- * $Revision: 645850 $
- * $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-import org.apache.http.conn.scheme.SocketFactory;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-
-
-/**
- * Interface for opening {@link OperatedClientConnection connections}.
- * This interface encapsulates the logic to create sockets and to
- * open or update the connection with the new socket.
- * Implementations will most likely make use of
- * {@link SocketFactory socket factories}.
- *
- * The methods in this interface allow the creation of plain and layered
- * sockets. Creating a tunnelled connection through a proxy, however,
- * is not within the scope of the operator.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 645850 $ $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
- *
- * @since 4.0
- */
-public interface ClientConnectionOperator {
-
-
- /**
- * Creates a new connection that can be operated.
- *
- * @return a new, unopened connection for use with this operator
- */
- OperatedClientConnection createConnection()
- ;
-
-
- /**
- * Opens a connection to the given target host.
- *
- * @param conn the connection to open
- * @param target the target host to connect to
- * @param local the local address to route from, or
- * null for the default
- * @param context the context for the connection
- * @param params the parameters for the connection
- *
- * @throws IOException in case of a problem
- */
- void openConnection(OperatedClientConnection conn,
- HttpHost target,
- InetAddress local,
- HttpContext context,
- HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Updates a connection with a layered secure connection.
- * The typical use of this method is to update a tunnelled plain
- * connection (HTTP) to a secure TLS/SSL connection (HTTPS).
- *
- * @param conn the open connection to update
- * @param target the target host for the updated connection.
- * The connection must already be open or tunnelled
- * to the host and port, but the scheme of the target
- * will be used to create a layered connection.
- * @param context the context for the connection
- * @param params the parameters for the updated connection
- *
- * @throws IOException in case of a problem
- */
- void updateSecureConnection(OperatedClientConnection conn,
- HttpHost target,
- HttpContext context,
- HttpParams params)
- throws IOException
- ;
-
-
-} // interface ClientConnectionOperator
-
diff --git a/src/org/apache/http/conn/ClientConnectionRequest.java b/src/org/apache/http/conn/ClientConnectionRequest.java
deleted file mode 100644
index 6ba02d0547b9c76dbee879886b698159e5b8f719..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ClientConnectionRequest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ClientConnectionRequest.java $
- * $Revision: 651815 $
- * $Date: 2008-04-26 04:14:43 -0700 (Sat, 26 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Encapsulates a request for a {@link ManagedClientConnection}.
- */
-public interface ClientConnectionRequest {
-
- /**
- * Obtains a connection within a given time.
- * This method will block until a connection becomes available,
- * the timeout expires, or the connection manager is
- * {@link ClientConnectionManager#shutdown() shut down}.
- * Timeouts are handled with millisecond precision.
- *
- * If {@link #abortRequest()} is called while this is blocking or
- * before this began, an {@link InterruptedException} will
- * be thrown.
- *
- * @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the timeout,
- * may be null only if there is no timeout
- *
- * @return a connection that can be used to communicate
- * along the given route
- *
- * @throws ConnectionPoolTimeoutException
- * in case of a timeout
- * @throws InterruptedException
- * if the calling thread is interrupted while waiting
- */
- ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
- throws InterruptedException, ConnectionPoolTimeoutException;
-
- /**
- * Aborts the call to {@link #getConnection(long, TimeUnit)},
- * causing it to throw an {@link InterruptedException}.
- */
- void abortRequest();
-
-}
diff --git a/src/org/apache/http/conn/ConnectTimeoutException.java b/src/org/apache/http/conn/ConnectTimeoutException.java
deleted file mode 100644
index 83a731a0e2379cd87e3215444bd2f38ef04c7975..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ConnectTimeoutException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ConnectTimeoutException.java $
- * $Revision: 617645 $
- * $Date: 2008-02-01 13:05:31 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.InterruptedIOException;
-
-/**
- * A timeout while connecting to an HTTP server or waiting for an
- * available connection from an HttpConnectionManager.
- *
- * @author Laura Werner
- *
- * @since 4.0
- */
-public class ConnectTimeoutException extends InterruptedIOException {
-
- private static final long serialVersionUID = -4816682903149535989L;
-
- /**
- * Creates a ConnectTimeoutException with a null detail message.
- */
- public ConnectTimeoutException() {
- super();
- }
-
- /**
- * Creates a ConnectTimeoutException with the specified detail message.
- *
- * @param message The exception detail message
- */
- public ConnectTimeoutException(final String message) {
- super(message);
- }
-
-}
diff --git a/src/org/apache/http/conn/ConnectionKeepAliveStrategy.java b/src/org/apache/http/conn/ConnectionKeepAliveStrategy.java
deleted file mode 100644
index 27d56cb600814e871c311f76900f0b3a91af4e4b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ConnectionKeepAliveStrategy.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Interface for deciding how long a connection can remain
- * idle before being reused.
- *
- * @author Sam Berlin
- *
- *
- * @version $Revision: $
- *
- * @since 4.0
- */
-public interface ConnectionKeepAliveStrategy {
-
- /**
- * Returns the duration of time which this connection can be safely kept
- * idle. If the connection is left idle for longer than this period of time,
- * it MUST not reused. A value of 0 or less may be returned to indicate that
- * there is no suitable suggestion.
- *
- * When coupled with a {@link ConnectionReuseStrategy}, if
- * {@link ConnectionReuseStrategy#keepAlive(HttpResponse, HttpContext)
- * returns true, this allows you to control how long the reuse will last. If
- * keepAlive returns false, this should have no meaningful impact
- *
- * @param response
- * The last response received over the connection.
- * @param context
- * the context in which the connection is being used.
- *
- * @return the duration in ms for which it is safe to keep the connection
- * idle, or <=0 if no suggested duration.
- */
- long getKeepAliveDuration(HttpResponse response, HttpContext context);
-
-}
diff --git a/src/org/apache/http/conn/ConnectionPoolTimeoutException.java b/src/org/apache/http/conn/ConnectionPoolTimeoutException.java
deleted file mode 100644
index 7d4985e6bf70803859c22da1b98fbacd6bd56ad8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ConnectionPoolTimeoutException.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ConnectionPoolTimeoutException.java $
- * $Revision: 505684 $
- * $Date: 2007-02-10 04:40:02 -0800 (Sat, 10 Feb 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-/**
- * A timeout while waiting for an available connection
- * from a connection manager.
- *
- * @author Laura Werner
- *
- * @since 4.0
- */
-public class ConnectionPoolTimeoutException extends ConnectTimeoutException {
-
- private static final long serialVersionUID = -7898874842020245128L;
-
- /**
- * Creates a ConnectTimeoutException with a null detail message.
- */
- public ConnectionPoolTimeoutException() {
- super();
- }
-
- /**
- * Creates a ConnectTimeoutException with the specified detail message.
- *
- * @param message The exception detail message
- */
- public ConnectionPoolTimeoutException(String message) {
- super(message);
- }
-
-}
diff --git a/src/org/apache/http/conn/ConnectionReleaseTrigger.java b/src/org/apache/http/conn/ConnectionReleaseTrigger.java
deleted file mode 100644
index a9ac12e337f9dc3f8f75d5f6bd4a20c4d2b9d604..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ConnectionReleaseTrigger.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ConnectionReleaseTrigger.java $
- * $Revision: 672367 $
- * $Date: 2008-06-27 12:49:20 -0700 (Fri, 27 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-
-
-/**
- * Interface for releasing a connection.
- * This can be implemented by various "trigger" objects which are
- * associated with a connection, for example
- * a {@link EofSensorInputStream stream}
- * or an {@link BasicManagedEntity entity}
- * or the {@link ManagedClientConnection connection} itself.
- *
- * The methods in this interface can safely be called multiple times.
- * The first invocation releases the connection, subsequent calls
- * are ignored.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 672367 $
- *
- * @since 4.0
- */
-public interface ConnectionReleaseTrigger {
-
- /**
- * Releases the connection with the option of keep-alive. This is a
- * "graceful" release and may cause IO operations for consuming the
- * remainder of a response entity. Use
- * {@link #abortConnection abortConnection} for a hard release. The
- * connection may be reused as specified by the duration.
- *
- * @throws IOException
- * in case of an IO problem. The connection will be released
- * anyway.
- */
- void releaseConnection()
- throws IOException
- ;
-
- /**
- * Releases the connection without the option of keep-alive.
- * This is a "hard" release that implies a shutdown of the connection.
- * Use {@link #releaseConnection releaseConnection} for a graceful release.
- *
- * @throws IOException in case of an IO problem.
- * The connection will be released anyway.
- */
- void abortConnection()
- throws IOException
- ;
-
-
-} // interface ConnectionReleaseTrigger
diff --git a/src/org/apache/http/conn/EofSensorInputStream.java b/src/org/apache/http/conn/EofSensorInputStream.java
deleted file mode 100644
index 0e1b90e618f55c3c4b1e98ae87e1c28da27584ad..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/EofSensorInputStream.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorInputStream.java $
- * $Revision: 672367 $
- * $Date: 2008-06-27 12:49:20 -0700 (Fri, 27 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-
-/**
- * A stream wrapper that triggers actions on {@link #close close()} and EOF.
- * Primarily used to auto-release an underlying
- * {@link ManagedClientConnection connection}
- * when the response body is consumed or no longer needed.
- *
- *
- * This class is based on AutoCloseInputStream in HttpClient 3.1,
- * but has notable differences. It does not allow mark/reset, distinguishes
- * different kinds of event, and does not always close the underlying stream
- * on EOF. That decision is left to the {@link EofSensorWatcher watcher}.
- *
- *
- * @see EofSensorWatcher EofSensorWatcher
- *
- * @author Roland Weber
- * @author Ortwin Glueck
- * @author Eric Johnson
- * @author Mike Bowler
- *
- *
- *
- * @version $Revision: 672367 $
- *
- * @since 4.0
- */
-// don't use FilterInputStream as the base class, we'd have to
-// override markSupported(), mark(), and reset() to disable them
-public class EofSensorInputStream extends InputStream
- implements ConnectionReleaseTrigger {
-
- /**
- * The wrapped input stream, while accessible.
- * The value changes to null when the wrapped stream
- * becomes inaccessible.
- */
- protected InputStream wrappedStream;
-
-
- /**
- * Indicates whether this stream itself is closed.
- * If it isn't, but {@link #wrappedStream wrappedStream}
- * is null, we're running in EOF mode.
- * All read operations will indicate EOF without accessing
- * the underlying stream. After closing this stream, read
- * operations will trigger an {@link IOException IOException}.
- *
- * @see #isReadAllowed isReadAllowed
- */
- private boolean selfClosed;
-
- /** The watcher to be notified, if any. */
- private EofSensorWatcher eofWatcher;
-
-
- /**
- * Creates a new EOF sensor.
- * If no watcher is passed, the underlying stream will simply be
- * closed when EOF is detected or {@link #close close} is called.
- * Otherwise, the watcher decides whether the underlying stream
- * should be closed before detaching from it.
- *
- * @param in the wrapped stream
- * @param watcher the watcher for events, or null for
- * auto-close behavior without notification
- */
- public EofSensorInputStream(final InputStream in,
- final EofSensorWatcher watcher) {
- if (in == null) {
- throw new IllegalArgumentException
- ("Wrapped stream may not be null.");
- }
-
- wrappedStream = in;
- selfClosed = false;
- eofWatcher = watcher;
- }
-
-
- /**
- * Checks whether the underlying stream can be read from.
- *
- * @return true if the underlying stream is accessible,
- * false if this stream is in EOF mode and
- * detached from the underlying stream
- *
- * @throws IOException if this stream is already closed
- */
- protected boolean isReadAllowed() throws IOException {
- if (selfClosed) {
- throw new IOException("Attempted read on closed stream.");
- }
- return (wrappedStream != null);
- }
-
-
- // non-javadoc, see base class InputStream
- @Override
- public int read() throws IOException {
- int l = -1;
-
- if (isReadAllowed()) {
- try {
- l = wrappedStream.read();
- checkEOF(l);
- } catch (IOException ex) {
- checkAbort();
- throw ex;
- }
- }
-
- return l;
- }
-
-
- // non-javadoc, see base class InputStream
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- int l = -1;
-
- if (isReadAllowed()) {
- try {
- l = wrappedStream.read(b, off, len);
- checkEOF(l);
- } catch (IOException ex) {
- checkAbort();
- throw ex;
- }
- }
-
- return l;
- }
-
-
- // non-javadoc, see base class InputStream
- @Override
- public int read(byte[] b) throws IOException {
- int l = -1;
-
- if (isReadAllowed()) {
- try {
- l = wrappedStream.read(b);
- checkEOF(l);
- } catch (IOException ex) {
- checkAbort();
- throw ex;
- }
- }
- return l;
- }
-
-
- // non-javadoc, see base class InputStream
- @Override
- public int available() throws IOException {
- int a = 0; // not -1
-
- if (isReadAllowed()) {
- try {
- a = wrappedStream.available();
- // no checkEOF() here, available() can't trigger EOF
- } catch (IOException ex) {
- checkAbort();
- throw ex;
- }
- }
-
- return a;
- }
-
-
- // non-javadoc, see base class InputStream
- @Override
- public void close() throws IOException {
- // tolerate multiple calls to close()
- selfClosed = true;
- checkClose();
- }
-
-
- /**
- * Detects EOF and notifies the watcher.
- * This method should only be called while the underlying stream is
- * still accessible. Use {@link #isReadAllowed isReadAllowed} to
- * check that condition.
- *
- * If EOF is detected, the watcher will be notified and this stream
- * is detached from the underlying stream. This prevents multiple
- * notifications from this stream.
- *
- * @param eof the result of the calling read operation.
- * A negative value indicates that EOF is reached.
- *
- * @throws IOException
- * in case of an IO problem on closing the underlying stream
- */
- protected void checkEOF(int eof) throws IOException {
-
- if ((wrappedStream != null) && (eof < 0)) {
- try {
- boolean scws = true; // should close wrapped stream?
- if (eofWatcher != null)
- scws = eofWatcher.eofDetected(wrappedStream);
- if (scws)
- wrappedStream.close();
- } finally {
- wrappedStream = null;
- }
- }
- }
-
-
- /**
- * Detects stream close and notifies the watcher.
- * There's not much to detect since this is called by {@link #close close}.
- * The watcher will only be notified if this stream is closed
- * for the first time and before EOF has been detected.
- * This stream will be detached from the underlying stream to prevent
- * multiple notifications to the watcher.
- *
- * @throws IOException
- * in case of an IO problem on closing the underlying stream
- */
- protected void checkClose() throws IOException {
-
- if (wrappedStream != null) {
- try {
- boolean scws = true; // should close wrapped stream?
- if (eofWatcher != null)
- scws = eofWatcher.streamClosed(wrappedStream);
- if (scws)
- wrappedStream.close();
- } finally {
- wrappedStream = null;
- }
- }
- }
-
-
- /**
- * Detects stream abort and notifies the watcher.
- * There's not much to detect since this is called by
- * {@link #abortConnection abortConnection}.
- * The watcher will only be notified if this stream is aborted
- * for the first time and before EOF has been detected or the
- * stream has been {@link #close closed} gracefully.
- * This stream will be detached from the underlying stream to prevent
- * multiple notifications to the watcher.
- *
- * @throws IOException
- * in case of an IO problem on closing the underlying stream
- */
- protected void checkAbort() throws IOException {
-
- if (wrappedStream != null) {
- try {
- boolean scws = true; // should close wrapped stream?
- if (eofWatcher != null)
- scws = eofWatcher.streamAbort(wrappedStream);
- if (scws)
- wrappedStream.close();
- } finally {
- wrappedStream = null;
- }
- }
- }
-
-
- /**
- * Same as {@link #close close()}.
- */
- public void releaseConnection() throws IOException {
- this.close();
- }
-
- /**
- * Aborts this stream.
- * This is a special version of {@link #close close()} which prevents
- * re-use of the underlying connection, if any. Calling this method
- * indicates that there should be no attempt to read until the end of
- * the stream.
- */
- public void abortConnection() throws IOException {
- // tolerate multiple calls
- selfClosed = true;
- checkAbort();
- }
-
-} // class EOFSensorInputStream
-
diff --git a/src/org/apache/http/conn/EofSensorWatcher.java b/src/org/apache/http/conn/EofSensorWatcher.java
deleted file mode 100644
index 837f8d95e3e3f65a45004a469b09671c4c04509c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/EofSensorWatcher.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/EofSensorWatcher.java $
- * $Revision: 552264 $
- * $Date: 2007-07-01 02:37:47 -0700 (Sun, 01 Jul 2007) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-
-/**
- * A watcher for {@link EofSensorInputStream EofSensorInputStream}.
- * Each stream will notify it's watcher at most once.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 552264 $
- *
- * @since 4.0
- */
-public interface EofSensorWatcher {
-
- /**
- * Indicates that EOF is detected.
- *
- * @param wrapped the underlying stream which has reached EOF
- *
- * @return true if wrapped should be closed,
- * false if it should be left alone
- *
- * @throws IOException
- * in case of an IO problem, for example if the watcher itself
- * closes the underlying stream. The caller will leave the
- * wrapped stream alone, as if false was returned.
- */
- boolean eofDetected(InputStream wrapped)
- throws IOException
- ;
-
-
- /**
- * Indicates that the {@link EofSensorInputStream stream} is closed.
- * This method will be called only if EOF was not detected
- * before closing. Otherwise, {@link #eofDetected eofDetected} is called.
- *
- * @param wrapped the underlying stream which has not reached EOF
- *
- * @return true if wrapped should be closed,
- * false if it should be left alone
- *
- * @throws IOException
- * in case of an IO problem, for example if the watcher itself
- * closes the underlying stream. The caller will leave the
- * wrapped stream alone, as if false was returned.
- */
- boolean streamClosed(InputStream wrapped)
- throws IOException
- ;
-
-
- /**
- * Indicates that the {@link EofSensorInputStream stream} is aborted.
- * This method will be called only if EOF was not detected
- * before aborting. Otherwise, {@link #eofDetected eofDetected} is called.
- *
- * This method will also be invoked when an input operation causes an
- * IOException to be thrown to make sure the input stream gets shut down.
- *
- * @param wrapped the underlying stream which has not reached EOF
- *
- * @return true if wrapped should be closed,
- * false if it should be left alone
- *
- * @throws IOException
- * in case of an IO problem, for example if the watcher itself
- * closes the underlying stream. The caller will leave the
- * wrapped stream alone, as if false was returned.
- */
- boolean streamAbort(InputStream wrapped)
- throws IOException
- ;
-
-
-} // interface EofSensorWatcher
diff --git a/src/org/apache/http/conn/HttpHostConnectException.java b/src/org/apache/http/conn/HttpHostConnectException.java
deleted file mode 100644
index 743ca777a8a9377be64f97243b9fc9bc6fd025a9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/HttpHostConnectException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/HttpHostConnectException.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.net.ConnectException;
-
-import org.apache.http.HttpHost;
-
-/**
- * A {@link ConnectException} that specifies the {@link HttpHost} that was
- * being connected to.
- */
-public class HttpHostConnectException extends ConnectException {
-
- private static final long serialVersionUID = -3194482710275220224L;
-
- private final HttpHost host;
-
- public HttpHostConnectException(final HttpHost host, final ConnectException cause) {
- super("Connection to " + host + " refused");
- this.host = host;
- initCause(cause);
- }
-
- public HttpHost getHost() {
- return this.host;
- }
-
-}
diff --git a/src/org/apache/http/conn/ManagedClientConnection.java b/src/org/apache/http/conn/ManagedClientConnection.java
deleted file mode 100644
index f642cb91da894393fa2ce5e3a78b25a73a5ff540..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ManagedClientConnection.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ManagedClientConnection.java $
- * $Revision: 672969 $
- * $Date: 2008-06-30 18:09:50 -0700 (Mon, 30 Jun 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLSession;
-
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpInetConnection;
-import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-import org.apache.http.conn.routing.HttpRoute;
-
-
-
-/**
- * A client-side connection with advanced connection logic.
- * Instances are typically obtained from a connection manager.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 672969 $
- *
- * @since 4.0
- */
-public interface ManagedClientConnection extends
- HttpClientConnection, HttpInetConnection, ConnectionReleaseTrigger {
-
-
- /**
- * Indicates whether this connection is secure.
- * The return value is well-defined only while the connection is open.
- * It may change even while the connection is open.
- *
- * @return true if this connection is secure,
- * false otherwise
- */
- boolean isSecure()
- ;
-
-
- /**
- * Obtains the current route of this connection.
- *
- * @return the route established so far, or
- * null if not connected
- */
- HttpRoute getRoute()
- ;
-
-
- /**
- * Obtains the SSL session of the underlying connection, if any.
- * If this connection is open, and the underlying socket is an
- * {@link javax.net.ssl.SSLSocket SSLSocket}, the SSL session of
- * that socket is obtained. This is a potentially blocking operation.
- *
- * Note: Whether the underlying socket is an SSL socket
- * can not necessarily be determined via {@link #isSecure}.
- * Plain sockets may be considered secure, for example if they are
- * connected to a known host in the same network segment.
- * On the other hand, SSL sockets may be considered insecure,
- * for example depending on the chosen cipher suite.
- *
- * @return the underlying SSL session if available,
- * null otherwise
- */
- SSLSession getSSLSession()
- ;
-
-
- /**
- * Opens this connection according to the given route.
- *
- * @param route the route along which to open. It will be opened to
- * the first proxy if present, or directly to the target.
- * @param context the context for opening this connection
- * @param params the parameters for opening this connection
- *
- * @throws IOException in case of a problem
- */
- void open(HttpRoute route, HttpContext context, HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Indicates that a tunnel to the target has been established.
- * The route is the one previously passed to {@link #open open}.
- * Subsequently, {@link #layerProtocol layerProtocol} can be called
- * to layer the TLS/SSL protocol on top of the tunnelled connection.
- *
- * Note: In HttpClient 3, a call to the corresponding method
- * would automatically trigger the layering of the TLS/SSL protocol.
- * This is not the case anymore, you can establish a tunnel without
- * layering a new protocol over the connection.
- *
- * @param secure true if the tunnel should be considered
- * secure, false otherwise
- * @param params the parameters for tunnelling this connection
- *
- * @throws IOException in case of a problem
- */
- void tunnelTarget(boolean secure, HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Indicates that a tunnel to an intermediate proxy has been established.
- * This is used exclusively for so-called proxy chains, where
- * a request has to pass through multiple proxies before reaching the
- * target. In that case, all proxies but the last need to be tunnelled
- * when establishing the connection. Tunnelling of the last proxy to the
- * target is optional and would be indicated via {@link #tunnelTarget}.
- *
- * @param next the proxy to which the tunnel was established.
- * This is not the proxy through which
- * the tunnel was established, but the new end point
- * of the tunnel. The tunnel does not yet
- * reach to the target, use {@link #tunnelTarget}
- * to indicate an end-to-end tunnel.
- * @param secure true if the connection should be
- * considered secure, false otherwise
- * @param params the parameters for tunnelling this connection
- *
- * @throws IOException in case of a problem
- */
- void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Layers a new protocol on top of a {@link #tunnelTarget tunnelled}
- * connection. This is typically used to create a TLS/SSL connection
- * through a proxy.
- * The route is the one previously passed to {@link #open open}.
- * It is not guaranteed that the layered connection is
- * {@link #isSecure secure}.
- *
- * @param context the context for layering on top of this connection
- * @param params the parameters for layering on top of this connection
- *
- * @throws IOException in case of a problem
- */
- void layerProtocol(HttpContext context, HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Marks this connection as being in a reusable communication state.
- * The checkpoints for reuseable communication states (in the absence
- * of pipelining) are before sending a request and after receiving
- * the response in it's entirety.
- * The connection will automatically clear the checkpoint when
- * used for communication. A call to this method indicates that
- * the next checkpoint has been reached.
- *
- * A reusable communication state is necessary but not sufficient
- * for the connection to be reused.
- * A {@link #getRoute route} mismatch, the connection being closed,
- * or other circumstances might prevent reuse.
- */
- void markReusable()
- ;
-
-
- /**
- * Marks this connection as not being in a reusable state.
- * This can be used immediately before releasing this connection
- * to prevent it's reuse. Reasons for preventing reuse include
- * error conditions and the evaluation of a
- * {@link org.apache.http.ConnectionReuseStrategy reuse strategy}.
- *
- * Note:
- * It is not necessary to call here before writing to
- * or reading from this connection. Communication attempts will
- * automatically unmark the state as non-reusable. It can then
- * be switched back using {@link #markReusable markReusable}.
- */
- void unmarkReusable()
- ;
-
-
- /**
- * Indicates whether this connection is in a reusable communication state.
- * See {@link #markReusable markReusable} and
- * {@link #unmarkReusable unmarkReusable} for details.
- *
- * @return true if this connection is marked as being in
- * a reusable communication state,
- * false otherwise
- */
- boolean isMarkedReusable()
- ;
-
- /**
- * Assigns a state object to this connection. Connection managers may make
- * use of the connection state when allocating persistent connections.
- *
- * @param state The state object
- */
- void setState(Object state)
- ;
-
- /**
- * Returns the state object associated with this connection.
- *
- * @return The state object
- */
- Object getState()
- ;
-
- /**
- * Sets the duration that this connection can remain idle before it is
- * reused. The connection should not be used again if this time elapses. The
- * idle duration must be reset after each request sent over this connection.
- * The elapsed time starts counting when the connection is released, which
- * is typically after the headers (and any response body, if present) is
- * fully consumed.
- */
- void setIdleDuration(long duration, TimeUnit unit);
-
-} // interface ManagedClientConnection
diff --git a/src/org/apache/http/conn/MultihomePlainSocketFactory.java b/src/org/apache/http/conn/MultihomePlainSocketFactory.java
deleted file mode 100644
index e9549ab1f8b482734df948e2b9644ac4a2c5e113..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/MultihomePlainSocketFactory.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Arrays;
-
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.SocketFactory;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Socket factory that implements a simple multi-home fail-over on connect failure,
- * provided the same hostname resolves to multiple {@link InetAddress}es. Please note
- * the {@link #connectSocket(Socket, String, int, InetAddress, int, HttpParams)}
- * method cannot be reliably interrupted by closing the socket returned by the
- * {@link #createSocket()} method.
- */
-public final class MultihomePlainSocketFactory implements SocketFactory {
-
- /**
- * The factory singleton.
- */
- private static final
- MultihomePlainSocketFactory DEFAULT_FACTORY = new MultihomePlainSocketFactory();
-
- /**
- * Gets the singleton instance of this class.
- * @return the one and only plain socket factory
- */
- public static MultihomePlainSocketFactory getSocketFactory() {
- return DEFAULT_FACTORY;
- }
-
- /**
- * Restricted default constructor.
- */
- private MultihomePlainSocketFactory() {
- super();
- }
-
-
- // non-javadoc, see interface org.apache.http.conn.SocketFactory
- public Socket createSocket() {
- return new Socket();
- }
-
- /**
- * Attempts to connects the socket to any of the {@link InetAddress}es the
- * given host name resolves to. If connection to all addresses fail, the
- * last I/O exception is propagated to the caller.
- *
- * @param sock socket to connect to any of the given addresses
- * @param host Host name to connect to
- * @param port the port to connect to
- * @param localAddress local address
- * @param localPort local port
- * @param params HTTP parameters
- *
- * @throws IOException if an error occurs during the connection
- * @throws SocketTimeoutException if timeout expires before connecting
- */
- public Socket connectSocket(Socket sock, String host, int port,
- InetAddress localAddress, int localPort,
- HttpParams params)
- throws IOException {
-
- if (host == null) {
- throw new IllegalArgumentException("Target host may not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null.");
- }
-
- if (sock == null)
- sock = createSocket();
-
- if ((localAddress != null) || (localPort > 0)) {
-
- // we need to bind explicitly
- if (localPort < 0)
- localPort = 0; // indicates "any"
-
- InetSocketAddress isa =
- new InetSocketAddress(localAddress, localPort);
- sock.bind(isa);
- }
-
- int timeout = HttpConnectionParams.getConnectionTimeout(params);
-
- InetAddress[] inetadrs = InetAddress.getAllByName(host);
- List addresses = new ArrayList(inetadrs.length);
- addresses.addAll(Arrays.asList(inetadrs));
- Collections.shuffle(addresses);
-
- IOException lastEx = null;
- for (InetAddress address: addresses) {
- try {
- sock.connect(new InetSocketAddress(address, port), timeout);
- break;
- } catch (SocketTimeoutException ex) {
- throw ex;
- } catch (IOException ex) {
- // create new socket
- sock = new Socket();
- // keep the last exception and retry
- lastEx = ex;
- }
- }
- if (lastEx != null) {
- throw lastEx;
- }
- return sock;
- } // connectSocket
-
-
- /**
- * Checks whether a socket connection is secure.
- * This factory creates plain socket connections
- * which are not considered secure.
- *
- * @param sock the connected socket
- *
- * @return false
- *
- * @throws IllegalArgumentException if the argument is invalid
- */
- public final boolean isSecure(Socket sock)
- throws IllegalArgumentException {
-
- if (sock == null) {
- throw new IllegalArgumentException("Socket may not be null.");
- }
- // This class check assumes that createSocket() calls the constructor
- // directly. If it was using javax.net.SocketFactory, we couldn't make
- // an assumption about the socket class here.
- if (sock.getClass() != Socket.class) {
- throw new IllegalArgumentException
- ("Socket not created by this factory.");
- }
- // This check is performed last since it calls a method implemented
- // by the argument object. getClass() is final in java.lang.Object.
- if (sock.isClosed()) {
- throw new IllegalArgumentException("Socket is closed.");
- }
-
- return false;
-
- } // isSecure
-
-
- /**
- * Compares this factory with an object.
- * There is only one instance of this class.
- *
- * @param obj the object to compare with
- *
- * @return iff the argument is this object
- */
- @Override
- public boolean equals(Object obj) {
- return (obj == this);
- }
-
- /**
- * Obtains a hash code for this object.
- * All instances of this class have the same hash code.
- * There is only one instance of this class.
- */
- @Override
- public int hashCode() {
- return PlainSocketFactory.class.hashCode();
- }
-
-}
diff --git a/src/org/apache/http/conn/OperatedClientConnection.java b/src/org/apache/http/conn/OperatedClientConnection.java
deleted file mode 100644
index 2eda8e98b092b6e77a8d2cf1adcdc80f5fc090b8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/OperatedClientConnection.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/OperatedClientConnection.java $
- * $Revision: 646087 $
- * $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpInetConnection;
-import org.apache.http.params.HttpParams;
-
-
-/**
- * A client-side connection that relies on outside logic to connect sockets to the
- * appropriate hosts. It can be operated directly by an application, or through an
- * {@link ClientConnectionOperator operator}.
- *
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 646087 $ $Date: 2008-04-08 14:36:46 -0700 (Tue, 08 Apr 2008) $
- *
- * @since 4.0
- */
-public interface OperatedClientConnection
- extends HttpClientConnection, HttpInetConnection {
-
- /**
- * Obtains the target host for this connection.
- * If the connection is to a proxy but not tunnelled, this is
- * the proxy. If the connection is tunnelled through a proxy,
- * this is the target of the tunnel.
- *
- * The return value is well-defined only while the connection is open.
- * It may change even while the connection is open,
- * because of an {@link #update update}.
- *
- * @return the host to which this connection is opened
- */
- HttpHost getTargetHost()
- ;
-
- /**
- * Indicates whether this connection is secure.
- * The return value is well-defined only while the connection is open.
- * It may change even while the connection is open,
- * because of an {@link #update update}.
- *
- * @return true if this connection is secure,
- * false otherwise
- */
- boolean isSecure()
- ;
-
- /**
- * Obtains the socket for this connection.
- * The return value is well-defined only while the connection is open.
- * It may change even while the connection is open,
- * because of an {@link #update update}.
- *
- * @return the socket for communicating with the
- * {@link #getTargetHost target host}
- */
- Socket getSocket()
- ;
-
-
- // There is no getParams(). For the moment, we
- // do not require connections to store parameters.
-
-
- /**
- * Signals that this connection is in the process of being open.
- *
- * By calling this method, you can provide the connection with
- * the unconnected socket that will be connected before
- * {@link #openCompleted} is called. This allows
- * the connection to close that socket if
- * {@link org.apache.http.HttpConnection#shutdown shutdown}
- * is called before it is open. Closing the unconnected socket
- * will interrupt a thread that is blocked on the connect.
- * Otherwise, that thread will either time out on the connect,
- * or it returns successfully and then opens this connection
- * which was just shut down.
- *
- * You also must call {@link #openCompleted} in order to complete
- * the process
- *
- * @param sock the unconnected socket which is about to
- * be connected.
- * @param target the target host of this connection
- */
- void opening(Socket sock, HttpHost target)
- throws IOException
- ;
-
-
- /**
- * Signals that the connection has been successfully open.
- * An attempt to call this method on an open connection will cause
- * an exception.
- *
- * @param secure true if this connection is secure, for
- * example if an SSLSocket is used, or
- * false if it is not secure
- * @param params parameters for this connection. The parameters will
- * be used when creating dependent objects, for example
- * to determine buffer sizes.
- */
- void openCompleted(boolean secure, HttpParams params)
- throws IOException
- ;
-
-
- /**
- * Updates this connection.
- * A connection can be updated only while it is open.
- * Updates are used for example when a tunnel has been established,
- * or when a TLS/SSL connection has been layered on top of a plain
- * socket connection.
- *
- * Note: Updating the connection will not close the
- * previously used socket. It is the caller's responsibility to close
- * that socket if it is no longer required.
- *
- * @param sock the new socket for communicating with the target host,
- * or null to continue using the old socket.
- * If null is passed, helper objects that
- * depend on the socket should be re-used. In that case,
- * some changes in the parameters will not take effect.
- * @param target the new target host of this connection
- * @param secure true if this connection is now secure,
- * false if it is not secure
- * @param params new parameters for this connection
- */
- void update(Socket sock, HttpHost target,
- boolean secure, HttpParams params)
- throws IOException
- ;
-
-
-} // interface OperatedClientConnection
diff --git a/src/org/apache/http/conn/package.html b/src/org/apache/http/conn/package.html
deleted file mode 100644
index e0b29cdff4c9160dfd0b0e5ec239d932c08e644b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/package.html
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-The client-side connection management and handling API
-at the heart of what is referred to as HttpConn.
-This component provides interfaces and implementations for
-opening and managing connections.
-
-
-The lowest layer of connection handling is comprised of
-{@link org.apache.http.conn.OperatedClientConnection OperatedClientConnection}
-and
-{@link org.apache.http.conn.ClientConnectionOperator ClientConnectionOperator}.
-The connection interface extends the core
-{@link org.apache.http.HttpClientConnection HttpClientConnection}
-by operations to set and update a socket.
-An operator encapsulates the logic to open and layer sockets,
-typically using a {@link org.apache.http.conn.scheme.SocketFactory SocketFactory}.
-The socket factory for a protocol
-{@link org.apache.http.conn.scheme.Scheme Scheme}
-such as "http" or "https" can be looked up in a
-{@link org.apache.http.conn.scheme.SchemeRegistry SchemeRegistry}.
-Applications without a need for sophisticated connection management
-can use this layer directly.
-
-
-
-On top of that lies the connection management layer. A
-{@link org.apache.http.conn.ClientConnectionManager ClientConnectionManager}
-internally manages operated connections, but hands out instances of
-{@link org.apache.http.conn.ManagedClientConnection ManagedClientConnection}.
-This interface abstracts from the underlying socket operations and
-provides convenient methods for opening and updating sockets in order
-to establish a {@link org.apache.http.conn.routing.HttpRoute route}.
-The operator is encapsulated by the connection manager and called
-automatically.
-
-
-
-Connections obtained from a manager have to be returned after use.
-This can be {@link org.apache.http.conn.ConnectionReleaseTrigger triggered}
-on various levels, either by releasing the
-{@link org.apache.http.conn.ManagedClientConnection
- connection}
-directly, or by calling a method on an
-{@link org.apache.http.conn.BasicManagedEntity entity}
-received from the connection, or by closing the
-{@link org.apache.http.conn.EofSensorInputStream stream}
-from which that entity is being read.
-
-Connection managers will try to keep returned connections alive in
-order to re-use them for subsequent requests along the same route.
-The managed connection interface and all triggers for connection release
-provide methods to enable or disable this behavior.
-
-
-
-
diff --git a/src/org/apache/http/conn/params/ConnConnectionPNames.java b/src/org/apache/http/conn/params/ConnConnectionPNames.java
deleted file mode 100644
index ff1a0906fc2f1d3b1ef0b6c98bb62a7037b7e057..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnConnectionPNames.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java $
- * $Revision: 576068 $
- * $Date: 2007-09-16 03:25:01 -0700 (Sun, 16 Sep 2007) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-
-/**
- * Parameter names for connections in HttpConn.
- *
- * @version $Revision: 576068 $
- *
- * @since 4.0
- */
-public interface ConnConnectionPNames {
-
-
- /**
- * Defines the maximum number of ignorable lines before we expect
- * a HTTP response's status line.
- *
- * With HTTP/1.1 persistent connections, the problem arises that
- * broken scripts could return a wrong Content-Length
- * (there are more bytes sent than specified).
- * Unfortunately, in some cases, this cannot be detected after the
- * bad response, but only before the next one.
- * So HttpClient must be able to skip those surplus lines this way.
- *
- *
- * This parameter expects a value of type {@link Integer}.
- * 0 disallows all garbage/empty lines before the status line.
- * Use {@link java.lang.Integer#MAX_VALUE} for unlimited
- * (default in lenient mode).
- *
- */
- public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
-
-
-}
diff --git a/src/org/apache/http/conn/params/ConnConnectionParamBean.java b/src/org/apache/http/conn/params/ConnConnectionParamBean.java
deleted file mode 100644
index 094b152a1c75b745d90252224871a89e90f0b7ec..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnConnectionParamBean.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import org.apache.http.params.HttpAbstractParamBean;
-import org.apache.http.params.HttpParams;
-
-/**
- * Allows for setting parameters relating to connections on
- * {@link HttpParams}. This class ensures that the values set on the params
- * are type-safe.
- */
-public class ConnConnectionParamBean extends HttpAbstractParamBean {
-
- public ConnConnectionParamBean (final HttpParams params) {
- super(params);
- }
-
- /**
- * @see ConnConnectionPNames#MAX_STATUS_LINE_GARBAGE
- */
- public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) {
- params.setIntParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, maxStatusLineGarbage);
- }
-
-}
diff --git a/src/org/apache/http/conn/params/ConnManagerPNames.java b/src/org/apache/http/conn/params/ConnManagerPNames.java
deleted file mode 100644
index 1184b12929dad0f283db110ab29501ab4da54e27..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnManagerPNames.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java $
- * $Revision: 658781 $
- * $Date: 2008-05-21 10:42:13 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-
-/**
- * Parameter names for connection managers in HttpConn.
- *
- * @version $Revision: 658781 $
- *
- * @since 4.0
- */
-public interface ConnManagerPNames {
-
- /**
- * Defines the timeout in milliseconds used when retrieving an instance of
- * {@link org.apache.http.conn.ManagedClientConnection} from the
- * {@link org.apache.http.conn.ClientConnectionManager}.
- *
- * This parameter expects a value of type {@link Long}.
- *
- */
- public static final String TIMEOUT = "http.conn-manager.timeout";
-
- /**
- * Defines the maximum number of connections per route.
- * This limit is interpreted by client connection managers
- * and applies to individual manager instances.
- *
- * This parameter expects a value of type {@link ConnPerRoute}.
- *
- */
- public static final String MAX_CONNECTIONS_PER_ROUTE = "http.conn-manager.max-per-route";
-
- /**
- * Defines the maximum number of connections in total.
- * This limit is interpreted by client connection managers
- * and applies to individual manager instances.
- *
- * This parameter expects a value of type {@link Integer}.
- *
- */
- public static final String MAX_TOTAL_CONNECTIONS = "http.conn-manager.max-total";
-
-}
diff --git a/src/org/apache/http/conn/params/ConnManagerParamBean.java b/src/org/apache/http/conn/params/ConnManagerParamBean.java
deleted file mode 100644
index 830b7bf3b1698360de1dcf246b4ce34e7383f58a..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnManagerParamBean.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java $
- * $Revision: 658781 $
- * $Date: 2008-05-21 10:42:13 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import org.apache.http.params.HttpAbstractParamBean;
-import org.apache.http.params.HttpParams;
-
-/**
- * Allows for setting parameters relating to connection managers on
- * {@link HttpParams}. This class ensures that the values set on the params
- * are type-safe.
- */
-public class ConnManagerParamBean extends HttpAbstractParamBean {
-
- public ConnManagerParamBean (final HttpParams params) {
- super(params);
- }
-
- public void setTimeout (final long timeout) {
- params.setLongParameter(ConnManagerPNames.TIMEOUT, timeout);
- }
-
- /** @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS */
- public void setMaxTotalConnections (final int maxConnections) {
- params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, maxConnections);
- }
-
- /** @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE */
- public void setConnectionsPerRoute(final ConnPerRouteBean connPerRoute) {
- params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, connPerRoute);
- }
-
-}
diff --git a/src/org/apache/http/conn/params/ConnManagerParams.java b/src/org/apache/http/conn/params/ConnManagerParams.java
deleted file mode 100644
index c6e042e9e0313d88b35018bd38de0e53d3eef780..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnManagerParams.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnManagerParams.java $
- * $Revision: 658785 $
- * $Date: 2008-05-21 10:47:40 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.params.HttpParams;
-
-/**
- * This class represents a collection of HTTP protocol parameters applicable
- * to client-side
- * {@link org.apache.http.conn.ClientConnectionManager connection managers}.
- *
- * @author Oleg Kalnichevski
- * @author Michael Becke
- *
- * @version $Revision: 658785 $
- *
- * @since 4.0
- *
- * @see ConnManagerPNames
- */
-public final class ConnManagerParams implements ConnManagerPNames {
-
- /** The default maximum number of connections allowed overall */
- public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 20;
-
- /**
- * Returns the timeout in milliseconds used when retrieving a
- * {@link org.apache.http.conn.ManagedClientConnection} from the
- * {@link org.apache.http.conn.ClientConnectionManager}.
- *
- * @return timeout in milliseconds.
- */
- public static long getTimeout(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- return params.getLongParameter(TIMEOUT, 0);
- }
-
- /**
- * Sets the timeout in milliseconds used when retrieving a
- * {@link org.apache.http.conn.ManagedClientConnection} from the
- * {@link org.apache.http.conn.ClientConnectionManager}.
- *
- * @param timeout the timeout in milliseconds
- */
- public static void setTimeout(final HttpParams params, long timeout) {
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- params.setLongParameter(TIMEOUT, timeout);
- }
-
- /** The default maximum number of connections allowed per host */
- private static final ConnPerRoute DEFAULT_CONN_PER_ROUTE = new ConnPerRoute() {
-
- public int getMaxForRoute(HttpRoute route) {
- return ConnPerRouteBean.DEFAULT_MAX_CONNECTIONS_PER_ROUTE;
- }
-
- };
-
- /**
- * Sets lookup interface for maximum number of connections allowed per route.
- *
- * @param params HTTP parameters
- * @param connPerRoute lookup interface for maximum number of connections allowed
- * per route
- *
- * @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
- */
- public static void setMaxConnectionsPerRoute(final HttpParams params,
- final ConnPerRoute connPerRoute) {
- if (params == null) {
- throw new IllegalArgumentException
- ("HTTP parameters must not be null.");
- }
- params.setParameter(MAX_CONNECTIONS_PER_ROUTE, connPerRoute);
- }
-
- /**
- * Returns lookup interface for maximum number of connections allowed per route.
- *
- * @param params HTTP parameters
- *
- * @return lookup interface for maximum number of connections allowed per route.
- *
- * @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
- */
- public static ConnPerRoute getMaxConnectionsPerRoute(final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException
- ("HTTP parameters must not be null.");
- }
- ConnPerRoute connPerRoute = (ConnPerRoute) params.getParameter(MAX_CONNECTIONS_PER_ROUTE);
- if (connPerRoute == null) {
- connPerRoute = DEFAULT_CONN_PER_ROUTE;
- }
- return connPerRoute;
- }
-
-
- /**
- * Sets the maximum number of connections allowed.
- *
- * @param params HTTP parameters
- * @param maxTotalConnections The maximum number of connections allowed.
- *
- * @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
- */
- public static void setMaxTotalConnections(
- final HttpParams params,
- int maxTotalConnections) {
- if (params == null) {
- throw new IllegalArgumentException
- ("HTTP parameters must not be null.");
- }
- params.setIntParameter(MAX_TOTAL_CONNECTIONS, maxTotalConnections);
- }
-
- /**
- * Gets the maximum number of connections allowed.
- *
- * @param params HTTP parameters
- *
- * @return The maximum number of connections allowed.
- *
- * @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
- */
- public static int getMaxTotalConnections(
- final HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException
- ("HTTP parameters must not be null.");
- }
- return params.getIntParameter(MAX_TOTAL_CONNECTIONS, DEFAULT_MAX_TOTAL_CONNECTIONS);
- }
-
-
-}
diff --git a/src/org/apache/http/conn/params/ConnPerRoute.java b/src/org/apache/http/conn/params/ConnPerRoute.java
deleted file mode 100644
index abff04e79ada8e47798812018daeae42a3252abe..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnPerRoute.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnPerRoute.java $
- * $Revision: 651813 $
- * $Date: 2008-04-26 03:43:34 -0700 (Sat, 26 Apr 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import org.apache.http.conn.routing.HttpRoute;
-
-/**
- * This interface is intended for looking up maximum number of connections
- * allowed for for a given route. This class can be used by pooling
- * {@link org.apache.http.conn.ClientConnectionManager connection managers} for
- * a fine-grained control of connections on a per route basis.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 651813 $
- *
- * @since 4.0
- */
-public interface ConnPerRoute {
-
- int getMaxForRoute(HttpRoute route);
-
-}
diff --git a/src/org/apache/http/conn/params/ConnPerRouteBean.java b/src/org/apache/http/conn/params/ConnPerRouteBean.java
deleted file mode 100644
index c6a36e349ed190abc2c9a807de7898bf9ab13a5e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnPerRouteBean.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java $
- * $Revision: 652947 $
- * $Date: 2008-05-02 16:15:40 -0700 (Fri, 02 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.http.conn.routing.HttpRoute;
-
-/**
- * This class maintains a map of HTTP routes to maximum number of connections allowed
- * for those routes. This class can be used by pooling
- * {@link org.apache.http.conn.ClientConnectionManager connection managers} for
- * a fine-grained control of connections on a per route basis.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 652947 $
- *
- * @since 4.0
- */
-public final class ConnPerRouteBean implements ConnPerRoute {
-
- /** The default maximum number of connections allowed per host */
- public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 2; // Per RFC 2616 sec 8.1.4
-
- private final Map maxPerHostMap;
-
- private int defaultMax;
-
- public ConnPerRouteBean(int defaultMax) {
- super();
- this.maxPerHostMap = new HashMap();
- setDefaultMaxPerRoute(defaultMax);
- }
-
- public ConnPerRouteBean() {
- this(DEFAULT_MAX_CONNECTIONS_PER_ROUTE);
- }
-
- public int getDefaultMax() {
- return this.defaultMax;
- }
-
- public void setDefaultMaxPerRoute(int max) {
- if (max < 1) {
- throw new IllegalArgumentException
- ("The maximum must be greater than 0.");
- }
- this.defaultMax = max;
- }
-
- public void setMaxForRoute(final HttpRoute route, int max) {
- if (route == null) {
- throw new IllegalArgumentException
- ("HTTP route may not be null.");
- }
- if (max < 1) {
- throw new IllegalArgumentException
- ("The maximum must be greater than 0.");
- }
- this.maxPerHostMap.put(route, Integer.valueOf(max));
- }
-
- public int getMaxForRoute(final HttpRoute route) {
- if (route == null) {
- throw new IllegalArgumentException
- ("HTTP route may not be null.");
- }
- Integer max = this.maxPerHostMap.get(route);
- if (max != null) {
- return max.intValue();
- } else {
- return this.defaultMax;
- }
- }
-
- public void setMaxForRoutes(final Map map) {
- if (map == null) {
- return;
- }
- this.maxPerHostMap.clear();
- this.maxPerHostMap.putAll(map);
- }
-
-}
diff --git a/src/org/apache/http/conn/params/ConnRoutePNames.java b/src/org/apache/http/conn/params/ConnRoutePNames.java
deleted file mode 100644
index f9d42db3052f2ac42ecb376a0a027bd6e06ab069..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnRoutePNames.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java $
- * $Revision: 613656 $
- * $Date: 2008-01-20 11:06:56 -0800 (Sun, 20 Jan 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-/**
- * Parameter names for routing in HttpConn.
- *
- * @version $Revision: 613656 $
- *
- * @since 4.0
- */
-public interface ConnRoutePNames {
-
- /**
- * Parameter for the default proxy.
- * The default value will be used by some
- * {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
- * implementations, in particular the default implementation.
- *
- * This parameter expects a value of type {@link org.apache.http.HttpHost}.
- *
- */
- public static final String DEFAULT_PROXY = "http.route.default-proxy";
-
-
- /**
- * Parameter for the local address.
- * On machines with multiple network interfaces, this parameter
- * can be used to select the network interface from which the
- * connection originates.
- * It will be interpreted by the standard
- * {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
- * implementations, in particular the default implementation.
- *
- * This parameter expects a value of type {@link java.net.InetAddress}.
- *
- */
- public static final String LOCAL_ADDRESS = "http.route.local-address";
-
-
- /**
- * Parameter for an forced route.
- * The forced route will be interpreted by the standard
- * {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
- * implementations.
- * Instead of computing a route, the given forced route will be
- * returned, even if it points to the wrong target host.
- *
- * This parameter expects a value of type
- * {@link org.apache.http.conn.routing.HttpRoute HttpRoute}.
- *
- */
- public static final String FORCED_ROUTE = "http.route.forced-route";
-
-}
-
diff --git a/src/org/apache/http/conn/params/ConnRouteParamBean.java b/src/org/apache/http/conn/params/ConnRouteParamBean.java
deleted file mode 100644
index 9464c0240bf3a85cd3cedd9609467da9c6e9f441..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnRouteParamBean.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.params.HttpAbstractParamBean;
-import org.apache.http.params.HttpParams;
-
-/**
- * Allows for setting parameters relating to connection routes on
- * {@link HttpParams}. This class ensures that the values set on the params
- * are type-safe.
- */
-public class ConnRouteParamBean extends HttpAbstractParamBean {
-
- public ConnRouteParamBean (final HttpParams params) {
- super(params);
- }
-
- /** @see ConnRoutePNames#DEFAULT_PROXY */
- public void setDefaultProxy (final HttpHost defaultProxy) {
- params.setParameter(ConnRoutePNames.DEFAULT_PROXY, defaultProxy);
- }
-
- /** @see ConnRoutePNames#LOCAL_ADDRESS */
- public void setLocalAddress (final InetAddress address) {
- params.setParameter(ConnRoutePNames.LOCAL_ADDRESS, address);
- }
-
- /** @see ConnRoutePNames#FORCED_ROUTE */
- public void setForcedRoute (final HttpRoute route) {
- params.setParameter(ConnRoutePNames.FORCED_ROUTE, route);
- }
-
-}
diff --git a/src/org/apache/http/conn/params/ConnRouteParams.java b/src/org/apache/http/conn/params/ConnRouteParams.java
deleted file mode 100644
index 2fa165402314a045d70d29dfc912b4d54f9e9941..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/ConnRouteParams.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/ConnRouteParams.java $
- * $Revision: 658785 $
- * $Date: 2008-05-21 10:47:40 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.params;
-
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
-import org.apache.http.conn.routing.HttpRoute;
-
-
-
-/**
- * An adaptor for accessing route related parameters in {@link HttpParams}.
- * See {@link ConnRoutePNames} for parameter name definitions.
- *
- * @author Oleg Kalnichevski
- * @author Roland Weber
- *
- * @version $Revision: 658785 $
- *
- * @since 4.0
- */
-public class ConnRouteParams implements ConnRoutePNames {
-
- /**
- * A special value indicating "no host".
- * This relies on a nonsense scheme name to avoid conflicts
- * with actual hosts. Note that this is a valid host.
- */
- public static final HttpHost NO_HOST =
- new HttpHost("127.0.0.255", 0, "no-host");
-
- /**
- * A special value indicating "no route".
- * This is a route with {@link #NO_HOST} as the target.
- */
- public static final HttpRoute NO_ROUTE = new HttpRoute(NO_HOST);
-
-
- /** Disabled default constructor. */
- private ConnRouteParams() {
- // no body
- }
-
-
- /**
- * Obtains the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
- * parameter value.
- * {@link #NO_HOST} will be mapped to null,
- * to allow unsetting in a hierarchy.
- *
- * @param params the parameters in which to look up
- *
- * @return the default proxy set in the argument parameters, or
- * null if not set
- */
- public static HttpHost getDefaultProxy(HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- HttpHost proxy = (HttpHost)
- params.getParameter(DEFAULT_PROXY);
- if ((proxy != null) && NO_HOST.equals(proxy)) {
- // value is explicitly unset
- proxy = null;
- }
- return proxy;
- }
-
-
- /**
- * Sets the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
- * parameter value.
- *
- * @param params the parameters in which to set the value
- * @param proxy the value to set, may be null.
- * Note that {@link #NO_HOST} will be mapped to
- * null by {@link #getDefaultProxy},
- * to allow for explicit unsetting in hierarchies.
- */
- public static void setDefaultProxy(HttpParams params,
- HttpHost proxy) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- params.setParameter(DEFAULT_PROXY, proxy);
- }
-
-
- /**
- * Obtains the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
- * parameter value.
- * {@link #NO_ROUTE} will be mapped to null,
- * to allow unsetting in a hierarchy.
- *
- * @param params the parameters in which to look up
- *
- * @return the forced route set in the argument parameters, or
- * null if not set
- */
- public static HttpRoute getForcedRoute(HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- HttpRoute route = (HttpRoute)
- params.getParameter(FORCED_ROUTE);
- if ((route != null) && NO_ROUTE.equals(route)) {
- // value is explicitly unset
- route = null;
- }
- return route;
- }
-
-
- /**
- * Sets the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
- * parameter value.
- *
- * @param params the parameters in which to set the value
- * @param route the value to set, may be null.
- * Note that {@link #NO_ROUTE} will be mapped to
- * null by {@link #getForcedRoute},
- * to allow for explicit unsetting in hierarchies.
- */
- public static void setForcedRoute(HttpParams params,
- HttpRoute route) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- params.setParameter(FORCED_ROUTE, route);
- }
-
-
- /**
- * Obtains the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
- * parameter value.
- * There is no special value that would automatically be mapped to
- * null. You can use the wildcard address (0.0.0.0 for IPv4,
- * :: for IPv6) to override a specific local address in a hierarchy.
- *
- * @param params the parameters in which to look up
- *
- * @return the local address set in the argument parameters, or
- * null if not set
- */
- public static InetAddress getLocalAddress(HttpParams params) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- InetAddress local = (InetAddress)
- params.getParameter(LOCAL_ADDRESS);
- // no explicit unsetting
- return local;
- }
-
-
- /**
- * Sets the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
- * parameter value.
- *
- * @param params the parameters in which to set the value
- * @param local the value to set, may be null
- */
- public static void setLocalAddress(HttpParams params,
- InetAddress local) {
- if (params == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
- params.setParameter(LOCAL_ADDRESS, local);
- }
-
-}
-
diff --git a/src/org/apache/http/conn/params/package.html b/src/org/apache/http/conn/params/package.html
deleted file mode 100644
index 9b80420f8adbad236359775337ed95ef1792059c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/params/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Parameters for configuring HttpConn.
-
-
-
diff --git a/src/org/apache/http/conn/routing/BasicRouteDirector.java b/src/org/apache/http/conn/routing/BasicRouteDirector.java
deleted file mode 100644
index a3714ec4895300d3f54a5c7bce9503cfa8fdca48..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/BasicRouteDirector.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java $
- * $Revision: 620255 $
- * $Date: 2008-02-10 02:23:55 -0800 (Sun, 10 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-
-
-/**
- * Basic implementation of an {@link HttpRouteDirector HttpRouteDirector}.
- * This implementation is stateless and therefore thread-safe.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 620255 $
- *
- * @since 4.0
- */
-public class BasicRouteDirector implements HttpRouteDirector {
-
- // public default constructor
-
-
- /**
- * Provides the next step.
- *
- * @param plan the planned route
- * @param fact the currently established route, or
- * null if nothing is established
- *
- * @return one of the constants defined in this class, indicating
- * either the next step to perform, or success, or failure.
- * 0 is for success, a negative value for failure.
- */
- public int nextStep(RouteInfo plan, RouteInfo fact) {
- if (plan == null) {
- throw new IllegalArgumentException
- ("Planned route may not be null.");
- }
-
- int step = UNREACHABLE;
-
- if ((fact == null) || (fact.getHopCount() < 1))
- step = firstStep(plan);
- else if (plan.getHopCount() > 1)
- step = proxiedStep(plan, fact);
- else
- step = directStep(plan, fact);
-
- return step;
-
- } // nextStep
-
-
- /**
- * Determines the first step to establish a route.
- *
- * @param plan the planned route
- *
- * @return the first step
- */
- protected int firstStep(RouteInfo plan) {
-
- return (plan.getHopCount() > 1) ?
- CONNECT_PROXY : CONNECT_TARGET;
- }
-
-
- /**
- * Determines the next step to establish a direct connection.
- *
- * @param plan the planned route
- * @param fact the currently established route
- *
- * @return one of the constants defined in this class, indicating
- * either the next step to perform, or success, or failure
- */
- protected int directStep(RouteInfo plan, RouteInfo fact) {
-
- if (fact.getHopCount() > 1)
- return UNREACHABLE;
- if (!plan.getTargetHost().equals(fact.getTargetHost()))
- return UNREACHABLE;
- // If the security is too low, we could now suggest to layer
- // a secure protocol on the direct connection. Layering on direct
- // connections has not been supported in HttpClient 3.x, we don't
- // consider it here until there is a real-life use case for it.
-
- // Should we tolerate if security is better than planned?
- // (plan.isSecure() && !fact.isSecure())
- if (plan.isSecure() != fact.isSecure())
- return UNREACHABLE;
-
- // Local address has to match only if the plan specifies one.
- if ((plan.getLocalAddress() != null) &&
- !plan.getLocalAddress().equals(fact.getLocalAddress())
- )
- return UNREACHABLE;
-
- return COMPLETE;
- }
-
-
- /**
- * Determines the next step to establish a connection via proxy.
- *
- * @param plan the planned route
- * @param fact the currently established route
- *
- * @return one of the constants defined in this class, indicating
- * either the next step to perform, or success, or failure
- */
- protected int proxiedStep(RouteInfo plan, RouteInfo fact) {
-
- if (fact.getHopCount() <= 1)
- return UNREACHABLE;
- if (!plan.getTargetHost().equals(fact.getTargetHost()))
- return UNREACHABLE;
- final int phc = plan.getHopCount();
- final int fhc = fact.getHopCount();
- if (phc < fhc)
- return UNREACHABLE;
-
- for (int i=0; i fhc)
- return TUNNEL_PROXY; // need to extend the proxy chain
-
- // proxy chain and target are the same, check tunnelling and layering
- if ((fact.isTunnelled() && !plan.isTunnelled()) ||
- (fact.isLayered() && !plan.isLayered()))
- return UNREACHABLE;
-
- if (plan.isTunnelled() && !fact.isTunnelled())
- return TUNNEL_TARGET;
- if (plan.isLayered() && !fact.isLayered())
- return LAYER_PROTOCOL;
-
- // tunnel and layering are the same, remains to check the security
- // Should we tolerate if security is better than planned?
- // (plan.isSecure() && !fact.isSecure())
- if (plan.isSecure() != fact.isSecure())
- return UNREACHABLE;
-
- return COMPLETE;
- }
-
-
-} // class BasicRouteDirector
diff --git a/src/org/apache/http/conn/routing/HttpRoute.java b/src/org/apache/http/conn/routing/HttpRoute.java
deleted file mode 100644
index 1e870b86462e4788b71defc24d3c2b06077fb7ad..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/HttpRoute.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-
-/**
- * The route for a request.
- * Instances of this class are unmodifiable and therefore suitable
- * for use as lookup keys.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 653041 $
- *
- * @since 4.0
- */
-public final class HttpRoute implements RouteInfo, Cloneable {
-
- /** The target host to connect to. */
- private final HttpHost targetHost;
-
- /**
- * The local address to connect from.
- * null indicates that the default should be used.
- */
- private final InetAddress localAddress;
-
- /** The proxy servers, if any. */
- private final HttpHost[] proxyChain;
-
- /** Whether the the route is tunnelled through the proxy. */
- private final TunnelType tunnelled;
-
- /** Whether the route is layered. */
- private final LayerType layered;
-
- /** Whether the route is (supposed to be) secure. */
- private final boolean secure;
-
-
- /**
- * Internal, fully-specified constructor.
- * This constructor does not clone the proxy chain array,
- * nor test it for null elements. This conversion and
- * check is the responsibility of the public constructors.
- * The order of arguments here is different from the similar public
- * constructor, as required by Java.
- *
- * @param local the local address to route from, or
- * null for the default
- * @param target the host to which to route
- * @param proxies the proxy chain to use, or
- * null for a direct route
- * @param secure true if the route is (to be) secure,
- * false otherwise
- * @param tunnelled the tunnel type of this route, or
- * null for PLAIN
- * @param layered the layering type of this route, or
- * null for PLAIN
- */
- private HttpRoute(InetAddress local,
- HttpHost target, HttpHost[] proxies,
- boolean secure,
- TunnelType tunnelled, LayerType layered) {
- if (target == null) {
- throw new IllegalArgumentException
- ("Target host may not be null.");
- }
- if ((tunnelled == TunnelType.TUNNELLED) && (proxies == null)) {
- throw new IllegalArgumentException
- ("Proxy required if tunnelled.");
- }
-
- // tunnelled is already checked above, that is in line with the default
- if (tunnelled == null)
- tunnelled = TunnelType.PLAIN;
- if (layered == null)
- layered = LayerType.PLAIN;
-
- this.targetHost = target;
- this.localAddress = local;
- this.proxyChain = proxies;
- this.secure = secure;
- this.tunnelled = tunnelled;
- this.layered = layered;
- }
-
-
- /**
- * Creates a new route with all attributes specified explicitly.
- *
- * @param target the host to which to route
- * @param local the local address to route from, or
- * null for the default
- * @param proxies the proxy chain to use, or
- * null for a direct route
- * @param secure true if the route is (to be) secure,
- * false otherwise
- * @param tunnelled the tunnel type of this route
- * @param layered the layering type of this route
- */
- public HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies,
- boolean secure, TunnelType tunnelled, LayerType layered) {
- this(local, target, toChain(proxies), secure, tunnelled, layered);
- }
-
-
- /**
- * Creates a new route with at most one proxy.
- *
- * @param target the host to which to route
- * @param local the local address to route from, or
- * null for the default
- * @param proxy the proxy to use, or
- * null for a direct route
- * @param secure true if the route is (to be) secure,
- * false otherwise
- * @param tunnelled true if the route is (to be) tunnelled
- * via the proxy,
- * false otherwise
- * @param layered true if the route includes a
- * layered protocol,
- * false otherwise
- */
- public HttpRoute(HttpHost target, InetAddress local, HttpHost proxy,
- boolean secure, TunnelType tunnelled, LayerType layered) {
- this(local, target, toChain(proxy), secure, tunnelled, layered);
- }
-
-
- /**
- * Creates a new direct route.
- * That is a route without a proxy.
- *
- * @param target the host to which to route
- * @param local the local address to route from, or
- * null for the default
- * @param secure true if the route is (to be) secure,
- * false otherwise
- */
- public HttpRoute(HttpHost target, InetAddress local, boolean secure) {
- this(local, target, null, secure, TunnelType.PLAIN, LayerType.PLAIN);
- }
-
-
- /**
- * Creates a new direct insecure route.
- *
- * @param target the host to which to route
- */
- public HttpRoute(HttpHost target) {
- this(null, target, null, false, TunnelType.PLAIN, LayerType.PLAIN);
- }
-
-
- /**
- * Creates a new route through a proxy.
- * When using this constructor, the proxy MUST be given.
- * For convenience, it is assumed that a secure connection will be
- * layered over a tunnel through the proxy.
- *
- * @param target the host to which to route
- * @param local the local address to route from, or
- * null for the default
- * @param proxy the proxy to use
- * @param secure true if the route is (to be) secure,
- * false otherwise
- */
- public HttpRoute(HttpHost target, InetAddress local, HttpHost proxy,
- boolean secure) {
- this(local, target, toChain(proxy), secure,
- secure ? TunnelType.TUNNELLED : TunnelType.PLAIN,
- secure ? LayerType.LAYERED : LayerType.PLAIN);
- if (proxy == null) {
- throw new IllegalArgumentException
- ("Proxy host may not be null.");
- }
- }
-
-
- /**
- * Helper to convert a proxy to a proxy chain.
- *
- * @param proxy the only proxy in the chain, or null
- *
- * @return a proxy chain array, or null
- */
- private static HttpHost[] toChain(HttpHost proxy) {
- if (proxy == null)
- return null;
-
- return new HttpHost[]{ proxy };
- }
-
-
- /**
- * Helper to duplicate and check a proxy chain.
- * An empty proxy chain is converted to null.
- *
- * @param proxies the proxy chain to duplicate, or null
- *
- * @return a new proxy chain array, or null
- */
- private static HttpHost[] toChain(HttpHost[] proxies) {
- if ((proxies == null) || (proxies.length < 1))
- return null;
-
- for (HttpHost proxy : proxies) {
- if (proxy == null)
- throw new IllegalArgumentException
- ("Proxy chain may not contain null elements.");
- }
-
- // copy the proxy chain, the traditional way
- HttpHost[] result = new HttpHost[proxies.length];
- System.arraycopy(proxies, 0, result, 0, proxies.length);
-
- return result;
- }
-
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getTargetHost() {
- return this.targetHost;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final InetAddress getLocalAddress() {
- return this.localAddress;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final int getHopCount() {
- return (proxyChain == null) ? 1 : (proxyChain.length+1);
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getHopTarget(int hop) {
- if (hop < 0)
- throw new IllegalArgumentException
- ("Hop index must not be negative: " + hop);
- final int hopcount = getHopCount();
- if (hop >= hopcount)
- throw new IllegalArgumentException
- ("Hop index " + hop +
- " exceeds route length " + hopcount);
-
- HttpHost result = null;
- if (hop < hopcount-1)
- result = this.proxyChain[hop];
- else
- result = this.targetHost;
-
- return result;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getProxyHost() {
- return (this.proxyChain == null) ? null : this.proxyChain[0];
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final TunnelType getTunnelType() {
- return this.tunnelled;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isTunnelled() {
- return (this.tunnelled == TunnelType.TUNNELLED);
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final LayerType getLayerType() {
- return this.layered;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isLayered() {
- return (this.layered == LayerType.LAYERED);
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isSecure() {
- return this.secure;
- }
-
-
- /**
- * Compares this route to another.
- *
- * @param o the object to compare with
- *
- * @return true if the argument is the same route,
- * false
- */
- @Override
- public final boolean equals(Object o) {
- if (o == this)
- return true;
- if (!(o instanceof HttpRoute))
- return false;
-
- HttpRoute that = (HttpRoute) o;
- boolean equal = this.targetHost.equals(that.targetHost);
- equal &=
- ( this.localAddress == that.localAddress) ||
- ((this.localAddress != null) &&
- this.localAddress.equals(that.localAddress));
- equal &=
- ( this.proxyChain == that.proxyChain) ||
- ((this.proxyChain != null) &&
- (that.proxyChain != null) &&
- (this.proxyChain.length == that.proxyChain.length));
- // comparison of actual proxies follows below
- equal &=
- (this.secure == that.secure) &&
- (this.tunnelled == that.tunnelled) &&
- (this.layered == that.layered);
-
- // chain length has been compared above, now check the proxies
- if (equal && (this.proxyChain != null)) {
- for (int i=0; equal && (i");
- }
- cab.append('{');
- if (this.tunnelled == TunnelType.TUNNELLED)
- cab.append('t');
- if (this.layered == LayerType.LAYERED)
- cab.append('l');
- if (this.secure)
- cab.append('s');
- cab.append("}->");
- if (this.proxyChain != null) {
- for (HttpHost aProxyChain : this.proxyChain) {
- cab.append(aProxyChain);
- cab.append("->");
- }
- }
- cab.append(this.targetHost);
- cab.append(']');
-
- return cab.toString();
- }
-
-
- // default implementation of clone() is sufficient
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-
-} // class HttpRoute
diff --git a/src/org/apache/http/conn/routing/HttpRouteDirector.java b/src/org/apache/http/conn/routing/HttpRouteDirector.java
deleted file mode 100644
index 8cfcf67dc065920f934bea1caf0936556afbf723..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/HttpRouteDirector.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRouteDirector.java $
- * $Revision: 620255 $
- * $Date: 2008-02-10 02:23:55 -0800 (Sun, 10 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-
-
-/**
- * Provides directions on establishing a route.
- * Implementations of this interface compare a planned route with
- * a tracked route and indicate the next step required.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 620255 $
- *
- * @since 4.0
- */
-public interface HttpRouteDirector {
-
- /** Indicates that the route can not be established at all. */
- public final static int UNREACHABLE = -1;
-
- /** Indicates that the route is complete. */
- public final static int COMPLETE = 0;
-
- /** Step: open connection to target. */
- public final static int CONNECT_TARGET = 1;
-
- /** Step: open connection to proxy. */
- public final static int CONNECT_PROXY = 2;
-
- /** Step: tunnel through proxy to target. */
- public final static int TUNNEL_TARGET = 3;
-
- /** Step: tunnel through proxy to other proxy. */
- public final static int TUNNEL_PROXY = 4;
-
- /** Step: layer protocol (over tunnel). */
- public final static int LAYER_PROTOCOL = 5;
-
-
- /**
- * Provides the next step.
- *
- * @param plan the planned route
- * @param fact the currently established route, or
- * null if nothing is established
- *
- * @return one of the constants defined in this interface, indicating
- * either the next step to perform, or success, or failure.
- * 0 is for success, a negative value for failure.
- */
- public int nextStep(RouteInfo plan, RouteInfo fact)
- ;
-
-
-} // interface HttpRouteDirector
diff --git a/src/org/apache/http/conn/routing/HttpRoutePlanner.java b/src/org/apache/http/conn/routing/HttpRoutePlanner.java
deleted file mode 100644
index 489702ab6ac641979c6046467e15c8ef01bc11ce..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/HttpRoutePlanner.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/HttpRoutePlanner.java $
- * $Revision: 613654 $
- * $Date: 2008-01-20 11:00:19 -0800 (Sun, 20 Jan 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
-
-
-
-/**
- * Encapsulates logic to compute a {@link HttpRoute} to a target host.
- * Implementations may for example be based on parameters, or on the
- * standard Java system properties.
- */
-public interface HttpRoutePlanner {
-
- /**
- * Determines the route for a request.
- *
- * @param target the target host for the request.
- * Implementations may accept null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param context the context to use for the subsequent execution.
- * Implementations may accept null.
- *
- * @return the route that the request should take
- *
- * @throws HttpException in case of a problem
- */
- public HttpRoute determineRoute(HttpHost target,
- HttpRequest request,
- HttpContext context)
- throws HttpException
- ;
-
-}
diff --git a/src/org/apache/http/conn/routing/RouteInfo.java b/src/org/apache/http/conn/routing/RouteInfo.java
deleted file mode 100644
index 3449cb1d222411dbdb96915d4edfca545a11866c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/RouteInfo.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java $
- * $Revision: 652200 $
- * $Date: 2008-04-29 17:22:43 -0700 (Tue, 29 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-
-
-/**
- * Read-only interface for route information.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 652200 $
- *
- * @since 4.0
- */
-public interface RouteInfo {
-
- /**
- * The tunnelling type of a route.
- * Plain routes are established by connecting to the target or
- * the first proxy.
- * Tunnelled routes are established by connecting to the first proxy
- * and tunnelling through all proxies to the target.
- * Routes without a proxy cannot be tunnelled.
- */
- public enum TunnelType { PLAIN, TUNNELLED }
-
- /**
- * The layering type of a route.
- * Plain routes are established by connecting or tunnelling.
- * Layered routes are established by layering a protocol such as TLS/SSL
- * over an existing connection.
- * Protocols can only be layered over a tunnel to the target, or
- * or over a direct connection without proxies.
- *
- * Layering a protocol
- * over a direct connection makes little sense, since the connection
- * could be established with the new protocol in the first place.
- * But we don't want to exclude that use case.
- */
- public enum LayerType { PLAIN, LAYERED }
-
-
-
- /**
- * Obtains the target host.
- *
- * @return the target host
- */
- HttpHost getTargetHost()
- ;
-
-
- /**
- * Obtains the local address to connect from.
- *
- * @return the local address,
- * or null
- */
- InetAddress getLocalAddress()
- ;
-
-
- /**
- * Obtains the number of hops in this route.
- * A direct route has one hop. A route through a proxy has two hops.
- * A route through a chain of n proxies has n+1 hops.
- *
- * @return the number of hops in this route
- */
- int getHopCount()
- ;
-
-
- /**
- * Obtains the target of a hop in this route.
- * The target of the last hop is the {@link #getTargetHost target host},
- * the target of previous hops is the respective proxy in the chain.
- * For a route through exactly one proxy, target of hop 0 is the proxy
- * and target of hop 1 is the target host.
- *
- * @param hop index of the hop for which to get the target,
- * 0 for first
- *
- * @return the target of the given hop
- *
- * @throws IllegalArgumentException
- * if the argument is negative or not less than
- * {@link #getHopCount getHopCount()}
- */
- HttpHost getHopTarget(int hop)
- ;
-
-
- /**
- * Obtains the first proxy host.
- *
- * @return the first proxy in the proxy chain, or
- * null if this route is direct
- */
- HttpHost getProxyHost()
- ;
-
-
- /**
- * Obtains the tunnel type of this route.
- * If there is a proxy chain, only end-to-end tunnels are considered.
- *
- * @return the tunnelling type
- */
- TunnelType getTunnelType()
- ;
-
-
- /**
- * Checks whether this route is tunnelled through a proxy.
- * If there is a proxy chain, only end-to-end tunnels are considered.
- *
- * @return true if tunnelled end-to-end through at least
- * one proxy,
- * false otherwise
- */
- boolean isTunnelled()
- ;
-
-
- /**
- * Obtains the layering type of this route.
- * In the presence of proxies, only layering over an end-to-end tunnel
- * is considered.
- *
- * @return the layering type
- */
- LayerType getLayerType()
- ;
-
-
- /**
- * Checks whether this route includes a layered protocol.
- * In the presence of proxies, only layering over an end-to-end tunnel
- * is considered.
- *
- * @return true if layered,
- * false otherwise
- */
- boolean isLayered()
- ;
-
-
- /**
- * Checks whether this route is secure.
- *
- * @return true if secure,
- * false otherwise
- */
- boolean isSecure()
- ;
-
-
-} // interface RouteInfo
diff --git a/src/org/apache/http/conn/routing/RouteTracker.java b/src/org/apache/http/conn/routing/RouteTracker.java
deleted file mode 100644
index ba8213e7e6ef902e70d4c4cb3fdd28cb3750d7f9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/RouteTracker.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteTracker.java $
- * $Revision: 620254 $
- * $Date: 2008-02-10 02:18:48 -0800 (Sun, 10 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.routing;
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-
-
-/**
- * Helps tracking the steps in establishing a route.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 620254 $
- *
- * @since 4.0
- */
-public final class RouteTracker implements RouteInfo, Cloneable {
-
- /** The target host to connect to. */
- private final HttpHost targetHost;
-
- /**
- * The local address to connect from.
- * null indicates that the default should be used.
- */
- private final InetAddress localAddress;
-
- // the attributes above are fixed at construction time
- // now follow attributes that indicate the established route
-
- /** Whether the first hop of the route is established. */
- private boolean connected;
-
- /** The proxy chain, if any. */
- private HttpHost[] proxyChain;
-
- /** Whether the the route is tunnelled end-to-end through proxies. */
- private TunnelType tunnelled;
-
- /** Whether the route is layered over a tunnel. */
- private LayerType layered;
-
- /** Whether the route is secure. */
- private boolean secure;
-
-
- /**
- * Creates a new route tracker.
- * The target and origin need to be specified at creation time.
- *
- * @param target the host to which to route
- * @param local the local address to route from, or
- * null for the default
- */
- public RouteTracker(HttpHost target, InetAddress local) {
- if (target == null) {
- throw new IllegalArgumentException("Target host may not be null.");
- }
- this.targetHost = target;
- this.localAddress = local;
- this.tunnelled = TunnelType.PLAIN;
- this.layered = LayerType.PLAIN;
- }
-
-
- /**
- * Creates a new tracker for the given route.
- * Only target and origin are taken from the route,
- * everything else remains to be tracked.
- *
- * @param route the route to track
- */
- public RouteTracker(HttpRoute route) {
- this(route.getTargetHost(), route.getLocalAddress());
- }
-
-
- /**
- * Tracks connecting to the target.
- *
- * @param secure true if the route is secure,
- * false otherwise
- */
- public final void connectTarget(boolean secure) {
- if (this.connected) {
- throw new IllegalStateException("Already connected.");
- }
- this.connected = true;
- this.secure = secure;
- }
-
-
- /**
- * Tracks connecting to the first proxy.
- *
- * @param proxy the proxy connected to
- * @param secure true if the route is secure,
- * false otherwise
- */
- public final void connectProxy(HttpHost proxy, boolean secure) {
- if (proxy == null) {
- throw new IllegalArgumentException("Proxy host may not be null.");
- }
- if (this.connected) {
- throw new IllegalStateException("Already connected.");
- }
- this.connected = true;
- this.proxyChain = new HttpHost[]{ proxy };
- this.secure = secure;
- }
-
-
- /**
- * Tracks tunnelling to the target.
- *
- * @param secure true if the route is secure,
- * false otherwise
- */
- public final void tunnelTarget(boolean secure) {
- if (!this.connected) {
- throw new IllegalStateException("No tunnel unless connected.");
- }
- if (this.proxyChain == null) {
- throw new IllegalStateException("No tunnel without proxy.");
- }
- this.tunnelled = TunnelType.TUNNELLED;
- this.secure = secure;
- }
-
-
- /**
- * Tracks tunnelling to a proxy in a proxy chain.
- * This will extend the tracked proxy chain, but it does not mark
- * the route as tunnelled. Only end-to-end tunnels are considered there.
- *
- * @param proxy the proxy tunnelled to
- * @param secure true if the route is secure,
- * false otherwise
- */
- public final void tunnelProxy(HttpHost proxy, boolean secure) {
- if (proxy == null) {
- throw new IllegalArgumentException("Proxy host may not be null.");
- }
- if (!this.connected) {
- throw new IllegalStateException("No tunnel unless connected.");
- }
- if (this.proxyChain == null) {
- throw new IllegalStateException("No proxy tunnel without proxy.");
- }
-
- // prepare an extended proxy chain
- HttpHost[] proxies = new HttpHost[this.proxyChain.length+1];
- System.arraycopy(this.proxyChain, 0,
- proxies, 0, this.proxyChain.length);
- proxies[proxies.length-1] = proxy;
-
- this.proxyChain = proxies;
- this.secure = secure;
- }
-
-
- /**
- * Tracks layering a protocol.
- *
- * @param secure true if the route is secure,
- * false otherwise
- */
- public final void layerProtocol(boolean secure) {
- // it is possible to layer a protocol over a direct connection,
- // although this case is probably not considered elsewhere
- if (!this.connected) {
- throw new IllegalStateException
- ("No layered protocol unless connected.");
- }
- this.layered = LayerType.LAYERED;
- this.secure = secure;
- }
-
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getTargetHost() {
- return this.targetHost;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final InetAddress getLocalAddress() {
- return this.localAddress;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final int getHopCount() {
- int hops = 0;
- if (this.connected) {
- if (proxyChain == null)
- hops = 1;
- else
- hops = proxyChain.length + 1;
- }
- return hops;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getHopTarget(int hop) {
- if (hop < 0)
- throw new IllegalArgumentException
- ("Hop index must not be negative: " + hop);
- final int hopcount = getHopCount();
- if (hop >= hopcount) {
- throw new IllegalArgumentException
- ("Hop index " + hop +
- " exceeds tracked route length " + hopcount +".");
- }
-
- HttpHost result = null;
- if (hop < hopcount-1)
- result = this.proxyChain[hop];
- else
- result = this.targetHost;
-
- return result;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final HttpHost getProxyHost() {
- return (this.proxyChain == null) ? null : this.proxyChain[0];
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isConnected() {
- return this.connected;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final TunnelType getTunnelType() {
- return this.tunnelled;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isTunnelled() {
- return (this.tunnelled == TunnelType.TUNNELLED);
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final LayerType getLayerType() {
- return this.layered;
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isLayered() {
- return (this.layered == LayerType.LAYERED);
- }
-
-
- // non-JavaDoc, see interface RouteInfo
- public final boolean isSecure() {
- return this.secure;
- }
-
-
- /**
- * Obtains the tracked route.
- * If a route has been tracked, it is {@link #isConnected connected}.
- * If not connected, nothing has been tracked so far.
- *
- * @return the tracked route, or
- * null if nothing has been tracked so far
- */
- public final HttpRoute toRoute() {
- return !this.connected ?
- null : new HttpRoute(this.targetHost, this.localAddress,
- this.proxyChain, this.secure,
- this.tunnelled, this.layered);
- }
-
-
- /**
- * Compares this tracked route to another.
- *
- * @param o the object to compare with
- *
- * @return true if the argument is the same tracked route,
- * false
- */
- @Override
- public final boolean equals(Object o) {
- if (o == this)
- return true;
- if (!(o instanceof RouteTracker))
- return false;
-
- RouteTracker that = (RouteTracker) o;
- boolean equal = this.targetHost.equals(that.targetHost);
- equal &=
- ( this.localAddress == that.localAddress) ||
- ((this.localAddress != null) &&
- this.localAddress.equals(that.localAddress));
- equal &=
- ( this.proxyChain == that.proxyChain) ||
- ((this.proxyChain != null) &&
- (that.proxyChain != null) &&
- (this.proxyChain.length == that.proxyChain.length));
- // comparison of actual proxies follows below
- equal &=
- (this.connected == that.connected) &&
- (this.secure == that.secure) &&
- (this.tunnelled == that.tunnelled) &&
- (this.layered == that.layered);
-
- // chain length has been compared above, now check the proxies
- if (equal && (this.proxyChain != null)) {
- for (int i=0; equal && (i");
- }
- cab.append('{');
- if (this.connected)
- cab.append('c');
- if (this.tunnelled == TunnelType.TUNNELLED)
- cab.append('t');
- if (this.layered == LayerType.LAYERED)
- cab.append('l');
- if (this.secure)
- cab.append('s');
- cab.append("}->");
- if (this.proxyChain != null) {
- for (int i=0; i");
- }
- }
- cab.append(this.targetHost);
- cab.append(']');
-
- return cab.toString();
- }
-
-
- // default implementation of clone() is sufficient
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-
-} // class RouteTracker
diff --git a/src/org/apache/http/conn/routing/package.html b/src/org/apache/http/conn/routing/package.html
deleted file mode 100644
index b50f97cd56f3dad77fb23a31f2f6e4192dbfa89a..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/routing/package.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-The client-side route representation and tracking API, part of HttpConn.
-
-
-An {@link org.apache.http.conn.routing.HttpRoute HttpRoute}
-is the path along which a request has to be sent to the server.
-The route starts at a local network address and may pass
-through one or more proxies before reaching the target.
-Routes through proxies can be tunnelled, and a layered protocol (TLS/SSL)
-might be put on top of the tunnel.
-The {@link org.apache.http.conn.routing.RouteTracker RouteTracker}
-helps in tracking the steps for establishing a route, while an
-{@link org.apache.http.conn.routing.HttpRouteDirector HttpRouteDirector}
-determines the next step to take.
-
-
-
-
-The {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
-is responsible for determining a route to a given target host.
-Implementations must know about proxies to use, and about exemptions
-for hosts that should be contacted directly without a proxy.
-
-
-
-
-
diff --git a/src/org/apache/http/conn/scheme/HostNameResolver.java b/src/org/apache/http/conn/scheme/HostNameResolver.java
deleted file mode 100644
index ca6615cf64e260a33b3ed3e7960506d347cb0d53..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/HostNameResolver.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.scheme;
-
-import java.io.IOException;
-import java.net.InetAddress;
-
-public interface HostNameResolver {
-
- InetAddress resolve (String hostname) throws IOException;
-
-}
diff --git a/src/org/apache/http/conn/scheme/LayeredSocketFactory.java b/src/org/apache/http/conn/scheme/LayeredSocketFactory.java
deleted file mode 100644
index 8dc6c6c99a6144f2f999086a1c93838496c9fcb5..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/LayeredSocketFactory.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/LayeredSocketFactory.java $
- * $Revision: 645850 $
- * $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.scheme;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-/**
- * A {@link SocketFactory SocketFactory} for layered sockets (SSL/TLS).
- * See there for things to consider when implementing a socket factory.
- *
- * @author Michael Becke
- * @author Mike Bowler
- * @since 4.0
- */
-public interface LayeredSocketFactory extends SocketFactory {
-
- /**
- * Returns a socket connected to the given host that is layered over an
- * existing socket. Used primarily for creating secure sockets through
- * proxies.
- *
- * @param socket the existing socket
- * @param host the host name/IP
- * @param port the port on the host
- * @param autoClose a flag for closing the underling socket when the created
- * socket is closed
- *
- * @return Socket a new socket
- *
- * @throws IOException if an I/O error occurs while creating the socket
- * @throws UnknownHostException if the IP address of the host cannot be
- * determined
- */
- Socket createSocket(
- Socket socket,
- String host,
- int port,
- boolean autoClose
- ) throws IOException, UnknownHostException;
-
-}
diff --git a/src/org/apache/http/conn/scheme/PlainSocketFactory.java b/src/org/apache/http/conn/scheme/PlainSocketFactory.java
deleted file mode 100644
index acc13f7de75d2d5693dfdedac54f55b86d3c76b1..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/PlainSocketFactory.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java $
- * $Revision: 659194 $
- * $Date: 2008-05-22 11:33:47 -0700 (Thu, 22 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.scheme;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * The default class for creating sockets.
- *
- * @author Roland Weber
- * @author Michael Becke
- */
-public final class PlainSocketFactory implements SocketFactory {
-
- /**
- * The factory singleton.
- */
- private static final
- PlainSocketFactory DEFAULT_FACTORY = new PlainSocketFactory();
-
- private final HostNameResolver nameResolver;
-
- /**
- * Gets the singleton instance of this class.
- * @return the one and only plain socket factory
- */
- public static PlainSocketFactory getSocketFactory() {
- return DEFAULT_FACTORY;
- }
-
- public PlainSocketFactory(final HostNameResolver nameResolver) {
- super();
- this.nameResolver = nameResolver;
- }
-
-
- public PlainSocketFactory() {
- this(null);
- }
-
- // non-javadoc, see interface org.apache.http.conn.SocketFactory
- public Socket createSocket() {
- return new Socket();
- }
-
- // non-javadoc, see interface org.apache.http.conn.SocketFactory
- public Socket connectSocket(Socket sock, String host, int port,
- InetAddress localAddress, int localPort,
- HttpParams params)
- throws IOException {
-
- if (host == null) {
- throw new IllegalArgumentException("Target host may not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null.");
- }
-
- if (sock == null)
- sock = createSocket();
-
- if ((localAddress != null) || (localPort > 0)) {
-
- // we need to bind explicitly
- if (localPort < 0)
- localPort = 0; // indicates "any"
-
- InetSocketAddress isa =
- new InetSocketAddress(localAddress, localPort);
- sock.bind(isa);
- }
-
- int timeout = HttpConnectionParams.getConnectionTimeout(params);
-
- InetSocketAddress remoteAddress;
- if (this.nameResolver != null) {
- remoteAddress = new InetSocketAddress(this.nameResolver.resolve(host), port);
- } else {
- remoteAddress = new InetSocketAddress(host, port);
- }
-
- sock.connect(remoteAddress, timeout);
-
- return sock;
-
- } // connectSocket
-
-
- /**
- * Checks whether a socket connection is secure.
- * This factory creates plain socket connections
- * which are not considered secure.
- *
- * @param sock the connected socket
- *
- * @return false
- *
- * @throws IllegalArgumentException if the argument is invalid
- */
- public final boolean isSecure(Socket sock)
- throws IllegalArgumentException {
-
- if (sock == null) {
- throw new IllegalArgumentException("Socket may not be null.");
- }
- // This class check assumes that createSocket() calls the constructor
- // directly. If it was using javax.net.SocketFactory, we couldn't make
- // an assumption about the socket class here.
- if (sock.getClass() != Socket.class) {
- throw new IllegalArgumentException
- ("Socket not created by this factory.");
- }
- // This check is performed last since it calls a method implemented
- // by the argument object. getClass() is final in java.lang.Object.
- if (sock.isClosed()) {
- throw new IllegalArgumentException("Socket is closed.");
- }
-
- return false;
-
- } // isSecure
-
-
- /**
- * Compares this factory with an object.
- * There is only one instance of this class.
- *
- * @param obj the object to compare with
- *
- * @return iff the argument is this object
- */
- @Override
- public boolean equals(Object obj) {
- return (obj == this);
- }
-
- /**
- * Obtains a hash code for this object.
- * All instances of this class have the same hash code.
- * There is only one instance of this class.
- */
- @Override
- public int hashCode() {
- return PlainSocketFactory.class.hashCode();
- }
-
-}
diff --git a/src/org/apache/http/conn/scheme/Scheme.java b/src/org/apache/http/conn/scheme/Scheme.java
deleted file mode 100644
index 590d59d437c4e1b2a306ead70e8a5ad9d0186e7e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/Scheme.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java $
- * $Revision: 652950 $
- * $Date: 2008-05-02 16:49:48 -0700 (Fri, 02 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.scheme;
-
-import java.util.Locale;
-
-import org.apache.http.util.LangUtils;
-
-/**
- * Encapsulates specifics of a protocol scheme such as "http" or "https".
- * Schemes are identified by lowercase names.
- * Supported schemes are typically collected in a
- * {@link SchemeRegistry SchemeRegistry}.
- *
- *
- * For example, to configure support for "https://" URLs,
- * you could write code like the following:
- *
- *
- * Scheme https = new Scheme("https", new MySecureSocketFactory(), 443);
- * SchemeRegistry.DEFAULT.register(https);
- *
- *
- * @author Roland Weber
- * @author Michael Becke
- * @author Jeff Dever
- * @author Mike Bowler
- */
-public final class Scheme {
-
- /** The name of this scheme, in lowercase. (e.g. http, https) */
- private final String name;
-
- /** The socket factory for this scheme */
- private final SocketFactory socketFactory;
-
- /** The default port for this scheme */
- private final int defaultPort;
-
- /** Indicates whether this scheme allows for layered connections */
- private final boolean layered;
-
-
- /** A string representation, for {@link #toString toString}. */
- private String stringRep;
-
-
- /**
- * Creates a new scheme.
- * Whether the created scheme allows for layered connections
- * depends on the class of factory.
- *
- * @param name the scheme name, for example "http".
- * The name will be converted to lowercase.
- * @param factory the factory for creating sockets for communication
- * with this scheme
- * @param port the default port for this scheme
- */
- public Scheme(final String name,
- final SocketFactory factory,
- final int port) {
-
- if (name == null) {
- throw new IllegalArgumentException
- ("Scheme name may not be null");
- }
- if (factory == null) {
- throw new IllegalArgumentException
- ("Socket factory may not be null");
- }
- if ((port <= 0) || (port > 0xffff)) {
- throw new IllegalArgumentException
- ("Port is invalid: " + port);
- }
-
- this.name = name.toLowerCase(Locale.ENGLISH);
- this.socketFactory = factory;
- this.defaultPort = port;
- this.layered = (factory instanceof LayeredSocketFactory);
- }
-
-
- /**
- * Obtains the default port.
- *
- * @return the default port for this scheme
- */
- public final int getDefaultPort() {
- return defaultPort;
- }
-
-
- /**
- * Obtains the socket factory.
- * If this scheme is {@link #isLayered layered}, the factory implements
- * {@link LayeredSocketFactory LayeredSocketFactory}.
- *
- * @return the socket factory for this scheme
- */
- public final SocketFactory getSocketFactory() {
- return socketFactory;
- }
-
-
- /**
- * Obtains the scheme name.
- *
- * @return the name of this scheme, in lowercase
- */
- public final String getName() {
- return name;
- }
-
-
- /**
- * Indicates whether this scheme allows for layered connections.
- *
- * @return true if layered connections are possible,
- * false otherwise
- */
- public final boolean isLayered() {
- return layered;
- }
-
-
- /**
- * Resolves the correct port for this scheme.
- * Returns the given port if it is valid, the default port otherwise.
- *
- * @param port the port to be resolved,
- * a negative number to obtain the default port
- *
- * @return the given port or the defaultPort
- */
- public final int resolvePort(int port) {
- return ((port <= 0) || (port > 0xffff)) ? defaultPort : port;
- }
-
-
- /**
- * Return a string representation of this object.
- *
- * @return a human-readable string description of this scheme
- */
- @Override
- public final String toString() {
- if (stringRep == null) {
- StringBuilder buffer = new StringBuilder();
- buffer.append(this.name);
- buffer.append(':');
- buffer.append(Integer.toString(this.defaultPort));
- stringRep = buffer.toString();
- }
- return stringRep;
- }
-
-
- /**
- * Compares this scheme to an object.
- *
- * @param obj the object to compare with
- *
- * @return true iff the argument is equal to this scheme
- */
- @Override
- public final boolean equals(Object obj) {
- if (obj == null) return false;
- if (this == obj) return true;
- if (!(obj instanceof Scheme)) return false;
-
- Scheme s = (Scheme) obj;
- return (name.equals(s.name) &&
- defaultPort == s.defaultPort &&
- layered == s.layered &&
- socketFactory.equals(s.socketFactory)
- );
- } // equals
-
-
- /**
- * Obtains a hash code for this scheme.
- *
- * @return the hash code
- */
- @Override
- public int hashCode() {
- int hash = LangUtils.HASH_SEED;
- hash = LangUtils.hashCode(hash, this.defaultPort);
- hash = LangUtils.hashCode(hash, this.name);
- hash = LangUtils.hashCode(hash, this.layered);
- hash = LangUtils.hashCode(hash, this.socketFactory);
- return hash;
- }
-
-} // class Scheme
diff --git a/src/org/apache/http/conn/scheme/SchemeRegistry.java b/src/org/apache/http/conn/scheme/SchemeRegistry.java
deleted file mode 100644
index 2ee8685a1dd654af045d590e52334a055f659661..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/SchemeRegistry.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java $
- * $Revision: 648356 $
- * $Date: 2008-04-15 10:57:53 -0700 (Tue, 15 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.scheme;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.http.HttpHost;
-
-/**
- * A set of supported protocol {@link Scheme schemes}.
- * Schemes are identified by lowercase names.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 648356 $ $Date: 2008-04-15 10:57:53 -0700 (Tue, 15 Apr 2008) $
- *
- * @since 4.0
- */
-public final class SchemeRegistry {
-
- /** The available schemes in this registry. */
- private final Map registeredSchemes;
-
-
- /**
- * Creates a new, empty scheme registry.
- */
- public SchemeRegistry() {
- super();
- registeredSchemes = new LinkedHashMap();
- }
-
-
- /**
- * Obtains a scheme by name.
- *
- * @param name the name of the scheme to look up (in lowercase)
- *
- * @return the scheme, never null
- *
- * @throws IllegalStateException
- * if the scheme with the given name is not registered
- */
- public synchronized final Scheme getScheme(String name) {
- Scheme found = get(name);
- if (found == null) {
- throw new IllegalStateException
- ("Scheme '"+name+"' not registered.");
- }
- return found;
- }
-
-
- /**
- * Obtains the scheme for a host.
- * Convenience method for getScheme(host.getSchemeName())
- *
- * @param host the host for which to obtain the scheme
- *
- * @return the scheme for the given host, never null
- *
- * @throws IllegalStateException
- * if a scheme with the respective name is not registered
- */
- public synchronized final Scheme getScheme(HttpHost host) {
- if (host == null) {
- throw new IllegalArgumentException("Host must not be null.");
- }
- return getScheme(host.getSchemeName());
- }
-
-
- /**
- * Obtains a scheme by name, if registered.
- *
- * @param name the name of the scheme to look up (in lowercase)
- *
- * @return the scheme, or
- * null if there is none by this name
- */
- public synchronized final Scheme get(String name) {
- if (name == null)
- throw new IllegalArgumentException("Name must not be null.");
-
- // leave it to the caller to use the correct name - all lowercase
- //name = name.toLowerCase();
- Scheme found = registeredSchemes.get(name);
- return found;
- }
-
-
- /**
- * Registers a scheme.
- * The scheme can later be retrieved by its name
- * using {@link #getScheme(String) getScheme} or {@link #get get}.
- *
- * @param sch the scheme to register
- *
- * @return the scheme previously registered with that name, or
- * null if none was registered
- */
- public synchronized final Scheme register(Scheme sch) {
- if (sch == null)
- throw new IllegalArgumentException("Scheme must not be null.");
-
- Scheme old = registeredSchemes.put(sch.getName(), sch);
- return old;
- }
-
-
- /**
- * Unregisters a scheme.
- *
- * @param name the name of the scheme to unregister (in lowercase)
- *
- * @return the unregistered scheme, or
- * null if there was none
- */
- public synchronized final Scheme unregister(String name) {
- if (name == null)
- throw new IllegalArgumentException("Name must not be null.");
-
- // leave it to the caller to use the correct name - all lowercase
- //name = name.toLowerCase();
- Scheme gone = registeredSchemes.remove(name);
- return gone;
- }
-
-
- /**
- * Obtains the names of the registered schemes in their default order.
- *
- * @return List containing registered scheme names.
- */
- public synchronized final List getSchemeNames() {
- return new ArrayList(registeredSchemes.keySet());
- }
-
- /**
- * Populates the internal collection of registered {@link Scheme protocol schemes}
- * with the content of the map passed as a parameter.
- *
- * @param map protocol schemes
- */
- public synchronized void setItems(final Map map) {
- if (map == null) {
- return;
- }
- registeredSchemes.clear();
- registeredSchemes.putAll(map);
- }
-
-} // class SchemeRegistry
-
diff --git a/src/org/apache/http/conn/scheme/SocketFactory.java b/src/org/apache/http/conn/scheme/SocketFactory.java
deleted file mode 100644
index bb553b29343ff39e24a695708ec61fb8e2ea7c2a..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/scheme/SocketFactory.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/scheme/SocketFactory.java $
- * $Revision: 645850 $
- * $Date: 2008-04-08 04:08:52 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.scheme;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-import org.apache.http.conn.ConnectTimeoutException;
-import org.apache.http.params.HttpParams;
-
-/**
- * A factory for creating and connecting sockets.
- * The factory encapsulates the logic for establishing a socket connection.
- *
- * Both {@link java.lang.Object#equals(java.lang.Object) Object.equals()}
- * and {@link java.lang.Object#hashCode() Object.hashCode()}
- * must be overridden for the correct operation of some connection managers.
- *
- * @author Roland Weber
- * @author Michael Becke
- * @author Mike Bowler
- */
-public interface SocketFactory {
-
- /**
- * Creates a new, unconnected socket.
- * The socket should subsequently be passed to
- * {@link #connectSocket connectSocket}.
- *
- * @return a new socket
- *
- * @throws IOException if an I/O error occurs while creating the socket
- */
- Socket createSocket()
- throws IOException
- ;
-
-
- /**
- * Connects a socket to the given host.
- *
- * @param sock the socket to connect, as obtained from
- * {@link #createSocket createSocket}.
- * null indicates that a new socket
- * should be created and connected.
- * @param host the host to connect to
- * @param port the port to connect to on the host
- * @param localAddress the local address to bind the socket to, or
- * null for any
- * @param localPort the port on the local machine,
- * 0 or a negative number for any
- * @param params additional {@link HttpParams parameters} for connecting
- *
- * @return the connected socket. The returned object may be different
- * from the sock argument if this factory supports
- * a layered protocol.
- *
- * @throws IOException if an I/O error occurs
- * @throws UnknownHostException if the IP address of the target host
- * can not be determined
- * @throws ConnectTimeoutException if the socket cannot be connected
- * within the time limit defined in the params
- */
- Socket connectSocket(
- Socket sock,
- String host,
- int port,
- InetAddress localAddress,
- int localPort,
- HttpParams params
- ) throws IOException, UnknownHostException, ConnectTimeoutException;
-
-
- /**
- * Checks whether a socket provides a secure connection.
- * The socket must be {@link #connectSocket connected}
- * by this factory.
- * The factory will not perform I/O operations
- * in this method.
- *
- * As a rule of thumb, plain sockets are not secure and
- * TLS/SSL sockets are secure. However, there may be
- * application specific deviations. For example, a plain
- * socket to a host in the same intranet ("trusted zone")
- * could be considered secure. On the other hand, a
- * TLS/SSL socket could be considered insecure based on
- * the cypher suite chosen for the connection.
- *
- * @param sock the connected socket to check
- *
- * @return true if the connection of the socket
- * should be considered secure, or
- * false if it should not
- *
- * @throws IllegalArgumentException
- * if the argument is invalid, for example because it is
- * not a connected socket or was created by a different
- * socket factory.
- * Note that socket factories are not required to
- * check these conditions, they may simply return a default
- * value when called with an invalid socket argument.
- */
- boolean isSecure(Socket sock)
- throws IllegalArgumentException
- ;
-
-}
diff --git a/src/org/apache/http/conn/ssl/AbstractVerifier.java b/src/org/apache/http/conn/ssl/AbstractVerifier.java
deleted file mode 100644
index 5195e5862ce02dbe1a0d40f9f61c6efe7f2af923..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/AbstractVerifier.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import org.apache.http.conn.util.InetAddressUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.StringTokenizer;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-/**
- * Abstract base class for all standard {@link X509HostnameVerifier}
- * implementations.
- *
- * @author Julius Davies
- */
-public abstract class AbstractVerifier implements X509HostnameVerifier {
-
- /**
- * This contains a list of 2nd-level domains that aren't allowed to
- * have wildcards when combined with country-codes.
- * For example: [*.co.uk].
- *
- * The [*.co.uk] problem is an interesting one. Should we just hope
- * that CA's would never foolishly allow such a certificate to happen?
- * Looks like we're the only implementation guarding against this.
- * Firefox, Curl, Sun Java 1.4, 5, 6 don't bother with this check.
- */
- private final static String[] BAD_COUNTRY_2LDS =
- { "ac", "co", "com", "ed", "edu", "go", "gouv", "gov", "info",
- "lg", "ne", "net", "or", "org" };
-
- static {
- // Just in case developer forgot to manually sort the array. :-)
- Arrays.sort(BAD_COUNTRY_2LDS);
- }
-
- public AbstractVerifier() {
- super();
- }
-
- public final void verify(String host, SSLSocket ssl)
- throws IOException {
- if(host == null) {
- throw new NullPointerException("host to verify is null");
- }
-
- ssl.startHandshake();
- SSLSession session = ssl.getSession();
- if(session == null) {
- // In our experience this only happens under IBM 1.4.x when
- // spurious (unrelated) certificates show up in the server'
- // chain. Hopefully this will unearth the real problem:
- InputStream in = ssl.getInputStream();
- in.available();
- /*
- If you're looking at the 2 lines of code above because
- you're running into a problem, you probably have two
- options:
-
- #1. Clean up the certificate chain that your server
- is presenting (e.g. edit "/etc/apache2/server.crt"
- or wherever it is your server's certificate chain
- is defined).
-
- OR
-
- #2. Upgrade to an IBM 1.5.x or greater JVM, or switch
- to a non-IBM JVM.
- */
-
- // If ssl.getInputStream().available() didn't cause an
- // exception, maybe at least now the session is available?
- session = ssl.getSession();
- if(session == null) {
- // If it's still null, probably a startHandshake() will
- // unearth the real problem.
- ssl.startHandshake();
-
- // Okay, if we still haven't managed to cause an exception,
- // might as well go for the NPE. Or maybe we're okay now?
- session = ssl.getSession();
- }
- }
-
- Certificate[] certs = session.getPeerCertificates();
- X509Certificate x509 = (X509Certificate) certs[0];
- verify(host, x509);
- }
-
- public final boolean verify(String host, SSLSession session) {
- try {
- Certificate[] certs = session.getPeerCertificates();
- X509Certificate x509 = (X509Certificate) certs[0];
- verify(host, x509);
- return true;
- }
- catch(SSLException e) {
- return false;
- }
- }
-
- public final void verify(String host, X509Certificate cert)
- throws SSLException {
- String[] cns = getCNs(cert);
- String[] subjectAlts = getDNSSubjectAlts(cert);
- verify(host, cns, subjectAlts);
- }
-
- public final void verify(final String host, final String[] cns,
- final String[] subjectAlts,
- final boolean strictWithSubDomains)
- throws SSLException {
-
- // Build the list of names we're going to check. Our DEFAULT and
- // STRICT implementations of the HostnameVerifier only use the
- // first CN provided. All other CNs are ignored.
- // (Firefox, wget, curl, Sun Java 1.4, 5, 6 all work this way).
- LinkedList names = new LinkedList();
- if(cns != null && cns.length > 0 && cns[0] != null) {
- names.add(cns[0]);
- }
- if(subjectAlts != null) {
- for (String subjectAlt : subjectAlts) {
- if (subjectAlt != null) {
- names.add(subjectAlt);
- }
- }
- }
-
- if(names.isEmpty()) {
- String msg = "Certificate for <" + host + "> doesn't contain CN or DNS subjectAlt";
- throw new SSLException(msg);
- }
-
- // StringBuffer for building the error message.
- StringBuffer buf = new StringBuffer();
-
- // We're can be case-insensitive when comparing the host we used to
- // establish the socket to the hostname in the certificate.
- String hostName = host.trim().toLowerCase(Locale.ENGLISH);
- boolean match = false;
- for(Iterator it = names.iterator(); it.hasNext();) {
- // Don't trim the CN, though!
- String cn = it.next();
- cn = cn.toLowerCase(Locale.ENGLISH);
- // Store CN in StringBuffer in case we need to report an error.
- buf.append(" <");
- buf.append(cn);
- buf.append('>');
- if(it.hasNext()) {
- buf.append(" OR");
- }
-
- // The CN better have at least two dots if it wants wildcard
- // action. It also can't be [*.co.uk] or [*.co.jp] or
- // [*.org.uk], etc...
- boolean doWildcard = cn.startsWith("*.") &&
- cn.lastIndexOf('.') >= 0 &&
- acceptableCountryWildcard(cn) &&
- !InetAddressUtils.isIPv4Address(host);
-
- if(doWildcard) {
- match = hostName.endsWith(cn.substring(1));
- if(match && strictWithSubDomains) {
- // If we're in strict mode, then [*.foo.com] is not
- // allowed to match [a.b.foo.com]
- match = countDots(hostName) == countDots(cn);
- }
- } else {
- match = hostName.equals(cn);
- }
- if(match) {
- break;
- }
- }
- if(!match) {
- throw new SSLException("hostname in certificate didn't match: <" + host + "> !=" + buf);
- }
- }
-
- public static boolean acceptableCountryWildcard(String cn) {
- int cnLen = cn.length();
- if(cnLen >= 7 && cnLen <= 9) {
- // Look for the '.' in the 3rd-last position:
- if(cn.charAt(cnLen - 3) == '.') {
- // Trim off the [*.] and the [.XX].
- String s = cn.substring(2, cnLen - 3);
- // And test against the sorted array of bad 2lds:
- int x = Arrays.binarySearch(BAD_COUNTRY_2LDS, s);
- return x < 0;
- }
- }
- return true;
- }
-
- public static String[] getCNs(X509Certificate cert) {
- LinkedList cnList = new LinkedList();
- /*
- Sebastian Hauer's original StrictSSLProtocolSocketFactory used
- getName() and had the following comment:
-
- Parses a X.500 distinguished name for the value of the
- "Common Name" field. This is done a bit sloppy right
- now and should probably be done a bit more according to
- RFC 2253.
-
- I've noticed that toString() seems to do a better job than
- getName() on these X500Principal objects, so I'm hoping that
- addresses Sebastian's concern.
-
- For example, getName() gives me this:
- 1.2.840.113549.1.9.1=#16166a756c6975736461766965734063756362632e636f6d
-
- whereas toString() gives me this:
- EMAILADDRESS=juliusdavies@cucbc.com
-
- Looks like toString() even works with non-ascii domain names!
- I tested it with "花子.co.jp" and it worked fine.
- */
- String subjectPrincipal = cert.getSubjectX500Principal().toString();
- StringTokenizer st = new StringTokenizer(subjectPrincipal, ",");
- while(st.hasMoreTokens()) {
- String tok = st.nextToken();
- int x = tok.indexOf("CN=");
- if(x >= 0) {
- cnList.add(tok.substring(x + 3));
- }
- }
- if(!cnList.isEmpty()) {
- String[] cns = new String[cnList.size()];
- cnList.toArray(cns);
- return cns;
- } else {
- return null;
- }
- }
-
-
- /**
- * Extracts the array of SubjectAlt DNS names from an X509Certificate.
- * Returns null if there aren't any.
- *
- * Note: Java doesn't appear able to extract international characters
- * from the SubjectAlts. It can only extract international characters
- * from the CN field.
- *
- * (Or maybe the version of OpenSSL I'm using to test isn't storing the
- * international characters correctly in the SubjectAlts?).
- *
- * @param cert X509Certificate
- * @return Array of SubjectALT DNS names stored in the certificate.
- */
- public static String[] getDNSSubjectAlts(X509Certificate cert) {
- LinkedList subjectAltList = new LinkedList();
- Collection> c = null;
- try {
- c = cert.getSubjectAlternativeNames();
- }
- catch(CertificateParsingException cpe) {
- Logger.getLogger(AbstractVerifier.class.getName())
- .log(Level.FINE, "Error parsing certificate.", cpe);
- }
- if(c != null) {
- for (List> aC : c) {
- List> list = aC;
- int type = ((Integer) list.get(0)).intValue();
- // If type is 2, then we've got a dNSName
- if (type == 2) {
- String s = (String) list.get(1);
- subjectAltList.add(s);
- }
- }
- }
- if(!subjectAltList.isEmpty()) {
- String[] subjectAlts = new String[subjectAltList.size()];
- subjectAltList.toArray(subjectAlts);
- return subjectAlts;
- } else {
- return null;
- }
- }
-
- /**
- * Counts the number of dots "." in a string.
- * @param s string to count dots from
- * @return number of dots
- */
- public static int countDots(final String s) {
- int count = 0;
- for(int i = 0; i < s.length(); i++) {
- if(s.charAt(i) == '.') {
- count++;
- }
- }
- return count;
- }
-
-}
diff --git a/src/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java b/src/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
deleted file mode 100644
index 05828fb6808774b3f15f536643c670c7f4765c94..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java $
- * $Revision: 617642 $
- * $Date: 2008-02-01 12:54:07 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-/**
- * The ALLOW_ALL HostnameVerifier essentially turns hostname verification
- * off. This implementation is a no-op, and never throws the SSLException.
- *
- * @author Julius Davies
- */
-public class AllowAllHostnameVerifier extends AbstractVerifier {
-
- public final void verify(
- final String host,
- final String[] cns,
- final String[] subjectAlts) {
- // Allow everything - so never blowup.
- }
-
- @Override
- public final String toString() {
- return "ALLOW_ALL";
- }
-
-}
diff --git a/src/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java b/src/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java
deleted file mode 100644
index f4129d6d62316bc44967e17d4d7de612d0fbc2fc..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java $
- * $Revision: 617642 $
- * $Date: 2008-02-01 12:54:07 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import javax.net.ssl.SSLException;
-
-/**
- * The HostnameVerifier that works the same way as Curl and Firefox.
- *
- * The hostname must match either the first CN, or any of the subject-alts.
- * A wildcard can occur in the CN, and in any of the subject-alts.
- *
- * The only difference between BROWSER_COMPATIBLE and STRICT is that a wildcard
- * (such as "*.foo.com") with BROWSER_COMPATIBLE matches all subdomains,
- * including "a.b.foo.com".
- *
- * @author Julius Davies
- */
-public class BrowserCompatHostnameVerifier extends AbstractVerifier {
-
- public final void verify(
- final String host,
- final String[] cns,
- final String[] subjectAlts) throws SSLException {
- verify(host, cns, subjectAlts, false);
- }
-
- @Override
- public final String toString() {
- return "BROWSER_COMPATIBLE";
- }
-
-}
diff --git a/src/org/apache/http/conn/ssl/SSLSocketFactory.java b/src/org/apache/http/conn/ssl/SSLSocketFactory.java
deleted file mode 100644
index 498b43e03bab1b13a9560303ae93a5ba1197665b..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/SSLSocketFactory.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java $
- * $Revision: 659194 $
- * $Date: 2008-05-22 11:33:47 -0700 (Thu, 22 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import org.apache.http.conn.scheme.HostNameResolver;
-import org.apache.http.conn.scheme.LayeredSocketFactory;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.UnrecoverableKeyException;
-
-/**
- * Layered socket factory for TLS/SSL connections, based on JSSE.
- *.
- *
- * SSLSocketFactory can be used to validate the identity of the HTTPS
- * server against a list of trusted certificates and to authenticate to
- * the HTTPS server using a private key.
- *
- *
- *
- * SSLSocketFactory will enable server authentication when supplied with
- * a {@link KeyStore truststore} file containg one or several trusted
- * certificates. The client secure socket will reject the connection during
- * the SSL session handshake if the target HTTPS server attempts to
- * authenticate itself with a non-trusted certificate.
- *
- *
- *
- * Use JDK keytool utility to import a trusted certificate and generate a truststore file:
- *
- * keytool -import -alias "my server cert" -file server.crt -keystore my.truststore
- *
- *
- *
- *
- * SSLSocketFactory will enable client authentication when supplied with
- * a {@link KeyStore keystore} file containg a private key/public certificate
- * pair. The client secure socket will use the private key to authenticate
- * itself to the target HTTPS server during the SSL session handshake if
- * requested to do so by the server.
- * The target HTTPS server will in its turn verify the certificate presented
- * by the client in order to establish client's authenticity
- *
- *
- *
- * Use the following sequence of actions to generate a keystore file
- *
- *
- * -
- *
- * Use JDK keytool utility to generate a new key
- *
keytool -genkey -v -alias "my client key" -validity 365 -keystore my.keystore
- * For simplicity use the same password for the key as that of the keystore
- *
- *
- *
- *
- * Issue a certificate signing request (CSR)
- *
keytool -certreq -alias "my client key" -file mycertreq.csr -keystore my.keystore
- *
- *
- *
- *
- * Send the certificate request to the trusted Certificate Authority for signature.
- * One may choose to act as her own CA and sign the certificate request using a PKI
- * tool, such as OpenSSL.
- *
- *
- *
- *
- * Import the trusted CA root certificate
- *
keytool -import -alias "my trusted ca" -file caroot.crt -keystore my.keystore
- *
- *
- *
- *
- * Import the PKCS#7 file containg the complete certificate chain
- *
keytool -import -alias "my client key" -file mycert.p7 -keystore my.keystore
- *
- *
- *
- *
- * Verify the content the resultant keystore file
- *
keytool -list -v -keystore my.keystore
- *
- *
- *
- * @author Oleg Kalnichevski
- * @author Julius Davies
- */
-
-public class SSLSocketFactory implements LayeredSocketFactory {
-
- public static final String TLS = "TLS";
- public static final String SSL = "SSL";
- public static final String SSLV2 = "SSLv2";
-
- public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
- = new AllowAllHostnameVerifier();
-
- public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
- = new BrowserCompatHostnameVerifier();
-
- public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER
- = new StrictHostnameVerifier();
- /**
- * The factory using the default JVM settings for secure connections.
- */
- private static final SSLSocketFactory DEFAULT_FACTORY = new SSLSocketFactory();
-
- /**
- * Gets an singleton instance of the SSLProtocolSocketFactory.
- * @return a SSLProtocolSocketFactory
- */
- public static SSLSocketFactory getSocketFactory() {
- return DEFAULT_FACTORY;
- }
-
- private final SSLContext sslcontext;
- private final javax.net.ssl.SSLSocketFactory socketfactory;
- private final HostNameResolver nameResolver;
- private X509HostnameVerifier hostnameVerifier = BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
-
- public SSLSocketFactory(
- String algorithm,
- final KeyStore keystore,
- final String keystorePassword,
- final KeyStore truststore,
- final SecureRandom random,
- final HostNameResolver nameResolver)
- throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
- {
- super();
- if (algorithm == null) {
- algorithm = TLS;
- }
- KeyManager[] keymanagers = null;
- if (keystore != null) {
- keymanagers = createKeyManagers(keystore, keystorePassword);
- }
- TrustManager[] trustmanagers = null;
- if (truststore != null) {
- trustmanagers = createTrustManagers(truststore);
- }
- this.sslcontext = SSLContext.getInstance(algorithm);
- this.sslcontext.init(keymanagers, trustmanagers, random);
- this.socketfactory = this.sslcontext.getSocketFactory();
- this.nameResolver = nameResolver;
- }
-
- public SSLSocketFactory(
- final KeyStore keystore,
- final String keystorePassword,
- final KeyStore truststore)
- throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
- {
- this(TLS, keystore, keystorePassword, truststore, null, null);
- }
-
- public SSLSocketFactory(final KeyStore keystore, final String keystorePassword)
- throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
- {
- this(TLS, keystore, keystorePassword, null, null, null);
- }
-
- public SSLSocketFactory(final KeyStore truststore)
- throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException
- {
- this(TLS, null, null, truststore, null, null);
- }
-
- /**
- * Creates the default SSL socket factory.
- * This constructor is used exclusively to instantiate the factory for
- * {@link #getSocketFactory getSocketFactory}.
- */
- private SSLSocketFactory() {
- super();
- this.sslcontext = null;
- this.socketfactory = HttpsURLConnection.getDefaultSSLSocketFactory();
- this.nameResolver = null;
- }
-
- private static KeyManager[] createKeyManagers(final KeyStore keystore, final String password)
- throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
- if (keystore == null) {
- throw new IllegalArgumentException("Keystore may not be null");
- }
- KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
- KeyManagerFactory.getDefaultAlgorithm());
- kmfactory.init(keystore, password != null ? password.toCharArray(): null);
- return kmfactory.getKeyManagers();
- }
-
- private static TrustManager[] createTrustManagers(final KeyStore keystore)
- throws KeyStoreException, NoSuchAlgorithmException {
- if (keystore == null) {
- throw new IllegalArgumentException("Keystore may not be null");
- }
- TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
- TrustManagerFactory.getDefaultAlgorithm());
- tmfactory.init(keystore);
- return tmfactory.getTrustManagers();
- }
-
-
- // non-javadoc, see interface org.apache.http.conn.SocketFactory
- public Socket createSocket()
- throws IOException {
-
- // the cast makes sure that the factory is working as expected
- return (SSLSocket) this.socketfactory.createSocket();
- }
-
-
- // non-javadoc, see interface org.apache.http.conn.SocketFactory
- public Socket connectSocket(
- final Socket sock,
- final String host,
- final int port,
- final InetAddress localAddress,
- int localPort,
- final HttpParams params
- ) throws IOException {
-
- if (host == null) {
- throw new IllegalArgumentException("Target host may not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null.");
- }
-
- SSLSocket sslsock = (SSLSocket)
- ((sock != null) ? sock : createSocket());
-
- if ((localAddress != null) || (localPort > 0)) {
-
- // we need to bind explicitly
- if (localPort < 0)
- localPort = 0; // indicates "any"
-
- InetSocketAddress isa =
- new InetSocketAddress(localAddress, localPort);
- sslsock.bind(isa);
- }
-
- int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
- int soTimeout = HttpConnectionParams.getSoTimeout(params);
-
- InetSocketAddress remoteAddress;
- if (this.nameResolver != null) {
- remoteAddress = new InetSocketAddress(this.nameResolver.resolve(host), port);
- } else {
- remoteAddress = new InetSocketAddress(host, port);
- }
-
- sslsock.connect(remoteAddress, connTimeout);
-
- sslsock.setSoTimeout(soTimeout);
- try {
- hostnameVerifier.verify(host, sslsock);
- // verifyHostName() didn't blowup - good!
- } catch (IOException iox) {
- // close the socket before re-throwing the exception
- try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
- throw iox;
- }
-
- return sslsock;
- }
-
-
- /**
- * Checks whether a socket connection is secure.
- * This factory creates TLS/SSL socket connections
- * which, by default, are considered secure.
- *
- * Derived classes may override this method to perform
- * runtime checks, for example based on the cypher suite.
- *
- * @param sock the connected socket
- *
- * @return true
- *
- * @throws IllegalArgumentException if the argument is invalid
- */
- public boolean isSecure(Socket sock)
- throws IllegalArgumentException {
-
- if (sock == null) {
- throw new IllegalArgumentException("Socket may not be null.");
- }
- // This instanceof check is in line with createSocket() above.
- if (!(sock instanceof SSLSocket)) {
- throw new IllegalArgumentException
- ("Socket not created by this factory.");
- }
- // This check is performed last since it calls the argument object.
- if (sock.isClosed()) {
- throw new IllegalArgumentException("Socket is closed.");
- }
-
- return true;
-
- } // isSecure
-
-
- // non-javadoc, see interface LayeredSocketFactory
- public Socket createSocket(
- final Socket socket,
- final String host,
- final int port,
- final boolean autoClose
- ) throws IOException, UnknownHostException {
- SSLSocket sslSocket = (SSLSocket) this.socketfactory.createSocket(
- socket,
- host,
- port,
- autoClose
- );
- hostnameVerifier.verify(host, sslSocket);
- // verifyHostName() didn't blowup - good!
- return sslSocket;
- }
-
- public void setHostnameVerifier(X509HostnameVerifier hostnameVerifier) {
- if ( hostnameVerifier == null ) {
- throw new IllegalArgumentException("Hostname verifier may not be null");
- }
- this.hostnameVerifier = hostnameVerifier;
- }
-
- public X509HostnameVerifier getHostnameVerifier() {
- return hostnameVerifier;
- }
-
-}
diff --git a/src/org/apache/http/conn/ssl/StrictHostnameVerifier.java b/src/org/apache/http/conn/ssl/StrictHostnameVerifier.java
deleted file mode 100644
index 5eb0d96e68a2e0240b2973575e4e8ac2338872f7..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/StrictHostnameVerifier.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifier.java $
- * $Revision: 617642 $
- * $Date: 2008-02-01 12:54:07 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import javax.net.ssl.SSLException;
-
-/**
- * The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun
- * Java 5, Sun Java 6-rc. It's also pretty close to IE6. This
- * implementation appears to be compliant with RFC 2818 for dealing with
- * wildcards.
- *
- * The hostname must match either the first CN, or any of the subject-alts.
- * A wildcard can occur in the CN, and in any of the subject-alts. The
- * one divergence from IE6 is how we only check the first CN. IE6 allows
- * a match against any of the CNs present. We decided to follow in
- * Sun Java 1.4's footsteps and only check the first CN. (If you need
- * to check all the CN's, feel free to write your own implementation!).
- *
- * A wildcard such as "*.foo.com" matches only subdomains in the same
- * level, for example "a.foo.com". It does not match deeper subdomains
- * such as "a.b.foo.com".
- *
- * @author Julius Davies
- */
-public class StrictHostnameVerifier extends AbstractVerifier {
-
- public final void verify(
- final String host,
- final String[] cns,
- final String[] subjectAlts) throws SSLException {
- verify(host, cns, subjectAlts, true);
- }
-
- @Override
- public final String toString() {
- return "STRICT";
- }
-
-}
diff --git a/src/org/apache/http/conn/ssl/X509HostnameVerifier.java b/src/org/apache/http/conn/ssl/X509HostnameVerifier.java
deleted file mode 100644
index 05ad04dd50bfb830e24f4168b659dac22e3a4ee5..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/X509HostnameVerifier.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/ssl/X509HostnameVerifier.java $
- * $Revision: 618365 $
- * $Date: 2008-02-04 10:20:08 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-import java.io.IOException;
-import java.security.cert.X509Certificate;
-
-/**
- * Interface for checking if a hostname matches the names stored inside the
- * server's X.509 certificate. Implements javax.net.ssl.HostnameVerifier, but
- * we don't actually use that interface. Instead we added some methods that
- * take String parameters (instead of javax.net.ssl.HostnameVerifier's
- * SSLSession). JUnit is a lot easier this way! :-)
- *
- * We provide the HostnameVerifier.DEFAULT, HostnameVerifier.STRICT, and
- * HostnameVerifier.ALLOW_ALL implementations. But feel free to define
- * your own implementation!
- *
- * Inspired by Sebastian Hauer's original StrictSSLProtocolSocketFactory in the
- * HttpClient "contrib" repository.
- *
- * @author Julius Davies
- * @author Sebastian Hauer
- *
- * @since 4.0 (8-Dec-2006)
- */
-public interface X509HostnameVerifier extends HostnameVerifier {
-
- boolean verify(String host, SSLSession session);
-
- void verify(String host, SSLSocket ssl) throws IOException;
-
- void verify(String host, X509Certificate cert) throws SSLException;
-
- /**
- * Checks to see if the supplied hostname matches any of the supplied CNs
- * or "DNS" Subject-Alts. Most implementations only look at the first CN,
- * and ignore any additional CNs. Most implementations do look at all of
- * the "DNS" Subject-Alts. The CNs or Subject-Alts may contain wildcards
- * according to RFC 2818.
- *
- * @param cns CN fields, in order, as extracted from the X.509
- * certificate.
- * @param subjectAlts Subject-Alt fields of type 2 ("DNS"), as extracted
- * from the X.509 certificate.
- * @param host The hostname to verify.
- * @throws SSLException If verification failed.
- */
- void verify(String host, String[] cns, String[] subjectAlts)
- throws SSLException;
-
-
-}
diff --git a/src/org/apache/http/conn/ssl/package.html b/src/org/apache/http/conn/ssl/package.html
deleted file mode 100644
index a5c737fafeda7d9ea1348a732cc0fb9d29cfd0cb..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/ssl/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-TLS/SSL specific parts of the HttpConn API.
-
-
-
diff --git a/src/org/apache/http/conn/util/InetAddressUtils.java b/src/org/apache/http/conn/util/InetAddressUtils.java
deleted file mode 100644
index 71f219070bb31f71912692d35023a05500646b85..0000000000000000000000000000000000000000
--- a/src/org/apache/http/conn/util/InetAddressUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/util/InetAddressUtils.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.util;
-
-import java.util.regex.Pattern;
-
-/**
- * A collection of utilities relating to InetAddresses.
- */
-public class InetAddressUtils {
-
- private InetAddressUtils() {
- }
-
- private static final Pattern IPV4_PATTERN =
- Pattern.compile(
- "^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$");
-
- private static final Pattern IPV6_STD_PATTERN =
- Pattern.compile(
- "^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$");
-
- private static final Pattern IPV6_HEX_COMPRESSED_PATTERN =
- Pattern.compile(
- "^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$");
-
- public static boolean isIPv4Address(final String input) {
- return IPV4_PATTERN.matcher(input).matches();
- }
-
- public static boolean isIPv6StdAddress(final String input) {
- return IPV6_STD_PATTERN.matcher(input).matches();
- }
-
- public static boolean isIPv6HexCompressedAddress(final String input) {
- return IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();
- }
-
- public static boolean isIPv6Address(final String input) {
- return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
- }
-
-}
diff --git a/src/org/apache/http/cookie/ClientCookie.java b/src/org/apache/http/cookie/ClientCookie.java
deleted file mode 100644
index 96edec976e97bafdc92f6ba766871b35d541afcc..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/ClientCookie.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java $
- * $Revision: 578403 $
- * $Date: 2007-09-22 03:56:04 -0700 (Sat, 22 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-/**
- * ClientCookie extends the standard {@link Cookie} interface with
- * additional client specific functionality such ability to retrieve
- * original cookie attributes exactly as they were specified by the
- * origin server. This is important for generating the Cookie
- * header because some cookie specifications require that the
- * Cookie header should include certain attributes only if
- * they were specified in the Set-Cookie header.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface ClientCookie extends Cookie {
-
- // RFC2109 attributes
- public static final String VERSION_ATTR = "version";
- public static final String PATH_ATTR = "path";
- public static final String DOMAIN_ATTR = "domain";
- public static final String MAX_AGE_ATTR = "max-age";
- public static final String SECURE_ATTR = "secure";
- public static final String COMMENT_ATTR = "comment";
- public static final String EXPIRES_ATTR = "expires";
-
- // RFC2965 attributes
- public static final String PORT_ATTR = "port";
- public static final String COMMENTURL_ATTR = "commenturl";
- public static final String DISCARD_ATTR = "discard";
-
- String getAttribute(String name);
-
- boolean containsAttribute(String name);
-
-}
\ No newline at end of file
diff --git a/src/org/apache/http/cookie/Cookie.java b/src/org/apache/http/cookie/Cookie.java
deleted file mode 100644
index 5eae9d59fb99c45ba60fbe646cec8802d138a694..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/Cookie.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/Cookie.java $
- * $Revision: 578403 $
- * $Date: 2007-09-22 03:56:04 -0700 (Sat, 22 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.util.Date;
-
-/**
- * HTTP "magic-cookie" represents a piece of state information
- * that the HTTP agent and the target server can exchange to maintain
- * a session.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface Cookie {
-
- /**
- * Returns the name.
- *
- * @return String name The name
- */
- String getName();
-
- /**
- * Returns the value.
- *
- * @return String value The current value.
- */
- String getValue();
-
- /**
- * Returns the comment describing the purpose of this cookie, or
- * null if no such comment has been defined.
- *
- * @return comment
- */
- String getComment();
-
- /**
- * If a user agent (web browser) presents this cookie to a user, the
- * cookie's purpose will be described by the information at this URL.
- */
- String getCommentURL();
-
- /**
- * Returns the expiration {@link Date} of the cookie, or null
- * if none exists.
- * Note: the object returned by this method is
- * considered immutable. Changing it (e.g. using setTime()) could result
- * in undefined behaviour. Do so at your peril.
- * @return Expiration {@link Date}, or null.
- */
- Date getExpiryDate();
-
- /**
- * Returns false if the cookie should be discarded at the end
- * of the "session"; true otherwise.
- *
- * @return false if the cookie should be discarded at the end
- * of the "session"; true otherwise
- */
- boolean isPersistent();
-
- /**
- * Returns domain attribute of the cookie.
- *
- * @return the value of the domain attribute
- */
- String getDomain();
-
- /**
- * Returns the path attribute of the cookie
- *
- * @return The value of the path attribute.
- */
- String getPath();
-
- /**
- * Get the Port attribute. It restricts the ports to which a cookie
- * may be returned in a Cookie request header.
- */
- int[] getPorts();
-
- /**
- * Indicates whether this cookie requires a secure connection.
- *
- * @return true if this cookie should only be sent
- * over secure connections, false otherwise.
- */
- boolean isSecure();
-
- /**
- * Returns the version of the cookie specification to which this
- * cookie conforms.
- *
- * @return the version of the cookie.
- */
- int getVersion();
-
- /**
- * Returns true if this cookie has expired.
- * @param date Current time
- *
- * @return true if the cookie has expired.
- */
- boolean isExpired(final Date date);
-
-}
-
diff --git a/src/org/apache/http/cookie/CookieAttributeHandler.java b/src/org/apache/http/cookie/CookieAttributeHandler.java
deleted file mode 100644
index a79d1153a1fa5fae2ecd84fed76cb75eb2452851..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieAttributeHandler.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieAttributeHandler.java $
- * $Revision: 558519 $
- * $Date: 2007-07-22 11:19:49 -0700 (Sun, 22 Jul 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.cookie;
-
-/**
- * Ths interface represents a cookie attribute handler responsible
- * for parsing, validating, and matching a specific cookie attribute,
- * such as path, domain, port, etc.
- *
- * Different cookie specifications can provide a specific
- * implementation for this class based on their cookie handling
- * rules.
- *
- * @author jain.samit@gmail.com (Samit Jain)
- *
- * @since 4.0
- */
-public interface CookieAttributeHandler {
-
- /**
- * Parse the given cookie attribute value and update the corresponding
- * {@link org.apache.http.cookie.Cookie} property.
- *
- * @param cookie {@link org.apache.http.cookie.Cookie} to be updated
- * @param value cookie attribute value from the cookie response header
- */
- void parse(SetCookie cookie, String value)
- throws MalformedCookieException;
-
- /**
- * Peforms cookie validation for the given attribute value.
- *
- * @param cookie {@link org.apache.http.cookie.Cookie} to validate
- * @param origin the cookie source to validate against
- * @throws MalformedCookieException if cookie validation fails for this attribute
- */
- void validate(Cookie cookie, CookieOrigin origin)
- throws MalformedCookieException;
-
- /**
- * Matches the given value (property of the destination host where request is being
- * submitted) with the corresponding cookie attribute.
- *
- * @param cookie {@link org.apache.http.cookie.Cookie} to match
- * @param origin the cookie source to match against
- * @return true if the match is successful; false otherwise
- */
- boolean match(Cookie cookie, CookieOrigin origin);
-
-}
diff --git a/src/org/apache/http/cookie/CookieIdentityComparator.java b/src/org/apache/http/cookie/CookieIdentityComparator.java
deleted file mode 100644
index 4fc701c8170c35147f01d241ae8c1f0147a3bda8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieIdentityComparator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java $
- * $Revision: 618308 $
- * $Date: 2008-02-04 07:51:19 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * This cookie comparator can be used to compare identity of cookies.
- *
- *
- * Cookies are considered identical if their names are equal and
- * their domain attributes match ignoring case.
- *
- *
- * @author Oleg Kalnichevski
- */
-public class CookieIdentityComparator implements Serializable, Comparator {
-
- private static final long serialVersionUID = 4466565437490631532L;
-
- public int compare(final Cookie c1, final Cookie c2) {
- int res = c1.getName().compareTo(c2.getName());
- if (res == 0) {
- // do not differentiate empty and null domains
- String d1 = c1.getDomain();
- if (d1 == null) {
- d1 = "";
- }
- String d2 = c2.getDomain();
- if (d2 == null) {
- d2 = "";
- }
- res = d1.compareToIgnoreCase(d2);
- }
- return res;
- }
-
-}
diff --git a/src/org/apache/http/cookie/CookieOrigin.java b/src/org/apache/http/cookie/CookieOrigin.java
deleted file mode 100644
index ad0448af8089fbf44c72c69315724236f9af9daa..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieOrigin.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieOrigin.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.cookie;
-
-import java.util.Locale;
-
-/**
- * CookieOrigin class incapsulates details of an origin server that
- * are relevant when parsing, validating or matching HTTP cookies.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public final class CookieOrigin {
-
- private final String host;
- private final int port;
- private final String path;
- private final boolean secure;
-
- public CookieOrigin(final String host, int port, final String path, boolean secure) {
- super();
- if (host == null) {
- throw new IllegalArgumentException(
- "Host of origin may not be null");
- }
- if (host.trim().length() == 0) {
- throw new IllegalArgumentException(
- "Host of origin may not be blank");
- }
- if (port < 0) {
- throw new IllegalArgumentException("Invalid port: " + port);
- }
- if (path == null) {
- throw new IllegalArgumentException(
- "Path of origin may not be null.");
- }
- this.host = host.toLowerCase(Locale.ENGLISH);
- this.port = port;
- if (path.trim().length() != 0) {
- this.path = path;
- } else {
- this.path = "/";
- }
- this.secure = secure;
- }
-
- public String getHost() {
- return this.host;
- }
-
- public String getPath() {
- return this.path;
- }
-
- public int getPort() {
- return this.port;
- }
-
- public boolean isSecure() {
- return this.secure;
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- buffer.append('[');
- if (this.secure) {
- buffer.append("(secure)");
- }
- buffer.append(this.host);
- buffer.append(':');
- buffer.append(Integer.toString(this.port));
- buffer.append(this.path);
- buffer.append(']');
- return buffer.toString();
- }
-
-}
diff --git a/src/org/apache/http/cookie/CookiePathComparator.java b/src/org/apache/http/cookie/CookiePathComparator.java
deleted file mode 100644
index f5f0a668aa26087254b740b350f51b60ddc5137e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookiePathComparator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * This cookie comparator ensures that multiple cookies satisfying
- * a common criteria are ordered in the Cookie header such
- * that those with more specific Path attributes precede those with
- * less specific.
- *
- *
- * This comparator assumes that Path attributes of two cookies
- * path-match a commmon request-URI. Otherwise, the result of the
- * comparison is undefined.
- *
- *
- * @author Oleg Kalnichevski
- */
-public class CookiePathComparator implements Serializable, Comparator {
-
- private static final long serialVersionUID = 7523645369616405818L;
-
- private String normalizePath(final Cookie cookie) {
- String path = cookie.getPath();
- if (path == null) {
- path = "/";
- }
- if (!path.endsWith("/")) {
- path = path + '/';
- }
- return path;
- }
-
- public int compare(final Cookie c1, final Cookie c2) {
- String path1 = normalizePath(c1);
- String path2 = normalizePath(c2);
- if (path1.equals(path2)) {
- return 0;
- } else if (path1.startsWith(path2)) {
- return -1;
- } else if (path2.startsWith(path1)) {
- return 1;
- } else {
- // Does not really matter
- return 0;
- }
- }
-
-}
diff --git a/src/org/apache/http/cookie/CookieSpec.java b/src/org/apache/http/cookie/CookieSpec.java
deleted file mode 100644
index 1eb9f26bf18cb32bc4d819c44dfbaaa8c4effc24..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieSpec.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpec.java $
- * $Revision: 603563 $
- * $Date: 2007-12-12 03:17:55 -0800 (Wed, 12 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.util.List;
-
-import org.apache.http.Header;
-
-/**
- * Defines the cookie management specification.
- * Cookie management specification must define
- *
- * - rules of parsing "Set-Cookie" header
- *
- rules of validation of parsed cookies
- *
- formatting of "Cookie" header
- *
- * for a given host, port and path of origin
- *
- * @author Oleg Kalnichevski
- * @author Jeff Dever
- *
- * @since 4.0
- */
-public interface CookieSpec {
-
- /**
- * Returns version of the state management this cookie specification
- * conforms to.
- *
- * @return version of the state management specification
- */
- int getVersion();
-
- /**
- * Parse the "Set-Cookie" Header into an array of Cookies.
- *
- * This method will not perform the validation of the resultant
- * {@link Cookie}s
- *
- * @see #validate
- *
- * @param header the Set-Cookie received from the server
- * @param origin details of the cookie origin
- * @return an array of Cookies parsed from the header
- * @throws MalformedCookieException if an exception occurs during parsing
- */
- List parse(Header header, CookieOrigin origin) throws MalformedCookieException;
-
- /**
- * Validate the cookie according to validation rules defined by the
- * cookie specification.
- *
- * @param cookie the Cookie to validate
- * @param origin details of the cookie origin
- * @throws MalformedCookieException if the cookie is invalid
- */
- void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException;
-
- /**
- * Determines if a Cookie matches the target location.
- *
- * @param cookie the Cookie to be matched
- * @param origin the target to test against
- *
- * @return true if the cookie should be submitted with a request
- * with given attributes, false otherwise.
- */
- boolean match(Cookie cookie, CookieOrigin origin);
-
- /**
- * Create "Cookie" headers for an array of Cookies.
- *
- * @param cookies the Cookies format into a Cookie header
- * @return a Header for the given Cookies.
- * @throws IllegalArgumentException if an input parameter is illegal
- */
- List formatCookies(List cookies);
-
- /**
- * Returns a request header identifying what version of the state management
- * specification is understood. May be null if the cookie
- * specification does not support Cookie2 header.
- */
- Header getVersionHeader();
-
-}
diff --git a/src/org/apache/http/cookie/CookieSpecFactory.java b/src/org/apache/http/cookie/CookieSpecFactory.java
deleted file mode 100644
index 9d5c21d3bebc09f69b100907e7497e42146adecc..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieSpecFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecFactory.java $
- * $Revision: 489636 $
- * $Date: 2006-12-22 04:34:57 -0800 (Fri, 22 Dec 2006) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import org.apache.http.params.HttpParams;
-
-/**
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface CookieSpecFactory {
-
- CookieSpec newInstance(HttpParams params);
-
-}
diff --git a/src/org/apache/http/cookie/CookieSpecRegistry.java b/src/org/apache/http/cookie/CookieSpecRegistry.java
deleted file mode 100644
index 64b9c8bab4ed53851fdf0edbb22341e8acc8d573..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/CookieSpecRegistry.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java $
- * $Revision: 652950 $
- * $Date: 2008-05-02 16:49:48 -0700 (Fri, 02 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.http.params.HttpParams;
-
-/**
- * Cookie specification registry that can be used to obtain the corresponding
- * cookie specification implementation for a given type of type or version of
- * cookie.
- *
- * @author Oleg Kalnichevski
- * @author Mike Bowler
- *
- * @since 4.0
- */
-public final class CookieSpecRegistry {
-
- private final Map registeredSpecs;
-
- public CookieSpecRegistry() {
- super();
- this.registeredSpecs = new LinkedHashMap();
- }
-
- /**
- * Registers a {@link CookieSpecFactory} with the given identifier.
- * If a specification with the given name already exists it will be overridden.
- * This nameis the same one used to retrieve the {@link CookieSpecFactory}
- * from {@link #getCookieSpec(String)}.
- *
- * @param name the identifier for this specification
- * @param factory the {@link CookieSpecFactory} class to register
- *
- * @see #getCookieSpec(String)
- */
- public synchronized void register(final String name, final CookieSpecFactory factory) {
- if (name == null) {
- throw new IllegalArgumentException("Name may not be null");
- }
- if (factory == null) {
- throw new IllegalArgumentException("Cookie spec factory may not be null");
- }
- registeredSpecs.put(name.toLowerCase(Locale.ENGLISH), factory);
- }
-
- /**
- * Unregisters the {@link CookieSpecFactory} with the given ID.
- *
- * @param id the identifier of the {@link CookieSpec cookie specification} to unregister
- */
- public synchronized void unregister(final String id) {
- if (id == null) {
- throw new IllegalArgumentException("Id may not be null");
- }
- registeredSpecs.remove(id.toLowerCase(Locale.ENGLISH));
- }
-
- /**
- * Gets the {@link CookieSpec cookie specification} with the given ID.
- *
- * @param name the {@link CookieSpec cookie specification} identifier
- * @param params the {@link HttpParams HTTP parameters} for the cookie
- * specification.
- *
- * @return {@link CookieSpec cookie specification}
- *
- * @throws IllegalStateException if a policy with the given name cannot be found
- */
- public synchronized CookieSpec getCookieSpec(final String name, final HttpParams params)
- throws IllegalStateException {
-
- if (name == null) {
- throw new IllegalArgumentException("Name may not be null");
- }
- CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
- if (factory != null) {
- return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported cookie spec: " + name);
- }
- }
-
- /**
- * Gets the {@link CookieSpec cookie specification} with the given name.
- *
- * @param name the {@link CookieSpec cookie specification} identifier
- *
- * @return {@link CookieSpec cookie specification}
- *
- * @throws IllegalStateException if a policy with the given name cannot be found
- */
- public synchronized CookieSpec getCookieSpec(final String name)
- throws IllegalStateException {
- return getCookieSpec(name, null);
- }
-
- /**
- * Obtains a list containing names of all registered {@link CookieSpec cookie
- * specs} in their default order.
- *
- * Note that the DEFAULT policy (if present) is likely to be the same
- * as one of the other policies, but does not have to be.
- *
- * @return list of registered cookie spec names
- */
- public synchronized List getSpecNames(){
- return new ArrayList(registeredSpecs.keySet());
- }
-
- /**
- * Populates the internal collection of registered {@link CookieSpec cookie
- * specs} with the content of the map passed as a parameter.
- *
- * @param map cookie specs
- */
- public synchronized void setItems(final Map map) {
- if (map == null) {
- return;
- }
- registeredSpecs.clear();
- registeredSpecs.putAll(map);
- }
-
-}
diff --git a/src/org/apache/http/cookie/MalformedCookieException.java b/src/org/apache/http/cookie/MalformedCookieException.java
deleted file mode 100644
index e3f30a98485d40f087976686f274f15aa889e522..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/MalformedCookieException.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/MalformedCookieException.java $
- * $Revision: 508891 $
- * $Date: 2007-02-18 02:08:48 -0800 (Sun, 18 Feb 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import org.apache.http.ProtocolException;
-
-/**
- * Signals that a cookie is in some way invalid or illegal in a given
- * context
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class MalformedCookieException extends ProtocolException {
-
- private static final long serialVersionUID = -6695462944287282185L;
-
- /**
- * Creates a new MalformedCookieException with a null detail message.
- */
- public MalformedCookieException() {
- super();
- }
-
- /**
- * Creates a new MalformedCookieException with a specified message string.
- *
- * @param message The exception detail message
- */
- public MalformedCookieException(String message) {
- super(message);
- }
-
- /**
- * Creates a new MalformedCookieException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the Throwable that caused this exception, or null
- * if the cause is unavailable, unknown, or not a Throwable
- */
- public MalformedCookieException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/src/org/apache/http/cookie/SM.java b/src/org/apache/http/cookie/SM.java
deleted file mode 100644
index a7047d51c680bc9aeb0ee7a13a141a24e791a80e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/SM.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SM.java $
- * $Revision: 582602 $
- * $Date: 2007-10-07 02:35:48 -0700 (Sun, 07 Oct 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-/**
- * Constants and static helpers related to the HTTP state management.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface SM {
-
- public static final String COOKIE = "Cookie";
- public static final String COOKIE2 = "Cookie2";
- public static final String SET_COOKIE = "Set-Cookie";
- public static final String SET_COOKIE2 = "Set-Cookie2";
-
-}
diff --git a/src/org/apache/http/cookie/SetCookie.java b/src/org/apache/http/cookie/SetCookie.java
deleted file mode 100644
index d207c48382ccd2b8585da946a376f52f5e74211d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/SetCookie.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java $
- * $Revision: 617193 $
- * $Date: 2008-01-31 11:26:47 -0800 (Thu, 31 Jan 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import java.util.Date;
-
-/**
- * This interface represents a SetCookie response header sent by the
- * origin server to the HTTP agent in order to maintain a conversational state.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface SetCookie extends Cookie {
-
- void setValue(String value);
-
- /**
- * If a user agent (web browser) presents this cookie to a user, the
- * cookie's purpose will be described using this comment.
- *
- * @param comment
- *
- * @see #getComment()
- */
- void setComment(String comment);
-
- /**
- * Sets expiration date.
- * Note: the object returned by this method is considered
- * immutable. Changing it (e.g. using setTime()) could result in undefined
- * behaviour. Do so at your peril.
- *
- * @param expiryDate the {@link Date} after which this cookie is no longer valid.
- *
- * @see Cookie#getExpiryDate
- *
- */
- void setExpiryDate (Date expiryDate);
-
- /**
- * Sets the domain attribute.
- *
- * @param domain The value of the domain attribute
- *
- * @see Cookie#getDomain
- */
- void setDomain(String domain);
-
- /**
- * Sets the path attribute.
- *
- * @param path The value of the path attribute
- *
- * @see Cookie#getPath
- *
- */
- void setPath(String path);
-
- /**
- * Sets the secure attribute of the cookie.
- *
- * When true the cookie should only be sent
- * using a secure protocol (https). This should only be set when
- * the cookie's originating server used a secure protocol to set the
- * cookie's value.
- *
- * @param secure The value of the secure attribute
- *
- * @see #isSecure()
- */
- void setSecure (boolean secure);
-
- /**
- * Sets the version of the cookie specification to which this
- * cookie conforms.
- *
- * @param version the version of the cookie.
- *
- * @see Cookie#getVersion
- */
- void setVersion(int version);
-
-}
-
diff --git a/src/org/apache/http/cookie/SetCookie2.java b/src/org/apache/http/cookie/SetCookie2.java
deleted file mode 100644
index cd0420e9f1c36f626a2b1c1b1406928a2ff9e588..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/SetCookie2.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie2.java $
- * $Revision: 578408 $
- * $Date: 2007-09-22 04:53:57 -0700 (Sat, 22 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-/**
- * This interface represents a SetCookie2 response header sent by the
- * origin server to the HTTP agent in order to maintain a conversational state.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public interface SetCookie2 extends SetCookie {
-
- /**
- * If a user agent (web browser) presents this cookie to a user, the
- * cookie's purpose will be described by the information at this URL.
- */
- void setCommentURL(String commentURL);
-
- /**
- * Sets the Port attribute. It restricts the ports to which a cookie
- * may be returned in a Cookie request header.
- */
- void setPorts(int[] ports);
-
- /**
- * Set the Discard attribute.
- *
- * Note: Discard attribute overrides Max-age.
- *
- * @see #isPersistent()
- */
- void setDiscard(boolean discard);
-
-}
-
diff --git a/src/org/apache/http/cookie/package.html b/src/org/apache/http/cookie/package.html
deleted file mode 100644
index 891d9c3c6ec8c6c9b78f1081d03237a01f3eb719..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/package.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-The API for client-side state management via cookies,
-commonly referred to as HttpCookie.
-
-
-
diff --git a/src/org/apache/http/cookie/params/CookieSpecPNames.java b/src/org/apache/http/cookie/params/CookieSpecPNames.java
deleted file mode 100644
index 6a6f6d0d1565981f8f2825aa7a314e6884cef470..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/params/CookieSpecPNames.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/params/CookieSpecPNames.java $
- * $Revision: 578403 $
- * $Date: 2007-09-22 03:56:04 -0700 (Sat, 22 Sep 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie.params;
-
-/**
- * Parameter names for cookie specifications in HttpCookie.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 578403 $
- *
- * @since 4.0
- */
-public interface CookieSpecPNames {
-
- /**
- * Parameter for the date patterns used for parsing.
- *
- * This parameter expects a value of type {@link java.util.Collection}.
- * The collection elements are of type {@link String}
- * and must be compatible with the syntax of
- * {@link java.text.SimpleDateFormat}.
- *
- */
- public static final String DATE_PATTERNS = "http.protocol.cookie-datepatterns";
-
- /**
- * Parameter for Cookie header formatting.
- * Defines whether {@link org.apache.http.cookie.Cookie cookies}
- * should be put on
- * a single {@link org.apache.http.Header request header}.
- * If not, each cookie is formatted in a seperate Cookie header.
- *
- * This parameter expects a value of type {@link Boolean}.
- *
- */
- public static final String SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header";
-
-}
diff --git a/src/org/apache/http/cookie/params/CookieSpecParamBean.java b/src/org/apache/http/cookie/params/CookieSpecParamBean.java
deleted file mode 100644
index 6016022cb89777b96c81be64f55dda96c63861e4..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/params/CookieSpecParamBean.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/params/CookieSpecParamBean.java $
- * $Revision: 632313 $
- * $Date: 2008-02-29 05:19:50 -0800 (Fri, 29 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie.params;
-
-import java.util.Collection;
-
-import org.apache.http.params.HttpAbstractParamBean;
-import org.apache.http.params.HttpParams;
-
-public class CookieSpecParamBean extends HttpAbstractParamBean {
-
- public CookieSpecParamBean (final HttpParams params) {
- super(params);
- }
-
- public void setDatePatterns (final Collection patterns) {
- params.setParameter(CookieSpecPNames.DATE_PATTERNS, patterns);
- }
-
- public void setSingleHeader (final boolean singleHeader) {
- params.setBooleanParameter(CookieSpecPNames.SINGLE_COOKIE_HEADER, singleHeader);
- }
-
-}
diff --git a/src/org/apache/http/cookie/params/package.html b/src/org/apache/http/cookie/params/package.html
deleted file mode 100644
index e6fb7cd0b71801df76fbba6df0906ae3bec2c489..0000000000000000000000000000000000000000
--- a/src/org/apache/http/cookie/params/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-Parameters for configuring HttpCookie.
-
-
-
diff --git a/src/org/apache/http/entity/AbstractHttpEntity.java b/src/org/apache/http/entity/AbstractHttpEntity.java
deleted file mode 100644
index 0fce6eb7d229123b7c73ed878ac156c7f2abca61..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/AbstractHttpEntity.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/AbstractHttpEntity.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Abstract base class for entities.
- * Provides the commonly used attributes for streamed and self-contained
- * implementations of {@link HttpEntity HttpEntity}.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public abstract class AbstractHttpEntity implements HttpEntity {
-
- /**
- * The Content-Type header.
- * Returned by {@link #getContentType getContentType},
- * unless that method is overridden.
- */
- protected Header contentType;
-
- /**
- * The Content-Encoding header.
- * Returned by {@link #getContentEncoding getContentEncoding},
- * unless that method is overridden.
- */
- protected Header contentEncoding;
-
- /**
- * The 'chunked' flag.
- * Returned by {@link #isChunked isChunked},
- * unless that method is overridden.
- */
- protected boolean chunked;
-
-
- /**
- * Protected default constructor.
- * The attributes of the created object remain
- * null and false, respectively.
- */
- protected AbstractHttpEntity() {
- super();
- }
-
-
- /**
- * Obtains the Content-Type header.
- * The default implementation returns the value of the
- * {@link #contentType contentType} attribute.
- *
- * @return the Content-Type header, or null
- */
- public Header getContentType() {
- return this.contentType;
- }
-
-
- /**
- * Obtains the Content-Encoding header.
- * The default implementation returns the value of the
- * {@link #contentEncoding contentEncoding} attribute.
- *
- * @return the Content-Encoding header, or null
- */
- public Header getContentEncoding() {
- return this.contentEncoding;
- }
-
- /**
- * Obtains the 'chunked' flag.
- * The default implementation returns the value of the
- * {@link #chunked chunked} attribute.
- *
- * @return the 'chunked' flag
- */
- public boolean isChunked() {
- return this.chunked;
- }
-
-
- /**
- * Specifies the Content-Type header.
- * The default implementation sets the value of the
- * {@link #contentType contentType} attribute.
- *
- * @param contentType the new Content-Encoding header, or
- * null to unset
- */
- public void setContentType(final Header contentType) {
- this.contentType = contentType;
- }
-
- /**
- * Specifies the Content-Type header, as a string.
- * The default implementation calls
- * {@link #setContentType(Header) setContentType(Header)}.
- *
- * @param ctString the new Content-Type header, or
- * null to unset
- */
- public void setContentType(final String ctString) {
- Header h = null;
- if (ctString != null) {
- h = new BasicHeader(HTTP.CONTENT_TYPE, ctString);
- }
- setContentType(h);
- }
-
-
- /**
- * Specifies the Content-Encoding header.
- * The default implementation sets the value of the
- * {@link #contentEncoding contentEncoding} attribute.
- *
- * @param contentEncoding the new Content-Encoding header, or
- * null to unset
- */
- public void setContentEncoding(final Header contentEncoding) {
- this.contentEncoding = contentEncoding;
- }
-
- /**
- * Specifies the Content-Encoding header, as a string.
- * The default implementation calls
- * {@link #setContentEncoding(Header) setContentEncoding(Header)}.
- *
- * @param ceString the new Content-Encoding header, or
- * null to unset
- */
- public void setContentEncoding(final String ceString) {
- Header h = null;
- if (ceString != null) {
- h = new BasicHeader(HTTP.CONTENT_ENCODING, ceString);
- }
- setContentEncoding(h);
- }
-
-
- /**
- * Specifies the 'chunked' flag.
- * The default implementation sets the value of the
- * {@link #chunked chunked} attribute.
- *
- * @param b the new 'chunked' flag
- */
- public void setChunked(boolean b) {
- this.chunked = b;
- }
-
-
- /**
- * Does not consume anything.
- * The default implementation does nothing if
- * {@link HttpEntity#isStreaming isStreaming}
- * returns false, and throws an exception
- * if it returns true.
- * This removes the burden of implementing
- * an empty method for non-streaming entities.
- *
- * @throws IOException in case of an I/O problem
- * @throws UnsupportedOperationException
- * if a streaming subclass does not override this method
- */
- public void consumeContent()
- throws IOException, UnsupportedOperationException{
- if (isStreaming()) {
- throw new UnsupportedOperationException
- ("streaming entity does not implement consumeContent()");
- }
- } // consumeContent
-
-
-} // class AbstractHttpEntity
diff --git a/src/org/apache/http/entity/BasicHttpEntity.java b/src/org/apache/http/entity/BasicHttpEntity.java
deleted file mode 100644
index df3c07c6f5583ac37d4a63cf35c398b937acacef..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/BasicHttpEntity.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/BasicHttpEntity.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * A generic streamed entity being received on a connection.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public class BasicHttpEntity extends AbstractHttpEntity {
-
- private InputStream content;
- private boolean contentObtained;
- private long length;
-
- /**
- * Creates a new basic entity.
- * The content is initially missing, the content length
- * is set to a negative number.
- */
- public BasicHttpEntity() {
- super();
- this.length = -1;
- }
-
- // non-javadoc, see interface HttpEntity
- public long getContentLength() {
- return this.length;
- }
-
- /**
- * Obtains the content, once only.
- *
- * @return the content, if this is the first call to this method
- * since {@link #setContent setContent} has been called
- *
- * @throws IllegalStateException
- * if the content has been obtained before, or
- * has not yet been provided
- */
- public InputStream getContent()
- throws IllegalStateException {
- if (this.content == null) {
- throw new IllegalStateException("Content has not been provided");
- }
- if (this.contentObtained) {
- throw new IllegalStateException("Content has been consumed");
- }
- this.contentObtained = true;
- return this.content;
-
- } // getContent
-
- /**
- * Tells that this entity is not repeatable.
- *
- * @return false
- */
- public boolean isRepeatable() {
- return false;
- }
-
- /**
- * Specifies the length of the content.
- *
- * @param len the number of bytes in the content, or
- * a negative number to indicate an unknown length
- */
- public void setContentLength(long len) {
- this.length = len;
- }
-
- /**
- * Specifies the content.
- *
- * @param instream the stream to return with the next call to
- * {@link #getContent getContent}
- */
- public void setContent(final InputStream instream) {
- this.content = instream;
- this.contentObtained = false;
- }
-
- // non-javadoc, see interface HttpEntity
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- InputStream instream = getContent();
- int l;
- byte[] tmp = new byte[2048];
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
- }
- }
-
- // non-javadoc, see interface HttpEntity
- public boolean isStreaming() {
- return !this.contentObtained && this.content != null;
- }
-
- // non-javadoc, see interface HttpEntity
- public void consumeContent() throws IOException {
- if (content != null) {
- content.close(); // reads to the end of the entity
- }
- }
-
-} // class BasicHttpEntity
diff --git a/src/org/apache/http/entity/BufferedHttpEntity.java b/src/org/apache/http/entity/BufferedHttpEntity.java
deleted file mode 100644
index 988879739e209d4abb2279c9304949ff1beadef2..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/BufferedHttpEntity.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/BufferedHttpEntity.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.util.EntityUtils;
-
-/**
- * A wrapping entity that buffers it content if necessary.
- * The buffered entity is always repeatable.
- * If the wrapped entity is repeatable itself, calls are passed through.
- * If the wrapped entity is not repeatable, the content is read into a
- * buffer once and provided from there as often as required.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public class BufferedHttpEntity extends HttpEntityWrapper {
-
- private final byte[] buffer;
-
- public BufferedHttpEntity(final HttpEntity entity) throws IOException {
- super(entity);
- if (!entity.isRepeatable() || entity.getContentLength() < 0) {
- this.buffer = EntityUtils.toByteArray(entity);
- } else {
- this.buffer = null;
- }
- }
-
- public long getContentLength() {
- if (this.buffer != null) {
- return this.buffer.length;
- } else {
- return wrappedEntity.getContentLength();
- }
- }
-
- public InputStream getContent() throws IOException {
- if (this.buffer != null) {
- return new ByteArrayInputStream(this.buffer);
- } else {
- return wrappedEntity.getContent();
- }
- }
-
- /**
- * Tells that this entity does not have to be chunked.
- *
- * @return false
- */
- public boolean isChunked() {
- return (buffer == null) && wrappedEntity.isChunked();
- }
-
- /**
- * Tells that this entity is repeatable.
- *
- * @return true
- */
- public boolean isRepeatable() {
- return true;
- }
-
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- if (this.buffer != null) {
- outstream.write(this.buffer);
- } else {
- wrappedEntity.writeTo(outstream);
- }
- }
-
-
- // non-javadoc, see interface HttpEntity
- public boolean isStreaming() {
- return (buffer == null) && wrappedEntity.isStreaming();
- }
-
-} // class BufferedHttpEntity
diff --git a/src/org/apache/http/entity/ByteArrayEntity.java b/src/org/apache/http/entity/ByteArrayEntity.java
deleted file mode 100644
index c7257f7338640d47af53c28e4eb70565aa01c326..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/ByteArrayEntity.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/ByteArrayEntity.java $
- * $Revision: 604625 $
- * $Date: 2007-12-16 06:11:11 -0800 (Sun, 16 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * An entity whose content is retrieved from a byte array.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 604625 $
- *
- * @since 4.0
- */
-public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
-
- protected final byte[] content;
-
- public ByteArrayEntity(final byte[] b) {
- super();
- if (b == null) {
- throw new IllegalArgumentException("Source byte array may not be null");
- }
- this.content = b;
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.content.length;
- }
-
- public InputStream getContent() {
- return new ByteArrayInputStream(this.content);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- outstream.write(this.content);
- outstream.flush();
- }
-
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-} // class ByteArrayEntity
diff --git a/src/org/apache/http/entity/ContentLengthStrategy.java b/src/org/apache/http/entity/ContentLengthStrategy.java
deleted file mode 100644
index cc4ab7d73d2742d901c7948ee09139efe53f2910..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/ContentLengthStrategy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/ContentLengthStrategy.java $
- * $Revision: 613298 $
- * $Date: 2008-01-18 14:09:22 -0800 (Fri, 18 Jan 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpMessage;
-
-/**
- * Represents a strategy to determine the content length based on the properties
- * of an HTTP message.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 613298 $
- *
- * @since 4.0
- */
-public interface ContentLengthStrategy {
-
- public static final int IDENTITY = -1;
- public static final int CHUNKED = -2;
-
- long determineLength(HttpMessage message) throws HttpException;
-
-}
diff --git a/src/org/apache/http/entity/ContentProducer.java b/src/org/apache/http/entity/ContentProducer.java
deleted file mode 100644
index 456eae3e37c39217f0b66bbcbd99316e49df459d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/ContentProducer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/ContentProducer.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * An abstract entity content producer.
- *
- *Content producers are expected to be able to produce their
- * content multiple times
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public interface ContentProducer {
-
- void writeTo(OutputStream outstream) throws IOException;
-
-}
diff --git a/src/org/apache/http/entity/EntityTemplate.java b/src/org/apache/http/entity/EntityTemplate.java
deleted file mode 100644
index 0c6002e73112c897834472d49a06437e267a4440..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/EntityTemplate.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/EntityTemplate.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Entity that delegates the process of content generation to an abstract
- * content producer.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public class EntityTemplate extends AbstractHttpEntity {
-
- private final ContentProducer contentproducer;
-
- public EntityTemplate(final ContentProducer contentproducer) {
- super();
- if (contentproducer == null) {
- throw new IllegalArgumentException("Content producer may not be null");
- }
- this.contentproducer = contentproducer;
- }
-
- public long getContentLength() {
- return -1;
- }
-
- public InputStream getContent() {
- throw new UnsupportedOperationException("Entity template does not implement getContent()");
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- this.contentproducer.writeTo(outstream);
- }
-
- public boolean isStreaming() {
- return true;
- }
-
- public void consumeContent() throws IOException {
- }
-
-}
diff --git a/src/org/apache/http/entity/FileEntity.java b/src/org/apache/http/entity/FileEntity.java
deleted file mode 100644
index a99105882f5346691c0bbef68b653c0d11c172f8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/FileEntity.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/FileEntity.java $
- * $Revision: 604625 $
- * $Date: 2007-12-16 06:11:11 -0800 (Sun, 16 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * An entity whose content is retrieved from a file.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 604625 $
- *
- * @since 4.0
- */
-public class FileEntity extends AbstractHttpEntity implements Cloneable {
-
- protected final File file;
-
- public FileEntity(final File file, final String contentType) {
- super();
- if (file == null) {
- throw new IllegalArgumentException("File may not be null");
- }
- this.file = file;
- setContentType(contentType);
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.file.length();
- }
-
- public InputStream getContent() throws IOException {
- return new FileInputStream(this.file);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- InputStream instream = new FileInputStream(this.file);
- try {
- byte[] tmp = new byte[4096];
- int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
- }
- outstream.flush();
- } finally {
- instream.close();
- }
- }
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- public Object clone() throws CloneNotSupportedException {
- // File instance is considered immutable
- // No need to make a copy of it
- return super.clone();
- }
-
-} // class FileEntity
diff --git a/src/org/apache/http/entity/HttpEntityWrapper.java b/src/org/apache/http/entity/HttpEntityWrapper.java
deleted file mode 100644
index 17a4149a0f319149866dbc108c3069641696978f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/HttpEntityWrapper.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/HttpEntityWrapper.java $
- * $Revision: 496070 $
- * $Date: 2007-01-14 04:18:34 -0800 (Sun, 14 Jan 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-
-/**
- * Base class for wrapping entities.
- * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all
- * calls to it. Implementations of wrapping entities can derive
- * from this class and need to override only those methods that
- * should not be delegated to the wrapped entity.
- *
- * @version $Revision: 496070 $
- *
- * @since 4.0
- */
-public class HttpEntityWrapper implements HttpEntity {
-
- /** The wrapped entity. */
- protected HttpEntity wrappedEntity;
-
- /**
- * Creates a new entity wrapper.
- *
- * @param wrapped the entity to wrap
- */
- public HttpEntityWrapper(HttpEntity wrapped) {
- super();
-
- if (wrapped == null) {
- throw new IllegalArgumentException
- ("wrapped entity must not be null");
- }
- wrappedEntity = wrapped;
-
- } // constructor
-
-
- public boolean isRepeatable() {
- return wrappedEntity.isRepeatable();
- }
-
- public boolean isChunked() {
- return wrappedEntity.isChunked();
- }
-
- public long getContentLength() {
- return wrappedEntity.getContentLength();
- }
-
- public Header getContentType() {
- return wrappedEntity.getContentType();
- }
-
- public Header getContentEncoding() {
- return wrappedEntity.getContentEncoding();
- }
-
- public InputStream getContent()
- throws IOException {
- return wrappedEntity.getContent();
- }
-
- public void writeTo(OutputStream outstream)
- throws IOException {
- wrappedEntity.writeTo(outstream);
- }
-
- public boolean isStreaming() {
- return wrappedEntity.isStreaming();
- }
-
- public void consumeContent()
- throws IOException {
- wrappedEntity.consumeContent();
- }
-
-} // class HttpEntityWrapper
diff --git a/src/org/apache/http/entity/InputStreamEntity.java b/src/org/apache/http/entity/InputStreamEntity.java
deleted file mode 100644
index 6d33fe44e0709bed5e986f5b03c80af64997e848..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/InputStreamEntity.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/InputStreamEntity.java $
- * $Revision: 617591 $
- * $Date: 2008-02-01 10:21:17 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * A streamed entity obtaining content from an {@link InputStream InputStream}.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 617591 $
- *
- * @since 4.0
- */
-public class InputStreamEntity extends AbstractHttpEntity {
-
- private final static int BUFFER_SIZE = 2048;
-
- private final InputStream content;
- private final long length;
- private boolean consumed = false;
-
- public InputStreamEntity(final InputStream instream, long length) {
- super();
- if (instream == null) {
- throw new IllegalArgumentException("Source input stream may not be null");
- }
- this.content = instream;
- this.length = length;
- }
-
- public boolean isRepeatable() {
- return false;
- }
-
- public long getContentLength() {
- return this.length;
- }
-
- public InputStream getContent() throws IOException {
- return this.content;
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- InputStream instream = this.content;
- byte[] buffer = new byte[BUFFER_SIZE];
- int l;
- if (this.length < 0) {
- // consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
- }
- } else {
- // consume no more than length
- long remaining = this.length;
- while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
- if (l == -1) {
- break;
- }
- outstream.write(buffer, 0, l);
- remaining -= l;
- }
- }
- this.consumed = true;
- }
-
- // non-javadoc, see interface HttpEntity
- public boolean isStreaming() {
- return !this.consumed;
- }
-
- // non-javadoc, see interface HttpEntity
- public void consumeContent() throws IOException {
- this.consumed = true;
- // If the input stream is from a connection, closing it will read to
- // the end of the content. Otherwise, we don't care what it does.
- this.content.close();
- }
-
-} // class InputStreamEntity
diff --git a/src/org/apache/http/entity/SerializableEntity.java b/src/org/apache/http/entity/SerializableEntity.java
deleted file mode 100644
index 171977b661c592a43fb8e182b2f0e7a373f8abf3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/SerializableEntity.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/SerializableEntity.java $
- * $Revision: 647816 $
- * $Date: 2008-04-14 07:37:13 -0700 (Mon, 14 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-
-public class SerializableEntity extends AbstractHttpEntity {
-
- private byte[] objSer;
-
- private Serializable objRef;
-
- public SerializableEntity(Serializable ser, boolean bufferize) throws IOException {
- super();
- if (ser == null) {
- throw new IllegalArgumentException("Source object may not be null");
- }
-
- if (bufferize) {
- createBytes(ser);
- } else {
- this.objRef = ser;
- }
- }
-
- private void createBytes(Serializable ser) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(ser);
- out.flush();
- this.objSer = baos.toByteArray();
- }
-
- public InputStream getContent() throws IOException, IllegalStateException {
- if (this.objSer == null) {
- createBytes(this.objRef);
- }
- return new ByteArrayInputStream(this.objSer);
- }
-
- public long getContentLength() {
- if (this.objSer == null) {
- return -1;
- } else {
- return this.objSer.length;
- }
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public boolean isStreaming() {
- return this.objSer == null;
- }
-
- public void writeTo(OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
-
- if (this.objSer == null) {
- ObjectOutputStream out = new ObjectOutputStream(outstream);
- out.writeObject(this.objRef);
- out.flush();
- } else {
- outstream.write(this.objSer);
- outstream.flush();
- }
- }
-
-}
diff --git a/src/org/apache/http/entity/StringEntity.java b/src/org/apache/http/entity/StringEntity.java
deleted file mode 100644
index cbc382b1baa55ed355e9129af4247ac9773c7466..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/StringEntity.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/entity/StringEntity.java $
- * $Revision: 618367 $
- * $Date: 2008-02-04 10:26:06 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.http.protocol.HTTP;
-
-/**
- * An entity whose content is retrieved from a string.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 618367 $
- *
- * @since 4.0
- */
-public class StringEntity extends AbstractHttpEntity implements Cloneable {
-
- protected final byte[] content;
-
- public StringEntity(final String s, String charset)
- throws UnsupportedEncodingException {
- super();
- if (s == null) {
- throw new IllegalArgumentException("Source string may not be null");
- }
- if (charset == null) {
- charset = HTTP.DEFAULT_CONTENT_CHARSET;
- }
- this.content = s.getBytes(charset);
- setContentType(HTTP.PLAIN_TEXT_TYPE + HTTP.CHARSET_PARAM + charset);
- }
-
- public StringEntity(final String s)
- throws UnsupportedEncodingException {
- this(s, null);
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.content.length;
- }
-
- public InputStream getContent() throws IOException {
- return new ByteArrayInputStream(this.content);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output stream may not be null");
- }
- outstream.write(this.content);
- outstream.flush();
- }
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-} // class StringEntity
diff --git a/src/org/apache/http/entity/package.html b/src/org/apache/http/entity/package.html
deleted file mode 100644
index 11d491e15a982b60654c9a455f602872416bd039..0000000000000000000000000000000000000000
--- a/src/org/apache/http/entity/package.html
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-Representations for HTTP message entities.
-
-An {@link org.apache.http.HttpEntity entity} is the optional content of a
-{@link org.apache.http.HttpMessage message}.
-You'll find a basic selection of entity implementations here.
-If you need to send an entity, you can provide it for example as a
-{@link org.apache.http.entity.ByteArrayEntity byte array},
-{@link org.apache.http.entity.StringEntity string},
-{@link org.apache.http.entity.FileEntity file}, or through an arbitrary
-{@link org.apache.http.entity.InputStreamEntity input stream}.
-If you receive a message with an entity, you typically get that as a
-{@link org.apache.http.entity.BasicHttpEntity basic} entity.
-Entity implementations can be
-{@link org.apache.http.entity.HttpEntityWrapper wrapped},
-for example to
-{@link org.apache.http.entity.BufferedHttpEntity buffer}
-the content in memory.
-
-
-
-
-
diff --git a/src/org/apache/http/impl/AbstractHttpClientConnection.java b/src/org/apache/http/impl/AbstractHttpClientConnection.java
deleted file mode 100644
index ebfaabbf74bd3e89413ca16b9188f2f0b54061a2..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/AbstractHttpClientConnection.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpClientConnection.java $
- * $Revision: 627457 $
- * $Date: 2008-02-13 07:14:19 -0800 (Wed, 13 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.impl.entity.EntityDeserializer;
-import org.apache.http.impl.entity.EntitySerializer;
-import org.apache.http.impl.entity.LaxContentLengthStrategy;
-import org.apache.http.impl.entity.StrictContentLengthStrategy;
-import org.apache.http.impl.io.HttpRequestWriter;
-import org.apache.http.impl.io.HttpResponseParser;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageWriter;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.params.HttpParams;
-
-/**
- * Abstract client-side HTTP connection capable of transmitting and receiving data
- * using arbitrary {@link SessionInputBuffer} and {@link SessionOutputBuffer}
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 627457 $
- *
- * @since 4.0
- */
-public abstract class AbstractHttpClientConnection implements HttpClientConnection {
-
- private final EntitySerializer entityserializer;
- private final EntityDeserializer entitydeserializer;
-
- private SessionInputBuffer inbuffer = null;
- private SessionOutputBuffer outbuffer = null;
- private HttpMessageParser responseParser = null;
- private HttpMessageWriter requestWriter = null;
- private HttpConnectionMetricsImpl metrics = null;
-
-
-
- public AbstractHttpClientConnection() {
- super();
- this.entityserializer = createEntitySerializer();
- this.entitydeserializer = createEntityDeserializer();
- }
-
- protected abstract void assertOpen() throws IllegalStateException;
-
- protected EntityDeserializer createEntityDeserializer() {
- return new EntityDeserializer(new LaxContentLengthStrategy());
- }
-
- protected EntitySerializer createEntitySerializer() {
- return new EntitySerializer(new StrictContentLengthStrategy());
- }
-
- protected HttpResponseFactory createHttpResponseFactory() {
- return new DefaultHttpResponseFactory();
- }
-
- protected HttpMessageParser createResponseParser(
- final SessionInputBuffer buffer,
- final HttpResponseFactory responseFactory,
- final HttpParams params) {
- // override in derived class to specify a line parser
- return new HttpResponseParser(buffer, null, responseFactory, params);
- }
-
- protected HttpMessageWriter createRequestWriter(
- final SessionOutputBuffer buffer,
- final HttpParams params) {
- // override in derived class to specify a line formatter
- return new HttpRequestWriter(buffer, null, params);
- }
-
- protected void init(
- final SessionInputBuffer inbuffer,
- final SessionOutputBuffer outbuffer,
- final HttpParams params) {
- if (inbuffer == null) {
- throw new IllegalArgumentException("Input session buffer may not be null");
- }
- if (outbuffer == null) {
- throw new IllegalArgumentException("Output session buffer may not be null");
- }
- this.inbuffer = inbuffer;
- this.outbuffer = outbuffer;
- this.responseParser = createResponseParser(
- inbuffer,
- createHttpResponseFactory(),
- params);
- this.requestWriter = createRequestWriter(
- outbuffer, params);
- this.metrics = new HttpConnectionMetricsImpl(
- inbuffer.getMetrics(),
- outbuffer.getMetrics());
- }
-
- public boolean isResponseAvailable(int timeout) throws IOException {
- assertOpen();
- return this.inbuffer.isDataAvailable(timeout);
- }
-
- public void sendRequestHeader(final HttpRequest request)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- assertOpen();
- this.requestWriter.write(request);
- this.metrics.incrementRequestCount();
- }
-
- public void sendRequestEntity(final HttpEntityEnclosingRequest request)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- assertOpen();
- if (request.getEntity() == null) {
- return;
- }
- this.entityserializer.serialize(
- this.outbuffer,
- request,
- request.getEntity());
- }
-
- protected void doFlush() throws IOException {
- this.outbuffer.flush();
- }
-
- public void flush() throws IOException {
- assertOpen();
- doFlush();
- }
-
- public HttpResponse receiveResponseHeader()
- throws HttpException, IOException {
- assertOpen();
- HttpResponse response = (HttpResponse) this.responseParser.parse();
- if (response.getStatusLine().getStatusCode() >= 200) {
- this.metrics.incrementResponseCount();
- }
- return response;
- }
-
- public void receiveResponseEntity(final HttpResponse response)
- throws HttpException, IOException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- assertOpen();
- HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, response);
- response.setEntity(entity);
- }
-
- public boolean isStale() {
- if (!isOpen()) {
- return true;
- }
- try {
- this.inbuffer.isDataAvailable(1);
- return false;
- } catch (IOException ex) {
- return true;
- }
- }
-
- public HttpConnectionMetrics getMetrics() {
- return this.metrics;
- }
-
-}
diff --git a/src/org/apache/http/impl/AbstractHttpServerConnection.java b/src/org/apache/http/impl/AbstractHttpServerConnection.java
deleted file mode 100644
index ef68ed3fbdede0f9d80299b2334027d8fcb27497..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/AbstractHttpServerConnection.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/AbstractHttpServerConnection.java $
- * $Revision: 618017 $
- * $Date: 2008-02-03 08:42:22 -0800 (Sun, 03 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpServerConnection;
-import org.apache.http.impl.entity.EntityDeserializer;
-import org.apache.http.impl.entity.EntitySerializer;
-import org.apache.http.impl.entity.LaxContentLengthStrategy;
-import org.apache.http.impl.entity.StrictContentLengthStrategy;
-import org.apache.http.impl.io.HttpRequestParser;
-import org.apache.http.impl.io.HttpResponseWriter;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageWriter;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.params.HttpParams;
-
-/**
- * Abstract server-side HTTP connection capable of transmitting and receiving data
- * using arbitrary {@link SessionInputBuffer} and {@link SessionOutputBuffer}
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 618017 $
- *
- * @since 4.0
- */
-public abstract class AbstractHttpServerConnection implements HttpServerConnection {
-
- private final EntitySerializer entityserializer;
- private final EntityDeserializer entitydeserializer;
-
- private SessionInputBuffer inbuffer = null;
- private SessionOutputBuffer outbuffer = null;
- private HttpMessageParser requestParser = null;
- private HttpMessageWriter responseWriter = null;
- private HttpConnectionMetricsImpl metrics = null;
-
-
-
- public AbstractHttpServerConnection() {
- super();
- this.entityserializer = createEntitySerializer();
- this.entitydeserializer = createEntityDeserializer();
- }
-
- protected abstract void assertOpen() throws IllegalStateException;
-
- protected EntityDeserializer createEntityDeserializer() {
- return new EntityDeserializer(new LaxContentLengthStrategy());
- }
-
- protected EntitySerializer createEntitySerializer() {
- return new EntitySerializer(new StrictContentLengthStrategy());
- }
-
- protected HttpRequestFactory createHttpRequestFactory() {
- return new DefaultHttpRequestFactory();
- }
-
- protected HttpMessageParser createRequestParser(
- final SessionInputBuffer buffer,
- final HttpRequestFactory requestFactory,
- final HttpParams params) {
- // override in derived class to specify a line parser
- return new HttpRequestParser(buffer, null, requestFactory, params);
- }
-
- protected HttpMessageWriter createResponseWriter(
- final SessionOutputBuffer buffer,
- final HttpParams params) {
- // override in derived class to specify a line formatter
- return new HttpResponseWriter(buffer, null, params);
- }
-
-
- protected void init(
- final SessionInputBuffer inbuffer,
- final SessionOutputBuffer outbuffer,
- final HttpParams params) {
- if (inbuffer == null) {
- throw new IllegalArgumentException("Input session buffer may not be null");
- }
- if (outbuffer == null) {
- throw new IllegalArgumentException("Output session buffer may not be null");
- }
- this.inbuffer = inbuffer;
- this.outbuffer = outbuffer;
- this.requestParser = createRequestParser(
- inbuffer,
- createHttpRequestFactory(),
- params);
- this.responseWriter = createResponseWriter(
- outbuffer, params);
- this.metrics = new HttpConnectionMetricsImpl(
- inbuffer.getMetrics(),
- outbuffer.getMetrics());
- }
-
- public HttpRequest receiveRequestHeader()
- throws HttpException, IOException {
- assertOpen();
- HttpRequest request = (HttpRequest) this.requestParser.parse();
- this.metrics.incrementRequestCount();
- return request;
- }
-
- public void receiveRequestEntity(final HttpEntityEnclosingRequest request)
- throws HttpException, IOException {
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- assertOpen();
- HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, request);
- request.setEntity(entity);
- }
-
- protected void doFlush() throws IOException {
- this.outbuffer.flush();
- }
-
- public void flush() throws IOException {
- assertOpen();
- doFlush();
- }
-
- public void sendResponseHeader(final HttpResponse response)
- throws HttpException, IOException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- assertOpen();
- this.responseWriter.write(response);
- if (response.getStatusLine().getStatusCode() >= 200) {
- this.metrics.incrementResponseCount();
- }
- }
-
- public void sendResponseEntity(final HttpResponse response)
- throws HttpException, IOException {
- if (response.getEntity() == null) {
- return;
- }
- this.entityserializer.serialize(
- this.outbuffer,
- response,
- response.getEntity());
- }
-
- public boolean isStale() {
- assertOpen();
- try {
- this.inbuffer.isDataAvailable(1);
- return false;
- } catch (IOException ex) {
- return true;
- }
- }
-
- public HttpConnectionMetrics getMetrics() {
- return this.metrics;
- }
-
-}
diff --git a/src/org/apache/http/impl/DefaultConnectionReuseStrategy.java b/src/org/apache/http/impl/DefaultConnectionReuseStrategy.java
deleted file mode 100644
index da1d5fd31b6e870f7ebd9c9e58ab22d10b5c9608..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/DefaultConnectionReuseStrategy.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategy.java $
- * $Revision: 602537 $
- * $Date: 2007-12-08 11:42:06 -0800 (Sat, 08 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpConnection;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.ParseException;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.TokenIterator;
-import org.apache.http.message.BasicTokenIterator;
-
-/**
- * Default implementation of a strategy deciding about connection re-use.
- * The default implementation first checks some basics, for example
- * whether the connection is still open or whether the end of the
- * request entity can be determined without closing the connection.
- * If these checks pass, the tokens in the "Connection" header will
- * be examined. In the absence of a "Connection" header, the
- * non-standard but commonly used "Proxy-Connection" header takes
- * it's role. A token "close" indicates that the connection cannot
- * be reused. If there is no such token, a token "keep-alive" indicates
- * that the connection should be re-used. If neither token is found,
- * or if there are no "Connection" headers, the default policy for
- * the HTTP version is applied. Since HTTP/1.1, connections are re-used
- * by default. Up until HTTP/1.0, connections are not re-used by default.
- *
- * @author Oleg Kalnichevski
- * @author Roland Weber
- *
- * @version $Revision: 602537 $
- *
- * @since 4.0
- */
-public class DefaultConnectionReuseStrategy
- implements ConnectionReuseStrategy {
-
- public DefaultConnectionReuseStrategy() {
- super();
- }
-
- // see interface ConnectionReuseStrategy
- public boolean keepAlive(final HttpResponse response,
- final HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException
- ("HTTP response may not be null.");
- }
- if (context == null) {
- throw new IllegalArgumentException
- ("HTTP context may not be null.");
- }
-
- HttpConnection conn = (HttpConnection)
- context.getAttribute(ExecutionContext.HTTP_CONNECTION);
-
- if (conn != null && !conn.isOpen())
- return false;
- // do NOT check for stale connection, that is an expensive operation
-
- // Check for a self-terminating entity. If the end of the entity will
- // be indicated by closing the connection, there is no keep-alive.
- HttpEntity entity = response.getEntity();
- ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
- if (entity != null) {
- if (entity.getContentLength() < 0) {
- if (!entity.isChunked() ||
- ver.lessEquals(HttpVersion.HTTP_1_0)) {
- // if the content length is not known and is not chunk
- // encoded, the connection cannot be reused
- return false;
- }
- }
- }
-
- // Check for the "Connection" header. If that is absent, check for
- // the "Proxy-Connection" header. The latter is an unspecified and
- // broken but unfortunately common extension of HTTP.
- HeaderIterator hit = response.headerIterator(HTTP.CONN_DIRECTIVE);
- if (!hit.hasNext())
- hit = response.headerIterator("Proxy-Connection");
-
- // Experimental usage of the "Connection" header in HTTP/1.0 is
- // documented in RFC 2068, section 19.7.1. A token "keep-alive" is
- // used to indicate that the connection should be persistent.
- // Note that the final specification of HTTP/1.1 in RFC 2616 does not
- // include this information. Neither is the "Connection" header
- // mentioned in RFC 1945, which informally describes HTTP/1.0.
- //
- // RFC 2616 specifies "close" as the only connection token with a
- // specific meaning: it disables persistent connections.
- //
- // The "Proxy-Connection" header is not formally specified anywhere,
- // but is commonly used to carry one token, "close" or "keep-alive".
- // The "Connection" header, on the other hand, is defined as a
- // sequence of tokens, where each token is a header name, and the
- // token "close" has the above-mentioned additional meaning.
- //
- // To get through this mess, we treat the "Proxy-Connection" header
- // in exactly the same way as the "Connection" header, but only if
- // the latter is missing. We scan the sequence of tokens for both
- // "close" and "keep-alive". As "close" is specified by RFC 2068,
- // it takes precedence and indicates a non-persistent connection.
- // If there is no "close" but a "keep-alive", we take the hint.
-
- if (hit.hasNext()) {
- try {
- TokenIterator ti = createTokenIterator(hit);
- boolean keepalive = false;
- while (ti.hasNext()) {
- final String token = ti.nextToken();
- if (HTTP.CONN_CLOSE.equalsIgnoreCase(token)) {
- return false;
- } else if (HTTP.CONN_KEEP_ALIVE.equalsIgnoreCase(token)) {
- // continue the loop, there may be a "close" afterwards
- keepalive = true;
- }
- }
- if (keepalive)
- return true;
- // neither "close" nor "keep-alive", use default policy
-
- } catch (ParseException px) {
- // invalid connection header means no persistent connection
- // we don't have logging in HttpCore, so the exception is lost
- return false;
- }
- }
-
- // default since HTTP/1.1 is persistent, before it was non-persistent
- return !ver.lessEquals(HttpVersion.HTTP_1_0);
- }
-
-
- /**
- * Creates a token iterator from a header iterator.
- * This method can be overridden to replace the implementation of
- * the token iterator.
- *
- * @param hit the header iterator
- *
- * @return the token iterator
- */
- protected TokenIterator createTokenIterator(HeaderIterator hit) {
- return new BasicTokenIterator(hit);
- }
-}
diff --git a/src/org/apache/http/impl/DefaultHttpClientConnection.java b/src/org/apache/http/impl/DefaultHttpClientConnection.java
deleted file mode 100644
index c0a96f5c5c26d762d684d4d91d598471745a552f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/DefaultHttpClientConnection.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java $
- * $Revision: 561083 $
- * $Date: 2007-07-30 11:31:17 -0700 (Mon, 30 Jul 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Default implementation of a client-side HTTP connection.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 561083 $
- *
- * @since 4.0
- */
-public class DefaultHttpClientConnection extends SocketHttpClientConnection {
-
- public DefaultHttpClientConnection() {
- super();
- }
-
- public void bind(
- final Socket socket,
- final HttpParams params) throws IOException {
- if (socket == null) {
- throw new IllegalArgumentException("Socket may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- assertNotOpen();
- socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
- socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
-
- int linger = HttpConnectionParams.getLinger(params);
- if (linger >= 0) {
- socket.setSoLinger(linger > 0, linger);
- }
- super.bind(socket, params);
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("[");
- if (isOpen()) {
- buffer.append(getRemotePort());
- } else {
- buffer.append("closed");
- }
- buffer.append("]");
- return buffer.toString();
- }
-
-}
diff --git a/src/org/apache/http/impl/DefaultHttpRequestFactory.java b/src/org/apache/http/impl/DefaultHttpRequestFactory.java
deleted file mode 100644
index dee36c9059d8ff532ea2b34f4df985f86b607412..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/DefaultHttpRequestFactory.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java $
- * $Revision: 618367 $
- * $Date: 2008-02-04 10:26:06 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestFactory;
-import org.apache.http.MethodNotSupportedException;
-import org.apache.http.RequestLine;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-
-/**
- * Default implementation of a factory for creating request objects.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 618367 $
- *
- * @since 4.0
- */
-public class DefaultHttpRequestFactory implements HttpRequestFactory {
-
- private static final String[] RFC2616_COMMON_METHODS = {
- "GET"
- };
-
- private static final String[] RFC2616_ENTITY_ENC_METHODS = {
- "POST",
- "PUT"
- };
-
- private static final String[] RFC2616_SPECIAL_METHODS = {
- "HEAD",
- "OPTIONS",
- "DELETE",
- "TRACE"
- };
-
-
- public DefaultHttpRequestFactory() {
- super();
- }
-
- private static boolean isOneOf(final String[] methods, final String method) {
- for (int i = 0; i < methods.length; i++) {
- if (methods[i].equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
- }
-
- public HttpRequest newHttpRequest(final RequestLine requestline)
- throws MethodNotSupportedException {
- if (requestline == null) {
- throw new IllegalArgumentException("Request line may not be null");
- }
- String method = requestline.getMethod();
- if (isOneOf(RFC2616_COMMON_METHODS, method)) {
- return new BasicHttpRequest(requestline);
- } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
- return new BasicHttpEntityEnclosingRequest(requestline);
- } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
- return new BasicHttpRequest(requestline);
- } else {
- throw new MethodNotSupportedException(method + " method not supported");
- }
- }
-
- public HttpRequest newHttpRequest(final String method, final String uri)
- throws MethodNotSupportedException {
- if (isOneOf(RFC2616_COMMON_METHODS, method)) {
- return new BasicHttpRequest(method, uri);
- } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
- return new BasicHttpEntityEnclosingRequest(method, uri);
- } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
- return new BasicHttpRequest(method, uri);
- } else {
- throw new MethodNotSupportedException(method
- + " method not supported");
- }
- }
-
-}
diff --git a/src/org/apache/http/impl/DefaultHttpResponseFactory.java b/src/org/apache/http/impl/DefaultHttpResponseFactory.java
deleted file mode 100644
index 40a2c9ada181e3261ddac8bc53cd8bfe6a1363fd..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/DefaultHttpResponseFactory.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpResponseFactory.java $
- * $Revision: 618367 $
- * $Date: 2008-02-04 10:26:06 -0800 (Mon, 04 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.util.Locale;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.StatusLine;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.ReasonPhraseCatalog;
-import org.apache.http.impl.EnglishReasonPhraseCatalog;
-
-/**
- * Default implementation of a factory for creating response objects.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 618367 $
- *
- * @since 4.0
- */
-public class DefaultHttpResponseFactory implements HttpResponseFactory {
-
- /** The catalog for looking up reason phrases. */
- protected final ReasonPhraseCatalog reasonCatalog;
-
-
- /**
- * Creates a new response factory with the given catalog.
- *
- * @param catalog the catalog of reason phrases
- */
- public DefaultHttpResponseFactory(ReasonPhraseCatalog catalog) {
- if (catalog == null) {
- throw new IllegalArgumentException
- ("Reason phrase catalog must not be null.");
- }
- this.reasonCatalog = catalog;
- }
-
- /**
- * Creates a new response factory with the default catalog.
- * The default catalog is
- * {@link EnglishReasonPhraseCatalog EnglishReasonPhraseCatalog}.
- */
- public DefaultHttpResponseFactory() {
- this(EnglishReasonPhraseCatalog.INSTANCE);
- }
-
-
- // non-javadoc, see interface HttpResponseFactory
- public HttpResponse newHttpResponse(final ProtocolVersion ver,
- final int status,
- HttpContext context) {
- if (ver == null) {
- throw new IllegalArgumentException("HTTP version may not be null");
- }
- final Locale loc = determineLocale(context);
- final String reason = reasonCatalog.getReason(status, loc);
- StatusLine statusline = new BasicStatusLine(ver, status, reason);
- return new BasicHttpResponse(statusline, reasonCatalog, loc);
- }
-
-
- // non-javadoc, see interface HttpResponseFactory
- public HttpResponse newHttpResponse(final StatusLine statusline,
- HttpContext context) {
- if (statusline == null) {
- throw new IllegalArgumentException("Status line may not be null");
- }
- final Locale loc = determineLocale(context);
- return new BasicHttpResponse(statusline, reasonCatalog, loc);
- }
-
-
- /**
- * Determines the locale of the response.
- * The implementation in this class always returns the default locale.
- *
- * @param context the context from which to determine the locale, or
- * null to use the default locale
- *
- * @return the locale for the response, never null
- */
- protected Locale determineLocale(HttpContext context) {
- return Locale.getDefault();
- }
-}
diff --git a/src/org/apache/http/impl/DefaultHttpServerConnection.java b/src/org/apache/http/impl/DefaultHttpServerConnection.java
deleted file mode 100644
index d296fc8ffa5aea0aa6bb26caed2524e19c89a536..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/DefaultHttpServerConnection.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java $
- * $Revision: 561083 $
- * $Date: 2007-07-30 11:31:17 -0700 (Mon, 30 Jul 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Default implementation of a server-side HTTP connection.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 561083 $
- *
- * @since 4.0
- */
-public class DefaultHttpServerConnection extends SocketHttpServerConnection {
-
- public DefaultHttpServerConnection() {
- super();
- }
-
- public void bind(final Socket socket, final HttpParams params) throws IOException {
- if (socket == null) {
- throw new IllegalArgumentException("Socket may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- assertNotOpen();
- socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
- socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
-
- int linger = HttpConnectionParams.getLinger(params);
- if (linger >= 0) {
- socket.setSoLinger(linger > 0, linger);
- }
- super.bind(socket, params);
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("[");
- if (isOpen()) {
- buffer.append(getRemotePort());
- } else {
- buffer.append("closed");
- }
- buffer.append("]");
- return buffer.toString();
- }
-
-}
diff --git a/src/org/apache/http/impl/EnglishReasonPhraseCatalog.java b/src/org/apache/http/impl/EnglishReasonPhraseCatalog.java
deleted file mode 100644
index f1aeee1aa968d198e72f8e3d2623062ecafc3d32..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/EnglishReasonPhraseCatalog.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalog.java $
- * $Revision: 505744 $
- * $Date: 2007-02-10 10:58:45 -0800 (Sat, 10 Feb 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.util.Locale;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.ReasonPhraseCatalog;
-
-
-/**
- * English reason phrases for HTTP status codes.
- * All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and
- * RFC2518 (WebDAV) are supported.
- *
- * @author Unascribed
- * @author Mike Bowler
- * @author Jeff Dever
- *
- * @version $Revision: 505744 $
- */
-public class EnglishReasonPhraseCatalog
- implements ReasonPhraseCatalog {
-
- // static array with english reason phrases defined below
-
- /**
- * The default instance of this catalog.
- * This catalog is thread safe, so there typically
- * is no need to create other instances.
- */
- public final static EnglishReasonPhraseCatalog INSTANCE =
- new EnglishReasonPhraseCatalog();
-
-
- /**
- * Restricted default constructor, for derived classes.
- * If you need an instance of this class, use {@link #INSTANCE INSTANCE}.
- */
- protected EnglishReasonPhraseCatalog() {
- // no body
- }
-
-
- /**
- * Obtains the reason phrase for a status code.
- *
- * @param status the status code, in the range 100-599
- * @param loc ignored
- *
- * @return the reason phrase, or null
- */
- public String getReason(int status, Locale loc) {
- if ((status < 100) || (status >= 600)) {
- throw new IllegalArgumentException
- ("Unknown category for status code " + status + ".");
- }
-
- final int category = status / 100;
- final int subcode = status - 100*category;
-
- String reason = null;
- if (REASON_PHRASES[category].length > subcode)
- reason = REASON_PHRASES[category][subcode];
-
- return reason;
- }
-
-
- /** Reason phrases lookup table. */
- private static final String[][] REASON_PHRASES = new String[][]{
- null,
- new String[3], // 1xx
- new String[8], // 2xx
- new String[8], // 3xx
- new String[25], // 4xx
- new String[8] // 5xx
- };
-
-
-
- /**
- * Stores the given reason phrase, by status code.
- * Helper method to initialize the static lookup table.
- *
- * @param status the status code for which to define the phrase
- * @param reason the reason phrase for this status code
- */
- private static void setReason(int status, String reason) {
- final int category = status / 100;
- final int subcode = status - 100*category;
- REASON_PHRASES[category][subcode] = reason;
- }
-
-
- // ----------------------------------------------------- Static Initializer
-
- /** Set up status code to "reason phrase" map. */
- static {
- // HTTP 1.0 Server status codes -- see RFC 1945
- setReason(HttpStatus.SC_OK,
- "OK");
- setReason(HttpStatus.SC_CREATED,
- "Created");
- setReason(HttpStatus.SC_ACCEPTED,
- "Accepted");
- setReason(HttpStatus.SC_NO_CONTENT,
- "No Content");
- setReason(HttpStatus.SC_MOVED_PERMANENTLY,
- "Moved Permanently");
- setReason(HttpStatus.SC_MOVED_TEMPORARILY,
- "Moved Temporarily");
- setReason(HttpStatus.SC_NOT_MODIFIED,
- "Not Modified");
- setReason(HttpStatus.SC_BAD_REQUEST,
- "Bad Request");
- setReason(HttpStatus.SC_UNAUTHORIZED,
- "Unauthorized");
- setReason(HttpStatus.SC_FORBIDDEN,
- "Forbidden");
- setReason(HttpStatus.SC_NOT_FOUND,
- "Not Found");
- setReason(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- "Internal Server Error");
- setReason(HttpStatus.SC_NOT_IMPLEMENTED,
- "Not Implemented");
- setReason(HttpStatus.SC_BAD_GATEWAY,
- "Bad Gateway");
- setReason(HttpStatus.SC_SERVICE_UNAVAILABLE,
- "Service Unavailable");
-
- // HTTP 1.1 Server status codes -- see RFC 2048
- setReason(HttpStatus.SC_CONTINUE,
- "Continue");
- setReason(HttpStatus.SC_TEMPORARY_REDIRECT,
- "Temporary Redirect");
- setReason(HttpStatus.SC_METHOD_NOT_ALLOWED,
- "Method Not Allowed");
- setReason(HttpStatus.SC_CONFLICT,
- "Conflict");
- setReason(HttpStatus.SC_PRECONDITION_FAILED,
- "Precondition Failed");
- setReason(HttpStatus.SC_REQUEST_TOO_LONG,
- "Request Too Long");
- setReason(HttpStatus.SC_REQUEST_URI_TOO_LONG,
- "Request-URI Too Long");
- setReason(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported Media Type");
- setReason(HttpStatus.SC_MULTIPLE_CHOICES,
- "Multiple Choices");
- setReason(HttpStatus.SC_SEE_OTHER,
- "See Other");
- setReason(HttpStatus.SC_USE_PROXY,
- "Use Proxy");
- setReason(HttpStatus.SC_PAYMENT_REQUIRED,
- "Payment Required");
- setReason(HttpStatus.SC_NOT_ACCEPTABLE,
- "Not Acceptable");
- setReason(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED,
- "Proxy Authentication Required");
- setReason(HttpStatus.SC_REQUEST_TIMEOUT,
- "Request Timeout");
-
- setReason(HttpStatus.SC_SWITCHING_PROTOCOLS,
- "Switching Protocols");
- setReason(HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION,
- "Non Authoritative Information");
- setReason(HttpStatus.SC_RESET_CONTENT,
- "Reset Content");
- setReason(HttpStatus.SC_PARTIAL_CONTENT,
- "Partial Content");
- setReason(HttpStatus.SC_GATEWAY_TIMEOUT,
- "Gateway Timeout");
- setReason(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED,
- "Http Version Not Supported");
- setReason(HttpStatus.SC_GONE,
- "Gone");
- setReason(HttpStatus.SC_LENGTH_REQUIRED,
- "Length Required");
- setReason(HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE,
- "Requested Range Not Satisfiable");
- setReason(HttpStatus.SC_EXPECTATION_FAILED,
- "Expectation Failed");
-
- // WebDAV Server-specific status codes
- setReason(HttpStatus.SC_PROCESSING,
- "Processing");
- setReason(HttpStatus.SC_MULTI_STATUS,
- "Multi-Status");
- setReason(HttpStatus.SC_UNPROCESSABLE_ENTITY,
- "Unprocessable Entity");
- setReason(HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE,
- "Insufficient Space On Resource");
- setReason(HttpStatus.SC_METHOD_FAILURE,
- "Method Failure");
- setReason(HttpStatus.SC_LOCKED,
- "Locked");
- setReason(HttpStatus.SC_INSUFFICIENT_STORAGE,
- "Insufficient Storage");
- setReason(HttpStatus.SC_FAILED_DEPENDENCY,
- "Failed Dependency");
- }
-
-
-}
diff --git a/src/org/apache/http/impl/HttpConnectionMetricsImpl.java b/src/org/apache/http/impl/HttpConnectionMetricsImpl.java
deleted file mode 100644
index 4f4eacf75ecbd4512a91fd23e146bfd6f49738c6..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/HttpConnectionMetricsImpl.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java $
- * $Revision: 548031 $
- * $Date: 2007-06-17 04:28:38 -0700 (Sun, 17 Jun 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.util.HashMap;
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.io.HttpTransportMetrics;
-
-/**
- * Implementation of the metrics interface.
- */
-public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
-
- public static final String REQUEST_COUNT = "http.request-count";
- public static final String RESPONSE_COUNT = "http.response-count";
- public static final String SENT_BYTES_COUNT = "http.sent-bytes-count";
- public static final String RECEIVED_BYTES_COUNT = "http.received-bytes-count";
-
- private final HttpTransportMetrics inTransportMetric;
- private final HttpTransportMetrics outTransportMetric;
- private long requestCount = 0;
- private long responseCount = 0;
-
- /**
- * The cache map for all metrics values.
- */
- private HashMap metricsCache;
-
- public HttpConnectionMetricsImpl(
- final HttpTransportMetrics inTransportMetric,
- final HttpTransportMetrics outTransportMetric) {
- super();
- this.inTransportMetric = inTransportMetric;
- this.outTransportMetric = outTransportMetric;
- }
-
- /* ------------------ Public interface method -------------------------- */
-
- public long getReceivedBytesCount() {
- if (this.inTransportMetric != null) {
- return this.inTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
- }
-
- public long getSentBytesCount() {
- if (this.outTransportMetric != null) {
- return this.outTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
- }
-
- public long getRequestCount() {
- return this.requestCount;
- }
-
- public void incrementRequestCount() {
- this.requestCount++;
- }
-
- public long getResponseCount() {
- return this.responseCount;
- }
-
- public void incrementResponseCount() {
- this.responseCount++;
- }
-
- public Object getMetric(final String metricName) {
- Object value = null;
- if (this.metricsCache != null) {
- value = this.metricsCache.get(metricName);
- }
- if (value == null) {
- if (REQUEST_COUNT.equals(metricName)) {
- value = new Long(requestCount);
- } else if (RESPONSE_COUNT.equals(metricName)) {
- value = new Long(responseCount);
- } else if (RECEIVED_BYTES_COUNT.equals(metricName)) {
- if (this.inTransportMetric != null) {
- return new Long(this.inTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
- } else if (SENT_BYTES_COUNT.equals(metricName)) {
- if (this.outTransportMetric != null) {
- return new Long(this.outTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
- }
- }
- return value;
- }
-
- public void setMetric(final String metricName, Object obj) {
- if (this.metricsCache == null) {
- this.metricsCache = new HashMap();
- }
- this.metricsCache.put(metricName, obj);
- }
-
- public void reset() {
- if (this.outTransportMetric != null) {
- this.outTransportMetric.reset();
- }
- if (this.inTransportMetric != null) {
- this.inTransportMetric.reset();
- }
- this.requestCount = 0;
- this.responseCount = 0;
- this.metricsCache = null;
- }
-
-}
diff --git a/src/org/apache/http/impl/NoConnectionReuseStrategy.java b/src/org/apache/http/impl/NoConnectionReuseStrategy.java
deleted file mode 100644
index c7a5f73f2a0253d2fced30aa483d4d21a5592df9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/NoConnectionReuseStrategy.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/NoConnectionReuseStrategy.java $
- * $Revision: 502684 $
- * $Date: 2007-02-02 10:25:38 -0800 (Fri, 02 Feb 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpResponse;
-import org.apache.http.protocol.HttpContext;
-
-
-/**
- * A strategy that never re-uses a connection.
- *
- * @author Roland Weber
- *
- * @version $Revision: 502684 $
- *
- * @since 4.0
- */
-public class NoConnectionReuseStrategy implements ConnectionReuseStrategy {
-
- // default constructor
-
-
- // non-JavaDoc, see interface ConnectionReuseStrategy
- public boolean keepAlive(final HttpResponse response, final HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
-
- return false;
- }
-
-}
diff --git a/src/org/apache/http/impl/SocketHttpClientConnection.java b/src/org/apache/http/impl/SocketHttpClientConnection.java
deleted file mode 100644
index 1e551e0c5f13f5eb11bbb4f6da95a07d4571cdc2..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/SocketHttpClientConnection.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpClientConnection.java $
- * $Revision: 561083 $
- * $Date: 2007-07-30 11:31:17 -0700 (Mon, 30 Jul 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-
-import org.apache.http.HttpInetConnection;
-import org.apache.http.impl.io.SocketInputBuffer;
-import org.apache.http.impl.io.SocketOutputBuffer;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Implementation of a client-side HTTP connection that can be bound to a
- * network Socket in order to receive and transmit data.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 561083 $
- *
- * @since 4.0
- */
-public class SocketHttpClientConnection
- extends AbstractHttpClientConnection implements HttpInetConnection {
-
- private volatile boolean open;
- private Socket socket = null;
-
- public SocketHttpClientConnection() {
- super();
- }
-
- protected void assertNotOpen() {
- if (this.open) {
- throw new IllegalStateException("Connection is already open");
- }
- }
-
- protected void assertOpen() {
- if (!this.open) {
- throw new IllegalStateException("Connection is not open");
- }
- }
-
- protected SessionInputBuffer createSessionInputBuffer(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
- }
-
- protected SessionOutputBuffer createSessionOutputBuffer(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
- }
-
- protected void bind(
- final Socket socket,
- final HttpParams params) throws IOException {
- if (socket == null) {
- throw new IllegalArgumentException("Socket may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- this.socket = socket;
-
- int buffersize = HttpConnectionParams.getSocketBufferSize(params);
-
- init(
- createSessionInputBuffer(socket, buffersize, params),
- createSessionOutputBuffer(socket, buffersize, params),
- params);
-
- this.open = true;
- }
-
- public boolean isOpen() {
- return this.open;
- }
-
- protected Socket getSocket() {
- return this.socket;
- }
-
- public InetAddress getLocalAddress() {
- if (this.socket != null) {
- return this.socket.getLocalAddress();
- } else {
- return null;
- }
- }
-
- public int getLocalPort() {
- if (this.socket != null) {
- return this.socket.getLocalPort();
- } else {
- return -1;
- }
- }
-
- public InetAddress getRemoteAddress() {
- if (this.socket != null) {
- return this.socket.getInetAddress();
- } else {
- return null;
- }
- }
-
- public int getRemotePort() {
- if (this.socket != null) {
- return this.socket.getPort();
- } else {
- return -1;
- }
- }
-
- public void setSocketTimeout(int timeout) {
- assertOpen();
- if (this.socket != null) {
- try {
- this.socket.setSoTimeout(timeout);
- } catch (SocketException ignore) {
- // It is not quite clear from the Sun's documentation if there are any
- // other legitimate cases for a socket exception to be thrown when setting
- // SO_TIMEOUT besides the socket being already closed
- }
- }
- }
-
- public int getSocketTimeout() {
- if (this.socket != null) {
- try {
- return this.socket.getSoTimeout();
- } catch (SocketException ignore) {
- return -1;
- }
- } else {
- return -1;
- }
- }
-
- public void shutdown() throws IOException {
- this.open = false;
- Socket tmpsocket = this.socket;
- if (tmpsocket != null) {
- tmpsocket.close();
- }
- }
-
- public void close() throws IOException {
- if (!this.open) {
- return;
- }
- this.open = false;
- doFlush();
- try {
- try {
- this.socket.shutdownOutput();
- } catch (IOException ignore) {
- }
- try {
- this.socket.shutdownInput();
- } catch (IOException ignore) {
- }
- } catch (UnsupportedOperationException ignore) {
- // if one isn't supported, the other one isn't either
- }
- this.socket.close();
- }
-
-}
diff --git a/src/org/apache/http/impl/SocketHttpServerConnection.java b/src/org/apache/http/impl/SocketHttpServerConnection.java
deleted file mode 100644
index cfa2bf9b35abb762857949b2f1eb1d51363b5489..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/SocketHttpServerConnection.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/SocketHttpServerConnection.java $
- * $Revision: 561083 $
- * $Date: 2007-07-30 11:31:17 -0700 (Mon, 30 Jul 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-
-import org.apache.http.HttpInetConnection;
-import org.apache.http.impl.io.SocketInputBuffer;
-import org.apache.http.impl.io.SocketOutputBuffer;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-
-/**
- * Implementation of a server-side HTTP connection that can be bound to a
- * network Socket in order to receive and transmit data.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 561083 $
- *
- * @since 4.0
- */
-public class SocketHttpServerConnection extends
- AbstractHttpServerConnection implements HttpInetConnection {
-
- private volatile boolean open;
- private Socket socket = null;
-
- public SocketHttpServerConnection() {
- super();
- }
-
- protected void assertNotOpen() {
- if (this.open) {
- throw new IllegalStateException("Connection is already open");
- }
- }
-
- protected void assertOpen() {
- if (!this.open) {
- throw new IllegalStateException("Connection is not open");
- }
- }
-
- protected SessionInputBuffer createHttpDataReceiver(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
- }
-
- protected SessionOutputBuffer createHttpDataTransmitter(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
- }
-
- protected void bind(final Socket socket, final HttpParams params) throws IOException {
- if (socket == null) {
- throw new IllegalArgumentException("Socket may not be null");
- }
- if (params == null) {
- throw new IllegalArgumentException("HTTP parameters may not be null");
- }
- this.socket = socket;
-
- int buffersize = HttpConnectionParams.getSocketBufferSize(params);
-
- init(
- createHttpDataReceiver(socket, buffersize, params),
- createHttpDataTransmitter(socket, buffersize, params),
- params);
-
- this.open = true;
- }
-
- protected Socket getSocket() {
- return this.socket;
- }
-
- public boolean isOpen() {
- return this.open;
- }
-
- public InetAddress getLocalAddress() {
- if (this.socket != null) {
- return this.socket.getLocalAddress();
- } else {
- return null;
- }
- }
-
- public int getLocalPort() {
- if (this.socket != null) {
- return this.socket.getLocalPort();
- } else {
- return -1;
- }
- }
-
- public InetAddress getRemoteAddress() {
- if (this.socket != null) {
- return this.socket.getInetAddress();
- } else {
- return null;
- }
- }
-
- public int getRemotePort() {
- if (this.socket != null) {
- return this.socket.getPort();
- } else {
- return -1;
- }
- }
-
- public void setSocketTimeout(int timeout) {
- assertOpen();
- if (this.socket != null) {
- try {
- this.socket.setSoTimeout(timeout);
- } catch (SocketException ignore) {
- // It is not quite clear from the Sun's documentation if there are any
- // other legitimate cases for a socket exception to be thrown when setting
- // SO_TIMEOUT besides the socket being already closed
- }
- }
- }
-
- public int getSocketTimeout() {
- if (this.socket != null) {
- try {
- return this.socket.getSoTimeout();
- } catch (SocketException ignore) {
- return -1;
- }
- } else {
- return -1;
- }
- }
-
- public void shutdown() throws IOException {
- this.open = false;
- Socket tmpsocket = this.socket;
- if (tmpsocket != null) {
- tmpsocket.close();
- }
- }
-
- public void close() throws IOException {
- if (!this.open) {
- return;
- }
- this.open = false;
- doFlush();
- try {
- this.socket.shutdownOutput();
- } catch (IOException ignore) {
- }
- try {
- this.socket.shutdownInput();
- } catch (IOException ignore) {
- }
- this.socket.close();
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/AuthSchemeBase.java b/src/org/apache/http/impl/auth/AuthSchemeBase.java
deleted file mode 100644
index 689ce5d0da371f93315ed968db760a10ebf10305..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/AuthSchemeBase.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java $
- * $Revision: 653867 $
- * $Date: 2008-05-06 11:17:29 -0700 (Tue, 06 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Abstract authentication scheme class that serves as a basis
- * for all authentication schemes supported by HttpClient. This class
- * defines the generic way of parsing an authentication challenge. It
- * does not make any assumptions regarding the format of the challenge
- * nor does it impose any specific way of responding to that challenge.
- *
- * @author Oleg Kalnichevski
-*/
-public abstract class AuthSchemeBase implements AuthScheme {
-
- /**
- * Flag whether authenticating against a proxy.
- */
- private boolean proxy;
-
- public AuthSchemeBase() {
- super();
- }
-
- /**
- * Processes the given challenge token. Some authentication schemes
- * may involve multiple challenge-response exchanges. Such schemes must be able
- * to maintain the state information when dealing with sequential challenges
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- public void processChallenge(final Header header) throws MalformedChallengeException {
- if (header == null) {
- throw new IllegalArgumentException("Header may not be null");
- }
- String authheader = header.getName();
- if (authheader.equalsIgnoreCase(AUTH.WWW_AUTH)) {
- this.proxy = false;
- } else if (authheader.equalsIgnoreCase(AUTH.PROXY_AUTH)) {
- this.proxy = true;
- } else {
- throw new MalformedChallengeException("Unexpected header name: " + authheader);
- }
-
- CharArrayBuffer buffer;
- int pos;
- if (header instanceof FormattedHeader) {
- buffer = ((FormattedHeader) header).getBuffer();
- pos = ((FormattedHeader) header).getValuePos();
- } else {
- String s = header.getValue();
- if (s == null) {
- throw new MalformedChallengeException("Header value is null");
- }
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
- pos = 0;
- }
- while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- int beginIndex = pos;
- while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- int endIndex = pos;
- String s = buffer.substring(beginIndex, endIndex);
- if (!s.equalsIgnoreCase(getSchemeName())) {
- throw new MalformedChallengeException("Invalid scheme identifier: " + s);
- }
-
- parseChallenge(buffer, pos, buffer.length());
- }
-
- protected abstract void parseChallenge(
- CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException;
-
- /**
- * Returns true if authenticating against a proxy, false
- * otherwise.
- *
- * @return true if authenticating against a proxy, false
- * otherwise
- */
- public boolean isProxy() {
- return this.proxy;
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/BasicScheme.java b/src/org/apache/http/impl/auth/BasicScheme.java
deleted file mode 100644
index 88ea1109f5492e30534a52c3d42945d723573ca3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/BasicScheme.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/BasicScheme.java $
- * $Revision: 658430 $
- * $Date: 2008-05-20 14:04:27 -0700 (Tue, 20 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.params.AuthParams;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EncodingUtils;
-
-/**
- *
- * Basic authentication scheme as defined in RFC 2617.
- *
- *
- * @author Remy Maucherat
- * @author Rodney Waldhoff
- * @author Jeff Dever
- * @author Ortwin Glueck
- * @author Sean C. Sullivan
- * @author Adrian Sutton
- * @author Mike Bowler
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-
-public class BasicScheme extends RFC2617Scheme {
-
- /** Whether the basic authentication process is complete */
- private boolean complete;
-
- /**
- * Default constructor for the basic authetication scheme.
- */
- public BasicScheme() {
- super();
- this.complete = false;
- }
-
- /**
- * Returns textual designation of the basic authentication scheme.
- *
- * @return basic
- */
- public String getSchemeName() {
- return "basic";
- }
-
- /**
- * Processes the Basic challenge.
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- @Override
- public void processChallenge(
- final Header header) throws MalformedChallengeException {
- super.processChallenge(header);
- this.complete = true;
- }
-
- /**
- * Tests if the Basic authentication process has been completed.
- *
- * @return true if Basic authorization has been processed,
- * false otherwise.
- */
- public boolean isComplete() {
- return this.complete;
- }
-
- /**
- * Returns false. Basic authentication scheme is request based.
- *
- * @return false.
- */
- public boolean isConnectionBased() {
- return false;
- }
-
- /**
- * Produces basic authorization header for the given set of {@link Credentials}.
- *
- * @param credentials The set of credentials to be used for athentication
- * @param request The request being authenticated
- * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
- * are not valid or not applicable for this authentication scheme
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return a basic authorization string
- */
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request) throws AuthenticationException {
-
- if (credentials == null) {
- throw new IllegalArgumentException("Credentials may not be null");
- }
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
-
- String charset = AuthParams.getCredentialCharset(request.getParams());
- return authenticate(credentials, charset, isProxy());
- }
-
- /**
- * Returns a basic Authorization header value for the given
- * {@link Credentials} and charset.
- *
- * @param credentials The credentials to encode.
- * @param charset The charset to use for encoding the credentials
- *
- * @return a basic authorization header
- */
- public static Header authenticate(
- final Credentials credentials,
- final String charset,
- boolean proxy) {
- if (credentials == null) {
- throw new IllegalArgumentException("Credentials may not be null");
- }
- if (charset == null) {
- throw new IllegalArgumentException("charset may not be null");
- }
-
- StringBuilder tmp = new StringBuilder();
- tmp.append(credentials.getUserPrincipal().getName());
- tmp.append(":");
- tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
-
- byte[] base64password = Base64.encodeBase64(
- EncodingUtils.getBytes(tmp.toString(), charset));
-
- CharArrayBuffer buffer = new CharArrayBuffer(32);
- if (proxy) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": Basic ");
- buffer.append(base64password, 0, base64password.length);
-
- return new BufferedHeader(buffer);
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/BasicSchemeFactory.java b/src/org/apache/http/impl/auth/BasicSchemeFactory.java
deleted file mode 100644
index c5d28b0fec0c071536339f7bd86342e9e3f81fd6..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/BasicSchemeFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/BasicSchemeFactory.java $
- * $Revision: 534839 $
- * $Date: 2007-05-03 06:03:41 -0700 (Thu, 03 May 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeFactory;
-import org.apache.http.params.HttpParams;
-
-/**
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class BasicSchemeFactory implements AuthSchemeFactory {
-
- public AuthScheme newInstance(final HttpParams params) {
- return new BasicScheme();
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/DigestScheme.java b/src/org/apache/http/impl/auth/DigestScheme.java
deleted file mode 100644
index 803807b3a91e3eac3f3f75b3fc5e0fe652ce3db7..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/DigestScheme.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/DigestScheme.java $
- * $Revision: 659595 $
- * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.params.AuthParams;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.message.BasicHeaderValueFormatter;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EncodingUtils;
-
-/**
- *
- * Digest authentication scheme as defined in RFC 2617.
- * Both MD5 (default) and MD5-sess are supported.
- * Currently only qop=auth or no qop is supported. qop=auth-int
- * is unsupported. If auth and auth-int are provided, auth is
- * used.
- *
- *
- * Credential charset is configured via the
- * {@link org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET
- * credential charset} parameter.
- * Since the digest username is included as clear text in the generated
- * Authentication header, the charset of the username must be compatible
- * with the
- * {@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET
- * http element charset}.
- *
- *
- * @author Remy Maucherat
- * @author Rodney Waldhoff
- * @author Jeff Dever
- * @author Ortwin Glueck
- * @author Sean C. Sullivan
- * @author Adrian Sutton
- * @author Mike Bowler
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-
-public class DigestScheme extends RFC2617Scheme {
-
- /**
- * Hexa values used when creating 32 character long digest in HTTP DigestScheme
- * in case of authentication.
- *
- * @see #encode(byte[])
- */
- private static final char[] HEXADECIMAL = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
- 'e', 'f'
- };
-
- /** Whether the digest authentication process is complete */
- private boolean complete;
-
- //TODO: supply a real nonce-count, currently a server will interprete a repeated request as a replay
- private static final String NC = "00000001"; //nonce-count is always 1
- private static final int QOP_MISSING = 0;
- private static final int QOP_AUTH_INT = 1;
- private static final int QOP_AUTH = 2;
-
- private int qopVariant = QOP_MISSING;
- private String cnonce;
-
- /**
- * Default constructor for the digest authetication scheme.
- */
- public DigestScheme() {
- super();
- this.complete = false;
- }
-
- /**
- * Processes the Digest challenge.
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- @Override
- public void processChallenge(
- final Header header) throws MalformedChallengeException {
- super.processChallenge(header);
-
- if (getParameter("realm") == null) {
- throw new MalformedChallengeException("missing realm in challange");
- }
- if (getParameter("nonce") == null) {
- throw new MalformedChallengeException("missing nonce in challange");
- }
-
- boolean unsupportedQop = false;
- // qop parsing
- String qop = getParameter("qop");
- if (qop != null) {
- StringTokenizer tok = new StringTokenizer(qop,",");
- while (tok.hasMoreTokens()) {
- String variant = tok.nextToken().trim();
- if (variant.equals("auth")) {
- qopVariant = QOP_AUTH;
- break; //that's our favourite, because auth-int is unsupported
- } else if (variant.equals("auth-int")) {
- qopVariant = QOP_AUTH_INT;
- } else {
- unsupportedQop = true;
- }
- }
- }
-
- if (unsupportedQop && (qopVariant == QOP_MISSING)) {
- throw new MalformedChallengeException("None of the qop methods is supported");
- }
- // Reset cnonce
- this.cnonce = null;
- this.complete = true;
- }
-
- /**
- * Tests if the Digest authentication process has been completed.
- *
- * @return true if Digest authorization has been processed,
- * false otherwise.
- */
- public boolean isComplete() {
- String s = getParameter("stale");
- if ("true".equalsIgnoreCase(s)) {
- return false;
- } else {
- return this.complete;
- }
- }
-
- /**
- * Returns textual designation of the digest authentication scheme.
- *
- * @return digest
- */
- public String getSchemeName() {
- return "digest";
- }
-
- /**
- * Returns false. Digest authentication scheme is request based.
- *
- * @return false.
- */
- public boolean isConnectionBased() {
- return false;
- }
-
- public void overrideParamter(final String name, final String value) {
- getParameters().put(name, value);
- }
-
- private String getCnonce() {
- if (this.cnonce == null) {
- this.cnonce = createCnonce();
- }
- return this.cnonce;
- }
-
- /**
- * Produces a digest authorization string for the given set of
- * {@link Credentials}, method name and URI.
- *
- * @param credentials A set of credentials to be used for athentication
- * @param request The request being authenticated
- *
- * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
- * are not valid or not applicable for this authentication scheme
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return a digest authorization string
- */
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request) throws AuthenticationException {
-
- if (credentials == null) {
- throw new IllegalArgumentException("Credentials may not be null");
- }
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
-
- // Add method name and request-URI to the parameter map
- getParameters().put("methodname", request.getRequestLine().getMethod());
- getParameters().put("uri", request.getRequestLine().getUri());
- String charset = getParameter("charset");
- if (charset == null) {
- charset = AuthParams.getCredentialCharset(request.getParams());
- getParameters().put("charset", charset);
- }
- String digest = createDigest(credentials);
- return createDigestHeader(credentials, digest);
- }
-
- private static MessageDigest createMessageDigest(
- final String digAlg) throws UnsupportedDigestAlgorithmException {
- try {
- return MessageDigest.getInstance(digAlg);
- } catch (Exception e) {
- throw new UnsupportedDigestAlgorithmException(
- "Unsupported algorithm in HTTP Digest authentication: "
- + digAlg);
- }
- }
-
- /**
- * Creates an MD5 response digest.
- *
- * @return The created digest as string. This will be the response tag's
- * value in the Authentication HTTP header.
- * @throws AuthenticationException when MD5 is an unsupported algorithm
- */
- private String createDigest(final Credentials credentials) throws AuthenticationException {
- // Collecting required tokens
- String uri = getParameter("uri");
- String realm = getParameter("realm");
- String nonce = getParameter("nonce");
- String method = getParameter("methodname");
- String algorithm = getParameter("algorithm");
- if (uri == null) {
- throw new IllegalStateException("URI may not be null");
- }
- if (realm == null) {
- throw new IllegalStateException("Realm may not be null");
- }
- if (nonce == null) {
- throw new IllegalStateException("Nonce may not be null");
- }
- // If an algorithm is not specified, default to MD5.
- if (algorithm == null) {
- algorithm = "MD5";
- }
- // If an charset is not specified, default to ISO-8859-1.
- String charset = getParameter("charset");
- if (charset == null) {
- charset = "ISO-8859-1";
- }
-
- if (qopVariant == QOP_AUTH_INT) {
- throw new AuthenticationException(
- "Unsupported qop in HTTP Digest authentication");
- }
-
- MessageDigest md5Helper = createMessageDigest("MD5");
-
- String uname = credentials.getUserPrincipal().getName();
- String pwd = credentials.getPassword();
-
- // 3.2.2.2: Calculating digest
- StringBuilder tmp = new StringBuilder(uname.length() + realm.length() + pwd.length() + 2);
- tmp.append(uname);
- tmp.append(':');
- tmp.append(realm);
- tmp.append(':');
- tmp.append(pwd);
- // unq(username-value) ":" unq(realm-value) ":" passwd
- String a1 = tmp.toString();
-
- //a1 is suitable for MD5 algorithm
- if(algorithm.equals("MD5-sess")) {
- // H( unq(username-value) ":" unq(realm-value) ":" passwd )
- // ":" unq(nonce-value)
- // ":" unq(cnonce-value)
-
- String cnonce = getCnonce();
-
- String tmp2=encode(md5Helper.digest(EncodingUtils.getBytes(a1, charset)));
- StringBuilder tmp3 = new StringBuilder(tmp2.length() + nonce.length() + cnonce.length() + 2);
- tmp3.append(tmp2);
- tmp3.append(':');
- tmp3.append(nonce);
- tmp3.append(':');
- tmp3.append(cnonce);
- a1 = tmp3.toString();
- } else if (!algorithm.equals("MD5")) {
- throw new AuthenticationException("Unhandled algorithm " + algorithm + " requested");
- }
- String md5a1 = encode(md5Helper.digest(EncodingUtils.getBytes(a1, charset)));
-
- String a2 = null;
- if (qopVariant == QOP_AUTH_INT) {
- // Unhandled qop auth-int
- //we do not have access to the entity-body or its hash
- //TODO: add Method ":" digest-uri-value ":" H(entity-body)
- } else {
- a2 = method + ':' + uri;
- }
- String md5a2 = encode(md5Helper.digest(EncodingUtils.getAsciiBytes(a2)));
-
- // 3.2.2.1
- String serverDigestValue;
- if (qopVariant == QOP_MISSING) {
- StringBuilder tmp2 = new StringBuilder(md5a1.length() + nonce.length() + md5a2.length());
- tmp2.append(md5a1);
- tmp2.append(':');
- tmp2.append(nonce);
- tmp2.append(':');
- tmp2.append(md5a2);
- serverDigestValue = tmp2.toString();
- } else {
- String qopOption = getQopVariantString();
- String cnonce = getCnonce();
-
- StringBuilder tmp2 = new StringBuilder(md5a1.length() + nonce.length()
- + NC.length() + cnonce.length() + qopOption.length() + md5a2.length() + 5);
- tmp2.append(md5a1);
- tmp2.append(':');
- tmp2.append(nonce);
- tmp2.append(':');
- tmp2.append(NC);
- tmp2.append(':');
- tmp2.append(cnonce);
- tmp2.append(':');
- tmp2.append(qopOption);
- tmp2.append(':');
- tmp2.append(md5a2);
- serverDigestValue = tmp2.toString();
- }
-
- String serverDigest =
- encode(md5Helper.digest(EncodingUtils.getAsciiBytes(serverDigestValue)));
-
- return serverDigest;
- }
-
- /**
- * Creates digest-response header as defined in RFC2617.
- *
- * @param credentials User credentials
- * @param digest The response tag's value as String.
- *
- * @return The digest-response as String.
- */
- private Header createDigestHeader(
- final Credentials credentials,
- final String digest) throws AuthenticationException {
-
- CharArrayBuffer buffer = new CharArrayBuffer(128);
- if (isProxy()) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": Digest ");
-
- String uri = getParameter("uri");
- String realm = getParameter("realm");
- String nonce = getParameter("nonce");
- String opaque = getParameter("opaque");
- String response = digest;
- String algorithm = getParameter("algorithm");
-
- String uname = credentials.getUserPrincipal().getName();
-
- List params = new ArrayList(20);
- params.add(new BasicNameValuePair("username", uname));
- params.add(new BasicNameValuePair("realm", realm));
- params.add(new BasicNameValuePair("nonce", nonce));
- params.add(new BasicNameValuePair("uri", uri));
- params.add(new BasicNameValuePair("response", response));
-
- if (qopVariant != QOP_MISSING) {
- params.add(new BasicNameValuePair("qop", getQopVariantString()));
- params.add(new BasicNameValuePair("nc", NC));
- params.add(new BasicNameValuePair("cnonce", getCnonce()));
- }
- if (algorithm != null) {
- params.add(new BasicNameValuePair("algorithm", algorithm));
- }
- if (opaque != null) {
- params.add(new BasicNameValuePair("opaque", opaque));
- }
-
- for (int i = 0; i < params.size(); i++) {
- BasicNameValuePair param = params.get(i);
- if (i > 0) {
- buffer.append(", ");
- }
- boolean noQuotes = "nc".equals(param.getName()) ||
- "qop".equals(param.getName());
- BasicHeaderValueFormatter.DEFAULT
- .formatNameValuePair(buffer, param, !noQuotes);
- }
- return new BufferedHeader(buffer);
- }
-
- private String getQopVariantString() {
- String qopOption;
- if (qopVariant == QOP_AUTH_INT) {
- qopOption = "auth-int";
- } else {
- qopOption = "auth";
- }
- return qopOption;
- }
-
- /**
- * Encodes the 128 bit (16 bytes) MD5 digest into a 32 characters long
- * String according to RFC 2617.
- *
- * @param binaryData array containing the digest
- * @return encoded MD5, or null if encoding failed
- */
- private static String encode(byte[] binaryData) {
- if (binaryData.length != 16) {
- return null;
- }
-
- char[] buffer = new char[32];
- for (int i = 0; i < 16; i++) {
- int low = (binaryData[i] & 0x0f);
- int high = ((binaryData[i] & 0xf0) >> 4);
- buffer[i * 2] = HEXADECIMAL[high];
- buffer[(i * 2) + 1] = HEXADECIMAL[low];
- }
-
- return new String(buffer);
- }
-
-
- /**
- * Creates a random cnonce value based on the current time.
- *
- * @return The cnonce value as String.
- * @throws UnsupportedDigestAlgorithmException if MD5 algorithm is not supported.
- */
- public static String createCnonce() {
- String cnonce;
-
- MessageDigest md5Helper = createMessageDigest("MD5");
-
- cnonce = Long.toString(System.currentTimeMillis());
- cnonce = encode(md5Helper.digest(EncodingUtils.getAsciiBytes(cnonce)));
-
- return cnonce;
- }
-}
diff --git a/src/org/apache/http/impl/auth/DigestSchemeFactory.java b/src/org/apache/http/impl/auth/DigestSchemeFactory.java
deleted file mode 100644
index 38f2e1253abb0b0f8bd8f86e522c8c0ef1c7e690..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/DigestSchemeFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/DigestSchemeFactory.java $
- * $Revision: 534839 $
- * $Date: 2007-05-03 06:03:41 -0700 (Thu, 03 May 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeFactory;
-import org.apache.http.params.HttpParams;
-
-/**
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class DigestSchemeFactory implements AuthSchemeFactory {
-
- public AuthScheme newInstance(final HttpParams params) {
- return new DigestScheme();
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/NTLMEngine.java b/src/org/apache/http/impl/auth/NTLMEngine.java
deleted file mode 100644
index 7b6bf4229de2ed05b780736b1d86a8946dfcd79f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/NTLMEngine.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/NTLMEngine.java $
- * $Revision: 659788 $
- * $Date: 2008-05-24 03:42:23 -0700 (Sat, 24 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-/**
- * Abstract NTLM authentication engine. The engine can be used to
- * generate Type1 messages and Type3 messages in response to a
- * Type2 challenge.
- *
- * For details see this resource
- *
- * @author Oleg Kalnichevski
-*/
-public interface NTLMEngine {
-
- /**
- * Generates a Type1 message given the domain and workstation.
- *
- * @param domain Optional Windows domain name. Can be null.
- * @param workstation Optional Windows workstation name. Can be
- * null.
- * @return Type1 message
- * @throws NTLMEngineException
- */
- String generateType1Msg(
- String domain,
- String workstation) throws NTLMEngineException;
-
- /**
- * Generates a Type3 message given the user credentials and the
- * authentication challenge.
- *
- * @param username Windows user name
- * @param password Password
- * @param domain Windows domain name
- * @param workstation Windows workstation name
- * @param challenge Type2 challenge.
- * @return Type3 response.
- * @throws NTLMEngineException
- */
- String generateType3Msg(
- String username,
- String password,
- String domain,
- String workstation,
- String challenge) throws NTLMEngineException;
-
-}
diff --git a/src/org/apache/http/impl/auth/NTLMEngineException.java b/src/org/apache/http/impl/auth/NTLMEngineException.java
deleted file mode 100644
index 73baabc453228eae2d38e8dc0e4d59ddab0faae1..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/NTLMEngineException.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/NTLMEngineException.java $
- * $Revision: 655048 $
- * $Date: 2008-05-10 04:22:12 -0700 (Sat, 10 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.auth.AuthenticationException;
-
-/**
- * Signals NTLM protocol failure.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class NTLMEngineException extends AuthenticationException {
-
- private static final long serialVersionUID = 6027981323731768824L;
-
- public NTLMEngineException() {
- super();
- }
-
- /**
- * Creates a new NTLMEngineException with the specified message.
- *
- * @param message the exception detail message
- */
- public NTLMEngineException(String message) {
- super(message);
- }
-
- /**
- * Creates a new NTLMEngineException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the Throwable that caused this exception, or null
- * if the cause is unavailable, unknown, or not a Throwable
- */
- public NTLMEngineException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/NTLMScheme.java b/src/org/apache/http/impl/auth/NTLMScheme.java
deleted file mode 100644
index 8dfdbba013bc83cd218776f02c0d3313e5742b3e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/NTLMScheme.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/NTLMScheme.java $
- * $Revision: 655048 $
- * $Date: 2008-05-10 04:22:12 -0700 (Sat, 10 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.InvalidCredentialsException;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.impl.auth.AuthSchemeBase;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.util.CharArrayBuffer;
-
-public class NTLMScheme extends AuthSchemeBase {
-
- enum State {
- UNINITIATED,
- CHALLENGE_RECEIVED,
- MSG_TYPE1_GENERATED,
- MSG_TYPE2_RECEVIED,
- MSG_TYPE3_GENERATED,
- FAILED,
- }
-
- private final NTLMEngine engine;
-
- private State state;
- private String challenge;
-
- public NTLMScheme(final NTLMEngine engine) {
- super();
- if (engine == null) {
- throw new IllegalArgumentException("NTLM engine may not be null");
- }
- this.engine = engine;
- this.state = State.UNINITIATED;
- this.challenge = null;
- }
-
- public String getSchemeName() {
- return "ntlm";
- }
-
- public String getParameter(String name) {
- // String parameters not supported
- return null;
- }
-
- public String getRealm() {
- // NTLM does not support the concept of an authentication realm
- return null;
- }
-
- public boolean isConnectionBased() {
- return true;
- }
-
- @Override
- protected void parseChallenge(
- final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
- String challenge = buffer.substringTrimmed(pos, len);
- if (challenge.length() == 0) {
- if (this.state == State.UNINITIATED) {
- this.state = State.CHALLENGE_RECEIVED;
- } else {
- this.state = State.FAILED;
- }
- this.challenge = null;
- } else {
- this.state = State.MSG_TYPE2_RECEVIED;
- this.challenge = challenge;
- }
- }
-
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request) throws AuthenticationException {
- NTCredentials ntcredentials = null;
- try {
- ntcredentials = (NTCredentials) credentials;
- } catch (ClassCastException e) {
- throw new InvalidCredentialsException(
- "Credentials cannot be used for NTLM authentication: "
- + credentials.getClass().getName());
- }
- String response = null;
- if (this.state == State.CHALLENGE_RECEIVED || this.state == State.FAILED) {
- response = this.engine.generateType1Msg(
- ntcredentials.getDomain(),
- ntcredentials.getWorkstation());
- this.state = State.MSG_TYPE1_GENERATED;
- } else if (this.state == State.MSG_TYPE2_RECEVIED) {
- response = this.engine.generateType3Msg(
- ntcredentials.getUserName(),
- ntcredentials.getPassword(),
- ntcredentials.getDomain(),
- ntcredentials.getWorkstation(),
- this.challenge);
- this.state = State.MSG_TYPE3_GENERATED;
- } else {
- throw new AuthenticationException("Unexpected state: " + this.state);
- }
- CharArrayBuffer buffer = new CharArrayBuffer(32);
- if (isProxy()) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": NTLM ");
- buffer.append(response);
- return new BufferedHeader(buffer);
- }
-
- public boolean isComplete() {
- return this.state == State.MSG_TYPE3_GENERATED || this.state == State.FAILED;
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/RFC2617Scheme.java b/src/org/apache/http/impl/auth/RFC2617Scheme.java
deleted file mode 100644
index 0ed0a28215c54df9a4075ca2e56c29c86bb4e721..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/RFC2617Scheme.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java $
- * $Revision: 659595 $
- * $Date: 2008-05-23 09:47:14 -0700 (Fri, 23 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.http.HeaderElement;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.message.BasicHeaderValueParser;
-import org.apache.http.message.HeaderValueParser;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Abstract authentication scheme class that lays foundation for all
- * RFC 2617 compliant authetication schemes and provides capabilities common
- * to all authentication schemes defined in RFC 2617.
- *
- * @author Oleg Kalnichevski
-*/
-public abstract class RFC2617Scheme extends AuthSchemeBase {
-
- /**
- * Authentication parameter map.
- */
- private Map params;
-
- /**
- * Default constructor for RFC2617 compliant authetication schemes.
- */
- public RFC2617Scheme() {
- super();
- }
-
- @Override
- protected void parseChallenge(
- final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
- HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
- ParserCursor cursor = new ParserCursor(pos, buffer.length());
- HeaderElement[] elements = parser.parseElements(buffer, cursor);
- if (elements.length == 0) {
- throw new MalformedChallengeException("Authentication challenge is empty");
- }
-
- this.params = new HashMap(elements.length);
- for (HeaderElement element : elements) {
- this.params.put(element.getName(), element.getValue());
- }
- }
-
- /**
- * Returns authentication parameters map. Keys in the map are lower-cased.
- *
- * @return the map of authentication parameters
- */
- protected Map getParameters() {
- if (this.params == null) {
- this.params = new HashMap();
- }
- return this.params;
- }
-
- /**
- * Returns authentication parameter with the given name, if available.
- *
- * @param name The name of the parameter to be returned
- *
- * @return the parameter with the given name
- */
- public String getParameter(final String name) {
- if (name == null) {
- throw new IllegalArgumentException("Parameter name may not be null");
- }
- if (this.params == null) {
- return null;
- }
- return this.params.get(name.toLowerCase(Locale.ENGLISH));
- }
-
- /**
- * Returns authentication realm. The realm may not be null.
- *
- * @return the authentication realm
- */
- public String getRealm() {
- return getParameter("realm");
- }
-
-}
diff --git a/src/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java b/src/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
deleted file mode 100644
index abd0a665202037c6e31a7370a7bc0c036642a42f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java $
- * $Revision: 527479 $
- * $Date: 2007-04-11 05:55:12 -0700 (Wed, 11 Apr 2007) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-/**
- * Authentication credentials required to respond to a authentication
- * challenge are invalid
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class UnsupportedDigestAlgorithmException extends RuntimeException {
-
- private static final long serialVersionUID = 319558534317118022L;
-
- /**
- * Creates a new UnsupportedAuthAlgoritmException with a null detail message.
- */
- public UnsupportedDigestAlgorithmException() {
- super();
- }
-
- /**
- * Creates a new UnsupportedAuthAlgoritmException with the specified message.
- *
- * @param message the exception detail message
- */
- public UnsupportedDigestAlgorithmException(String message) {
- super(message);
- }
-
- /**
- * Creates a new UnsupportedAuthAlgoritmException with the specified detail message and cause.
- *
- * @param message the exception detail message
- * @param cause the Throwable that caused this exception, or null
- * if the cause is unavailable, unknown, or not a Throwable
- */
- public UnsupportedDigestAlgorithmException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/src/org/apache/http/impl/auth/package.html b/src/org/apache/http/impl/auth/package.html
deleted file mode 100644
index e301283df7104685ade8ae0e8887fb7917b4d61f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/auth/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/src/org/apache/http/impl/client/AbstractAuthenticationHandler.java
deleted file mode 100644
index 57699d5caed42653d2d4a2e2a6cdfda49261b4e0..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/AbstractAuthenticationHandler.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeRegistry;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.client.AuthenticationHandler;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * @author Oleg Kalnichevski
- */
-public abstract class AbstractAuthenticationHandler implements AuthenticationHandler {
-
- private final Log log = LogFactory.getLog(getClass());
-
- private static final List DEFAULT_SCHEME_PRIORITY = Arrays.asList(new String[] {
- "ntlm",
- "digest",
- "basic"
- });
-
- public AbstractAuthenticationHandler() {
- super();
- }
-
- protected Map parseChallenges(
- final Header[] headers) throws MalformedChallengeException {
-
- Map map = new HashMap(headers.length);
- for (Header header : headers) {
- CharArrayBuffer buffer;
- int pos;
- if (header instanceof FormattedHeader) {
- buffer = ((FormattedHeader) header).getBuffer();
- pos = ((FormattedHeader) header).getValuePos();
- } else {
- String s = header.getValue();
- if (s == null) {
- throw new MalformedChallengeException("Header value is null");
- }
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
- pos = 0;
- }
- while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- int beginIndex = pos;
- while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- int endIndex = pos;
- String s = buffer.substring(beginIndex, endIndex);
- map.put(s.toLowerCase(Locale.ENGLISH), header);
- }
- return map;
- }
-
- protected List getAuthPreferences() {
- return DEFAULT_SCHEME_PRIORITY;
- }
-
- public AuthScheme selectScheme(
- final Map challenges,
- final HttpResponse response,
- final HttpContext context) throws AuthenticationException {
-
- AuthSchemeRegistry registry = (AuthSchemeRegistry) context.getAttribute(
- ClientContext.AUTHSCHEME_REGISTRY);
- if (registry == null) {
- throw new IllegalStateException("AuthScheme registry not set in HTTP context");
- }
-
- List> authPrefs = (List>) context.getAttribute(
- ClientContext.AUTH_SCHEME_PREF);
- if (authPrefs == null) {
- authPrefs = getAuthPreferences();
- }
-
- if (this.log.isDebugEnabled()) {
- this.log.debug("Authentication schemes in the order of preference: "
- + authPrefs);
- }
-
- AuthScheme authScheme = null;
- for (int i = 0; i < authPrefs.size(); i++) {
- String id = (String) authPrefs.get(i);
- Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
-
- if (challenge != null) {
- if (this.log.isDebugEnabled()) {
- this.log.debug(id + " authentication scheme selected");
- }
- try {
- authScheme = registry.getAuthScheme(id, response.getParams());
- break;
- } catch (IllegalStateException e) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Authentication scheme " + id + " not supported");
- // Try again
- }
- }
- } else {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Challenge for " + id + " authentication scheme not available");
- // Try again
- }
- }
- }
- if (authScheme == null) {
- // If none selected, something is wrong
- throw new AuthenticationException(
- "Unable to respond to any of these challenges: "
- + challenges);
- }
- return authScheme;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/AbstractHttpClient.java b/src/org/apache/http/impl/client/AbstractHttpClient.java
deleted file mode 100644
index 3a1b83841897be306084c7a85767b319d5979119..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/AbstractHttpClient.java
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java $
- * $Revision: 677250 $
- * $Date: 2008-07-16 04:45:47 -0700 (Wed, 16 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.net.URI;
-import java.lang.reflect.UndeclaredThrowableException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpEntity;
-import org.apache.http.auth.AuthSchemeRegistry;
-import org.apache.http.client.AuthenticationHandler;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.RequestDirector;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.RedirectHandler;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.cookie.CookieSpecRegistry;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.DefaultedHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-
-/**
- * Convenience base class for HTTP client implementations.
- *
- * @author Roland Weber
- * @author Oleg Kalnichevski
- *
- *
- * @version $Revision: 677250 $
- *
- * @since 4.0
- */
-public abstract class AbstractHttpClient implements HttpClient {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /** The parameters. */
- private HttpParams defaultParams;
-
- /** The request executor. */
- private HttpRequestExecutor requestExec;
-
- /** The connection manager. */
- private ClientConnectionManager connManager;
-
- /** The connection re-use strategy. */
- private ConnectionReuseStrategy reuseStrategy;
-
- /** The connection keep-alive strategy. */
- private ConnectionKeepAliveStrategy keepAliveStrategy;
-
- /** The cookie spec registry. */
- private CookieSpecRegistry supportedCookieSpecs;
-
- /** The authentication scheme registry. */
- private AuthSchemeRegistry supportedAuthSchemes;
-
- /** The HTTP processor. */
- private BasicHttpProcessor httpProcessor;
-
- /** The request retry handler. */
- private HttpRequestRetryHandler retryHandler;
-
- /** The redirect handler. */
- private RedirectHandler redirectHandler;
-
- /** The target authentication handler. */
- private AuthenticationHandler targetAuthHandler;
-
- /** The proxy authentication handler. */
- private AuthenticationHandler proxyAuthHandler;
-
- /** The cookie store. */
- private CookieStore cookieStore;
-
- /** The credentials provider. */
- private CredentialsProvider credsProvider;
-
- /** The route planner. */
- private HttpRoutePlanner routePlanner;
-
- /** The user token handler. */
- private UserTokenHandler userTokenHandler;
-
-
- /**
- * Creates a new HTTP client.
- *
- * @param conman the connection manager
- * @param params the parameters
- */
- protected AbstractHttpClient(
- final ClientConnectionManager conman,
- final HttpParams params) {
- defaultParams = params;
- connManager = conman;
- } // constructor
-
- protected abstract HttpParams createHttpParams();
-
-
- protected abstract HttpContext createHttpContext();
-
-
- protected abstract HttpRequestExecutor createRequestExecutor();
-
-
- protected abstract ClientConnectionManager createClientConnectionManager();
-
-
- protected abstract AuthSchemeRegistry createAuthSchemeRegistry();
-
-
- protected abstract CookieSpecRegistry createCookieSpecRegistry();
-
-
- protected abstract ConnectionReuseStrategy createConnectionReuseStrategy();
-
-
- protected abstract ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy();
-
-
- protected abstract BasicHttpProcessor createHttpProcessor();
-
-
- protected abstract HttpRequestRetryHandler createHttpRequestRetryHandler();
-
-
- protected abstract RedirectHandler createRedirectHandler();
-
-
- protected abstract AuthenticationHandler createTargetAuthenticationHandler();
-
-
- protected abstract AuthenticationHandler createProxyAuthenticationHandler();
-
-
- protected abstract CookieStore createCookieStore();
-
-
- protected abstract CredentialsProvider createCredentialsProvider();
-
-
- protected abstract HttpRoutePlanner createHttpRoutePlanner();
-
-
- protected abstract UserTokenHandler createUserTokenHandler();
-
-
- // non-javadoc, see interface HttpClient
- public synchronized final HttpParams getParams() {
- if (defaultParams == null) {
- defaultParams = createHttpParams();
- }
- return defaultParams;
- }
-
-
- /**
- * Replaces the parameters.
- * The implementation here does not update parameters of dependent objects.
- *
- * @param params the new default parameters
- */
- public synchronized void setParams(HttpParams params) {
- defaultParams = params;
- }
-
-
- public synchronized final ClientConnectionManager getConnectionManager() {
- if (connManager == null) {
- connManager = createClientConnectionManager();
- }
- return connManager;
- }
-
-
- public synchronized final HttpRequestExecutor getRequestExecutor() {
- if (requestExec == null) {
- requestExec = createRequestExecutor();
- }
- return requestExec;
- }
-
-
- public synchronized final AuthSchemeRegistry getAuthSchemes() {
- if (supportedAuthSchemes == null) {
- supportedAuthSchemes = createAuthSchemeRegistry();
- }
- return supportedAuthSchemes;
- }
-
-
- public synchronized void setAuthSchemes(final AuthSchemeRegistry authSchemeRegistry) {
- supportedAuthSchemes = authSchemeRegistry;
- }
-
-
- public synchronized final CookieSpecRegistry getCookieSpecs() {
- if (supportedCookieSpecs == null) {
- supportedCookieSpecs = createCookieSpecRegistry();
- }
- return supportedCookieSpecs;
- }
-
-
- public synchronized void setCookieSpecs(final CookieSpecRegistry cookieSpecRegistry) {
- supportedCookieSpecs = cookieSpecRegistry;
- }
-
-
- public synchronized final ConnectionReuseStrategy getConnectionReuseStrategy() {
- if (reuseStrategy == null) {
- reuseStrategy = createConnectionReuseStrategy();
- }
- return reuseStrategy;
- }
-
-
- public synchronized void setReuseStrategy(final ConnectionReuseStrategy reuseStrategy) {
- this.reuseStrategy = reuseStrategy;
- }
-
-
- public synchronized final ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy() {
- if (keepAliveStrategy == null) {
- keepAliveStrategy = createConnectionKeepAliveStrategy();
- }
- return keepAliveStrategy;
- }
-
-
- public synchronized void setKeepAliveStrategy(final ConnectionKeepAliveStrategy keepAliveStrategy) {
- this.keepAliveStrategy = keepAliveStrategy;
- }
-
-
- public synchronized final HttpRequestRetryHandler getHttpRequestRetryHandler() {
- if (retryHandler == null) {
- retryHandler = createHttpRequestRetryHandler();
- }
- return retryHandler;
- }
-
-
- public synchronized void setHttpRequestRetryHandler(final HttpRequestRetryHandler retryHandler) {
- this.retryHandler = retryHandler;
- }
-
-
- public synchronized final RedirectHandler getRedirectHandler() {
- if (redirectHandler == null) {
- redirectHandler = createRedirectHandler();
- }
- return redirectHandler;
- }
-
-
- public synchronized void setRedirectHandler(final RedirectHandler redirectHandler) {
- this.redirectHandler = redirectHandler;
- }
-
-
- public synchronized final AuthenticationHandler getTargetAuthenticationHandler() {
- if (targetAuthHandler == null) {
- targetAuthHandler = createTargetAuthenticationHandler();
- }
- return targetAuthHandler;
- }
-
-
- public synchronized void setTargetAuthenticationHandler(
- final AuthenticationHandler targetAuthHandler) {
- this.targetAuthHandler = targetAuthHandler;
- }
-
-
- public synchronized final AuthenticationHandler getProxyAuthenticationHandler() {
- if (proxyAuthHandler == null) {
- proxyAuthHandler = createProxyAuthenticationHandler();
- }
- return proxyAuthHandler;
- }
-
-
- public synchronized void setProxyAuthenticationHandler(
- final AuthenticationHandler proxyAuthHandler) {
- this.proxyAuthHandler = proxyAuthHandler;
- }
-
-
- public synchronized final CookieStore getCookieStore() {
- if (cookieStore == null) {
- cookieStore = createCookieStore();
- }
- return cookieStore;
- }
-
-
- public synchronized void setCookieStore(final CookieStore cookieStore) {
- this.cookieStore = cookieStore;
- }
-
-
- public synchronized final CredentialsProvider getCredentialsProvider() {
- if (credsProvider == null) {
- credsProvider = createCredentialsProvider();
- }
- return credsProvider;
- }
-
-
- public synchronized void setCredentialsProvider(final CredentialsProvider credsProvider) {
- this.credsProvider = credsProvider;
- }
-
-
- public synchronized final HttpRoutePlanner getRoutePlanner() {
- if (this.routePlanner == null) {
- this.routePlanner = createHttpRoutePlanner();
- }
- return this.routePlanner;
- }
-
-
- public synchronized void setRoutePlanner(final HttpRoutePlanner routePlanner) {
- this.routePlanner = routePlanner;
- }
-
-
- public synchronized final UserTokenHandler getUserTokenHandler() {
- if (this.userTokenHandler == null) {
- this.userTokenHandler = createUserTokenHandler();
- }
- return this.userTokenHandler;
- }
-
-
- public synchronized void setUserTokenHandler(final UserTokenHandler userTokenHandler) {
- this.userTokenHandler = userTokenHandler;
- }
-
-
- protected synchronized final BasicHttpProcessor getHttpProcessor() {
- if (httpProcessor == null) {
- httpProcessor = createHttpProcessor();
- }
- return httpProcessor;
- }
-
-
- public synchronized void addResponseInterceptor(final HttpResponseInterceptor itcp) {
- getHttpProcessor().addInterceptor(itcp);
- }
-
-
- public synchronized void addResponseInterceptor(final HttpResponseInterceptor itcp, int index) {
- getHttpProcessor().addInterceptor(itcp, index);
- }
-
-
- public synchronized HttpResponseInterceptor getResponseInterceptor(int index) {
- return getHttpProcessor().getResponseInterceptor(index);
- }
-
-
- public synchronized int getResponseInterceptorCount() {
- return getHttpProcessor().getResponseInterceptorCount();
- }
-
-
- public synchronized void clearResponseInterceptors() {
- getHttpProcessor().clearResponseInterceptors();
- }
-
-
- public void removeResponseInterceptorByClass(Class extends HttpResponseInterceptor> clazz) {
- getHttpProcessor().removeResponseInterceptorByClass(clazz);
- }
-
-
- public synchronized void addRequestInterceptor(final HttpRequestInterceptor itcp) {
- getHttpProcessor().addInterceptor(itcp);
- }
-
-
- public synchronized void addRequestInterceptor(final HttpRequestInterceptor itcp, int index) {
- getHttpProcessor().addInterceptor(itcp, index);
- }
-
-
- public synchronized HttpRequestInterceptor getRequestInterceptor(int index) {
- return getHttpProcessor().getRequestInterceptor(index);
- }
-
-
- public synchronized int getRequestInterceptorCount() {
- return getHttpProcessor().getRequestInterceptorCount();
- }
-
-
- public synchronized void clearRequestInterceptors() {
- getHttpProcessor().clearRequestInterceptors();
- }
-
-
- public void removeRequestInterceptorByClass(Class extends HttpRequestInterceptor> clazz) {
- getHttpProcessor().removeRequestInterceptorByClass(clazz);
- }
-
-
- // non-javadoc, see interface HttpClient
- public final HttpResponse execute(HttpUriRequest request)
- throws IOException, ClientProtocolException {
-
- return execute(request, (HttpContext) null);
- }
-
-
- /**
- * Maps to {@link HttpClient#execute(HttpHost,HttpRequest,HttpContext)
- * execute(target, request, context)}.
- * The target is determined from the URI of the request.
- *
- * @param request the request to execute
- * @param context the request-specific execution context,
- * or null to use a default context
- */
- public final HttpResponse execute(HttpUriRequest request,
- HttpContext context)
- throws IOException, ClientProtocolException {
-
- if (request == null) {
- throw new IllegalArgumentException
- ("Request must not be null.");
- }
-
- return execute(determineTarget(request), request, context);
- }
-
- private HttpHost determineTarget(HttpUriRequest request) {
- // A null target may be acceptable if there is a default target.
- // Otherwise, the null target is detected in the director.
- HttpHost target = null;
-
- URI requestURI = request.getURI();
- if (requestURI.isAbsolute()) {
- target = new HttpHost(
- requestURI.getHost(),
- requestURI.getPort(),
- requestURI.getScheme());
- }
- return target;
- }
-
- // non-javadoc, see interface HttpClient
- public final HttpResponse execute(HttpHost target, HttpRequest request)
- throws IOException, ClientProtocolException {
-
- return execute(target, request, (HttpContext) null);
- }
-
-
- // non-javadoc, see interface HttpClient
- public final HttpResponse execute(HttpHost target, HttpRequest request,
- HttpContext context)
- throws IOException, ClientProtocolException {
-
- if (request == null) {
- throw new IllegalArgumentException
- ("Request must not be null.");
- }
- // a null target may be acceptable, this depends on the route planner
- // a null context is acceptable, default context created below
-
- HttpContext execContext = null;
- RequestDirector director = null;
-
- // Initialize the request execution context making copies of
- // all shared objects that are potentially threading unsafe.
- synchronized (this) {
-
- HttpContext defaultContext = createHttpContext();
- if (context == null) {
- execContext = defaultContext;
- } else {
- execContext = new DefaultedHttpContext(context, defaultContext);
- }
- // Create a director for this request
- director = createClientRequestDirector(
- getRequestExecutor(),
- getConnectionManager(),
- getConnectionReuseStrategy(),
- getConnectionKeepAliveStrategy(),
- getRoutePlanner(),
- getHttpProcessor().copy(),
- getHttpRequestRetryHandler(),
- getRedirectHandler(),
- getTargetAuthenticationHandler(),
- getProxyAuthenticationHandler(),
- getUserTokenHandler(),
- determineParams(request));
- }
-
- try {
- return director.execute(target, request, execContext);
- } catch(HttpException httpException) {
- throw new ClientProtocolException(httpException);
- }
- } // execute
-
-
- protected RequestDirector createClientRequestDirector(
- final HttpRequestExecutor requestExec,
- final ClientConnectionManager conman,
- final ConnectionReuseStrategy reustrat,
- final ConnectionKeepAliveStrategy kastrat,
- final HttpRoutePlanner rouplan,
- final HttpProcessor httpProcessor,
- final HttpRequestRetryHandler retryHandler,
- final RedirectHandler redirectHandler,
- final AuthenticationHandler targetAuthHandler,
- final AuthenticationHandler proxyAuthHandler,
- final UserTokenHandler stateHandler,
- final HttpParams params) {
- return new DefaultRequestDirector(
- requestExec,
- conman,
- reustrat,
- kastrat,
- rouplan,
- httpProcessor,
- retryHandler,
- redirectHandler,
- targetAuthHandler,
- proxyAuthHandler,
- stateHandler,
- params);
- }
-
- /**
- * Obtains parameters for executing a request.
- * The default implementation in this class creates a new
- * {@link ClientParamsStack} from the request parameters
- * and the client parameters.
- *
- * This method is called by the default implementation of
- * {@link #execute(HttpHost,HttpRequest,HttpContext)}
- * to obtain the parameters for the
- * {@link DefaultRequestDirector}.
- *
- * @param req the request that will be executed
- *
- * @return the parameters to use
- */
- protected HttpParams determineParams(HttpRequest req) {
- return new ClientParamsStack
- (null, getParams(), req.getParams(), null);
- }
-
-
- // non-javadoc, see interface HttpClient
- public T execute(
- final HttpUriRequest request,
- final ResponseHandler extends T> responseHandler)
- throws IOException, ClientProtocolException {
- return execute(request, responseHandler, null);
- }
-
-
- // non-javadoc, see interface HttpClient
- public T execute(
- final HttpUriRequest request,
- final ResponseHandler extends T> responseHandler,
- final HttpContext context)
- throws IOException, ClientProtocolException {
- HttpHost target = determineTarget(request);
- return execute(target, request, responseHandler, context);
- }
-
-
- // non-javadoc, see interface HttpClient
- public T execute(
- final HttpHost target,
- final HttpRequest request,
- final ResponseHandler extends T> responseHandler)
- throws IOException, ClientProtocolException {
- return execute(target, request, responseHandler, null);
- }
-
-
- // non-javadoc, see interface HttpClient
- public T execute(
- final HttpHost target,
- final HttpRequest request,
- final ResponseHandler extends T> responseHandler,
- final HttpContext context)
- throws IOException, ClientProtocolException {
- if (responseHandler == null) {
- throw new IllegalArgumentException
- ("Response handler must not be null.");
- }
-
- HttpResponse response = execute(target, request, context);
-
- T result;
- try {
- result = responseHandler.handleResponse(response);
- } catch (Throwable t) {
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- try {
- entity.consumeContent();
- } catch (Throwable t2) {
- // Log this exception. The original exception is more
- // important and will be thrown to the caller.
- this.log.warn("Error consuming content after an exception.", t2);
- }
- }
-
- if (t instanceof Error) {
- throw (Error) t;
- }
-
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
-
- if (t instanceof IOException) {
- throw (IOException) t;
- }
-
- throw new UndeclaredThrowableException(t);
- }
-
- // Handling the response was successful. Ensure that the content has
- // been fully consumed.
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- // Let this exception go to the caller.
- entity.consumeContent();
- }
-
- return result;
- }
-
-
-} // class AbstractHttpClient
diff --git a/src/org/apache/http/impl/client/BasicCookieStore.java b/src/org/apache/http/impl/client/BasicCookieStore.java
deleted file mode 100644
index 9970961dcef1d345b9dce025e76cc7a6722d299d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/BasicCookieStore.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieIdentityComparator;
-
-/**
- * Default implementation of {@link CookieStore}
- *
- * @author Remy Maucherat
- * @author Rodney Waldhoff
- * @author Jeff Dever
- * @author Sean C. Sullivan
- * @author Michael Becke
- * @author Oleg Kalnichevski
- * @author Mike Bowler
- * @author Adrian Sutton
- *
- * @since 4.0
- */
-public class BasicCookieStore implements CookieStore {
-
- private final ArrayList cookies;
-
- private final Comparator cookieComparator;
-
- // -------------------------------------------------------- Class Variables
-
- /**
- * Default constructor.
- */
- public BasicCookieStore() {
- super();
- this.cookies = new ArrayList();
- this.cookieComparator = new CookieIdentityComparator();
- }
-
- /**
- * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies.
- * If the given cookie has already expired it will not be added, but existing
- * values will still be removed.
- *
- * @param cookie the {@link Cookie cookie} to be added
- *
- * @see #addCookies(Cookie[])
- *
- */
- public synchronized void addCookie(Cookie cookie) {
- if (cookie != null) {
- // first remove any old cookie that is equivalent
- for (Iterator it = cookies.iterator(); it.hasNext();) {
- if (cookieComparator.compare(cookie, it.next()) == 0) {
- it.remove();
- break;
- }
- }
- if (!cookie.isExpired(new Date())) {
- cookies.add(cookie);
- }
- }
- }
-
- /**
- * Adds an array of {@link Cookie HTTP cookies}. Cookies are added individually and
- * in the given array order. If any of the given cookies has already expired it will
- * not be added, but existing values will still be removed.
- *
- * @param cookies the {@link Cookie cookies} to be added
- *
- * @see #addCookie(Cookie)
- *
- */
- public synchronized void addCookies(Cookie[] cookies) {
- if (cookies != null) {
- for (Cookie cooky : cookies) {
- this.addCookie(cooky);
- }
- }
- }
-
- /**
- * Returns an immutable array of {@link Cookie cookies} that this HTTP
- * state currently contains.
- *
- * @return an array of {@link Cookie cookies}.
- */
- public synchronized List getCookies() {
- return Collections.unmodifiableList(this.cookies);
- }
-
- /**
- * Removes all of {@link Cookie cookies} in this HTTP state
- * that have expired by the specified {@link java.util.Date date}.
- *
- * @return true if any cookies were purged.
- *
- * @see Cookie#isExpired(Date)
- */
- public synchronized boolean clearExpired(final Date date) {
- if (date == null) {
- return false;
- }
- boolean removed = false;
- for (Iterator it = cookies.iterator(); it.hasNext();) {
- if (it.next().isExpired(date)) {
- it.remove();
- removed = true;
- }
- }
- return removed;
- }
-
- @Override
- public String toString() {
- return cookies.toString();
- }
-
- /**
- * Clears all cookies.
- */
- public synchronized void clear() {
- cookies.clear();
- }
-
-}
diff --git a/src/org/apache/http/impl/client/BasicCredentialsProvider.java b/src/org/apache/http/impl/client/BasicCredentialsProvider.java
deleted file mode 100644
index 02427ea26c034a77697ee80277d0863b58bd8f2c..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/BasicCredentialsProvider.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.HashMap;
-
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.CredentialsProvider;
-
-/**
- * Default implementation of {@link CredentialsProvider}
- *
- * @author Remy Maucherat
- * @author Rodney Waldhoff
- * @author Jeff Dever
- * @author Sean C. Sullivan
- * @author Michael Becke
- * @author Oleg Kalnichevski
- * @author Mike Bowler
- * @author Adrian Sutton
- *
- * @since 4.0
- */
-public class BasicCredentialsProvider implements CredentialsProvider {
-
- private final HashMap credMap;
-
- /**
- * Default constructor.
- */
- public BasicCredentialsProvider() {
- super();
- this.credMap = new HashMap();
- }
-
- /**
- * Sets the {@link Credentials credentials} for the given authentication
- * scope. Any previous credentials for the given scope will be overwritten.
- *
- * @param authscope the {@link AuthScope authentication scope}
- * @param credentials the authentication {@link Credentials credentials}
- * for the given scope.
- *
- * @see #getCredentials(AuthScope)
- */
- public synchronized void setCredentials(
- final AuthScope authscope,
- final Credentials credentials) {
- if (authscope == null) {
- throw new IllegalArgumentException("Authentication scope may not be null");
- }
- credMap.put(authscope, credentials);
- }
-
- /**
- * Find matching {@link Credentials credentials} for the given authentication scope.
- *
- * @param map the credentials hash map
- * @param authscope the {@link AuthScope authentication scope}
- * @return the credentials
- *
- */
- private static Credentials matchCredentials(
- final HashMap map,
- final AuthScope authscope) {
- // see if we get a direct hit
- Credentials creds = map.get(authscope);
- if (creds == null) {
- // Nope.
- // Do a full scan
- int bestMatchFactor = -1;
- AuthScope bestMatch = null;
- for (AuthScope current: map.keySet()) {
- int factor = authscope.match(current);
- if (factor > bestMatchFactor) {
- bestMatchFactor = factor;
- bestMatch = current;
- }
- }
- if (bestMatch != null) {
- creds = map.get(bestMatch);
- }
- }
- return creds;
- }
-
- /**
- * Get the {@link Credentials credentials} for the given authentication scope.
- *
- * @param authscope the {@link AuthScope authentication scope}
- * @return the credentials
- *
- * @see #setCredentials(AuthScope, Credentials)
- */
- public synchronized Credentials getCredentials(final AuthScope authscope) {
- if (authscope == null) {
- throw new IllegalArgumentException("Authentication scope may not be null");
- }
- return matchCredentials(this.credMap, authscope);
- }
-
- @Override
- public String toString() {
- return credMap.toString();
- }
-
- /**
- * Clears all credentials.
- */
- public synchronized void clear() {
- this.credMap.clear();
- }
-
-}
diff --git a/src/org/apache/http/impl/client/BasicResponseHandler.java b/src/org/apache/http/impl/client/BasicResponseHandler.java
deleted file mode 100644
index f17d30ddf3dbd97c23c35054536a6c634bde47c8..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/BasicResponseHandler.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicResponseHandler.java $
- * $Revision: 677240 $
- * $Date: 2008-07-16 04:25:47 -0700 (Wed, 16 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.util.EntityUtils;
-
-/**
- * A {@link ResponseHandler} that returns the response body as a String
- * for successful (2xx) responses. If the response code was >= 300, the response
- * body is consumed and an {@link HttpResponseException} is thrown.
- *
- * If this is used with
- * {@link org.apache.http.client.HttpClient#execute(
- * org.apache.http.client.methods.HttpUriRequest, ResponseHandler),
- * HttpClient may handle redirects (3xx responses) internally.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 677240 $
- *
- * @since 4.0
- */
-public class BasicResponseHandler implements ResponseHandler {
-
- /**
- * Returns the response body as a String if the response was successful (a
- * 2xx status code). If no response body exists, this returns null. If the
- * response was unsuccessful (>= 300 status code), throws an
- * {@link HttpResponseException}.
- */
- public String handleResponse(final HttpResponse response)
- throws HttpResponseException, IOException {
- StatusLine statusLine = response.getStatusLine();
- if (statusLine.getStatusCode() >= 300) {
- throw new HttpResponseException(statusLine.getStatusCode(),
- statusLine.getReasonPhrase());
- }
-
- HttpEntity entity = response.getEntity();
- return entity == null ? null : EntityUtils.toString(entity);
- }
-
-}
diff --git a/src/org/apache/http/impl/client/ClientParamsStack.java b/src/org/apache/http/impl/client/ClientParamsStack.java
deleted file mode 100644
index a017e5db3541dea4661101e683423ad7e93d58e6..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/ClientParamsStack.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/ClientParamsStack.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.AbstractHttpParams;
-
-
-/**
- * Represents a stack of parameter collections.
- * When retrieving a parameter, the stack is searched in a fixed order
- * and the first match returned. Setting parameters via the stack is
- * not supported. To minimize overhead, the stack has a fixed size and
- * does not maintain an internal array.
- * The supported stack entries, sorted by increasing priority, are:
- *
- * - Application parameters:
- * expected to be the same for all clients used by an application.
- * These provide "global", that is application-wide, defaults.
- *
- * - Client parameters:
- * specific to an instance of
- * {@link org.apache.http.client.HttpClient HttpClient}.
- * These provide client specific defaults.
- *
- * - Request parameters:
- * specific to a single request execution.
- * For overriding client and global defaults.
- *
- * - Override parameters:
- * specific to an instance of
- * {@link org.apache.http.client.HttpClient HttpClient}.
- * These can be used to set parameters that cannot be overridden
- * on a per-request basis.
- *
- *
- * Each stack entry may be null. That is preferable over
- * an empty params collection, since it avoids searching the empty collection
- * when looking up parameters.
- *
- * @author Roland Weber
- *
- *
- * @version $Revision: 673450 $
- */
-public class ClientParamsStack extends AbstractHttpParams {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /** The application parameter collection, or null. */
- protected final HttpParams applicationParams;
-
- /** The client parameter collection, or null. */
- protected final HttpParams clientParams;
-
- /** The request parameter collection, or null. */
- protected final HttpParams requestParams;
-
- /** The override parameter collection, or null. */
- protected final HttpParams overrideParams;
-
-
- /**
- * Creates a new parameter stack from elements.
- * The arguments will be stored as-is, there is no copying to
- * prevent modification.
- *
- * @param aparams application parameters, or null
- * @param cparams client parameters, or null
- * @param rparams request parameters, or null
- * @param oparams override parameters, or null
- */
- public ClientParamsStack(HttpParams aparams, HttpParams cparams,
- HttpParams rparams, HttpParams oparams) {
- applicationParams = aparams;
- clientParams = cparams;
- requestParams = rparams;
- overrideParams = oparams;
- }
-
-
- /**
- * Creates a copy of a parameter stack.
- * The new stack will have the exact same entries as the argument stack.
- * There is no copying of parameters.
- *
- * @param stack the stack to copy
- */
- public ClientParamsStack(ClientParamsStack stack) {
- this(stack.getApplicationParams(),
- stack.getClientParams(),
- stack.getRequestParams(),
- stack.getOverrideParams());
- }
-
-
- /**
- * Creates a modified copy of a parameter stack.
- * The new stack will contain the explicitly passed elements.
- * For elements where the explicit argument is null,
- * the corresponding element from the argument stack is used.
- * There is no copying of parameters.
- *
- * @param stack the stack to modify
- * @param aparams application parameters, or null
- * @param cparams client parameters, or null
- * @param rparams request parameters, or null
- * @param oparams override parameters, or null
- */
- public ClientParamsStack(ClientParamsStack stack,
- HttpParams aparams, HttpParams cparams,
- HttpParams rparams, HttpParams oparams) {
- this((aparams != null) ? aparams : stack.getApplicationParams(),
- (cparams != null) ? cparams : stack.getClientParams(),
- (rparams != null) ? rparams : stack.getRequestParams(),
- (oparams != null) ? oparams : stack.getOverrideParams());
- }
-
-
- /**
- * Obtains the application parameters of this stack.
- *
- * @return the application parameters, or null
- */
- public final HttpParams getApplicationParams() {
- return applicationParams;
- }
-
- /**
- * Obtains the client parameters of this stack.
- *
- * @return the client parameters, or null
- */
- public final HttpParams getClientParams() {
- return clientParams;
- }
-
- /**
- * Obtains the request parameters of this stack.
- *
- * @return the request parameters, or null
- */
- public final HttpParams getRequestParams() {
- return requestParams;
- }
-
- /**
- * Obtains the override parameters of this stack.
- *
- * @return the override parameters, or null
- */
- public final HttpParams getOverrideParams() {
- return overrideParams;
- }
-
-
- /**
- * Obtains a parameter from this stack.
- * See class comment for search order.
- *
- * @param name the name of the parameter to obtain
- *
- * @return the highest-priority value for that parameter, or
- * null if it is not set anywhere in this stack
- */
- public Object getParameter(String name) {
- if (name == null) {
- throw new IllegalArgumentException
- ("Parameter name must not be null.");
- }
-
- Object result = null;
-
- if (overrideParams != null) {
- result = overrideParams.getParameter(name);
- }
- if ((result == null) && (requestParams != null)) {
- result = requestParams.getParameter(name);
- }
- if ((result == null) && (clientParams != null)) {
- result = clientParams.getParameter(name);
- }
- if ((result == null) && (applicationParams != null)) {
- result = applicationParams.getParameter(name);
- }
- if (this.log.isDebugEnabled()) {
- this.log.debug("'" + name + "': " + result);
- }
-
- return result;
- }
-
- /**
- * Does not set a parameter.
- * Parameter stacks are read-only. It is possible, though discouraged,
- * to access and modify specific stack entries.
- * Derived classes may change this behavior.
- *
- * @param name ignored
- * @param value ignored
- *
- * @return nothing
- *
- * @throws UnsupportedOperationException always
- */
- public HttpParams setParameter(String name, Object value)
- throws UnsupportedOperationException {
-
- throw new UnsupportedOperationException
- ("Setting parameters in a stack is not supported.");
- }
-
-
- /**
- * Does not remove a parameter.
- * Parameter stacks are read-only. It is possible, though discouraged,
- * to access and modify specific stack entries.
- * Derived classes may change this behavior.
- *
- * @param name ignored
- *
- * @return nothing
- *
- * @throws UnsupportedOperationException always
- */
- public boolean removeParameter(String name) {
- throw new UnsupportedOperationException
- ("Removing parameters in a stack is not supported.");
- }
-
-
- /**
- * Does not copy parameters.
- * Parameter stacks are lightweight objects, expected to be instantiated
- * as needed and to be used only in a very specific context. On top of
- * that, they are read-only. The typical copy operation to prevent
- * accidental modification of parameters passed by the application to
- * a framework object is therefore pointless and disabled.
- * Create a new stack if you really need a copy.
- *
- * Derived classes may change this behavior.
- *
- * @return this parameter stack
- */
- public HttpParams copy() {
- return this;
- }
-
-
-}
diff --git a/src/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java b/src/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
deleted file mode 100644
index c7641d2105e2d44cc18e9ffc4839d18791cd099e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategy.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $HeadURL: $
- * $Revision: $
- * $Date: $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderElementIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.message.BasicHeaderElementIterator;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Default implementation of a strategy deciding duration
- * that a connection can remain idle.
- *
- * The default implementation looks solely at the 'Keep-Alive'
- * header's timeout token.
- *
- * @author Sam Berlin
- *
- * @version $Revision: $
- *
- * @since 4.0
- */
-public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy {
-
- public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- HeaderElementIterator it = new BasicHeaderElementIterator(
- response.headerIterator(HTTP.CONN_KEEP_ALIVE));
- while (it.hasNext()) {
- HeaderElement he = it.nextElement();
- String param = he.getName();
- String value = he.getValue();
- if (value != null && param.equalsIgnoreCase("timeout")) {
- try {
- return Long.parseLong(value) * 1000;
- } catch(NumberFormatException ignore) {
- }
- }
- }
- return -1;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/DefaultHttpClient.java b/src/org/apache/http/impl/client/DefaultHttpClient.java
deleted file mode 100644
index f0b694e40f4117e4b6e4d6382f76a3193c67e825..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultHttpClient.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java $
- * $Revision: 677250 $
- * $Date: 2008-07-16 04:45:47 -0700 (Wed, 16 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpVersion;
-import org.apache.http.auth.AuthSchemeRegistry;
-import org.apache.http.client.AuthenticationHandler;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.RedirectHandler;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.params.AuthPolicy;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.params.CookiePolicy;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.client.protocol.RequestAddCookies;
-import org.apache.http.client.protocol.RequestDefaultHeaders;
-import org.apache.http.client.protocol.RequestProxyAuthentication;
-import org.apache.http.client.protocol.RequestTargetAuthentication;
-import org.apache.http.client.protocol.ResponseProcessCookies;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionManagerFactory;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.cookie.CookieSpecRegistry;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.impl.auth.BasicSchemeFactory;
-import org.apache.http.impl.auth.DigestSchemeFactory;
-import org.apache.http.impl.conn.DefaultHttpRoutePlanner;
-import org.apache.http.impl.conn.SingleClientConnManager;
-import org.apache.http.impl.cookie.BestMatchSpecFactory;
-import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
-import org.apache.http.impl.cookie.NetscapeDraftSpecFactory;
-import org.apache.http.impl.cookie.RFC2109SpecFactory;
-import org.apache.http.impl.cookie.RFC2965SpecFactory;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.BasicHttpProcessor;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.RequestConnControl;
-import org.apache.http.protocol.RequestContent;
-import org.apache.http.protocol.RequestExpectContinue;
-import org.apache.http.protocol.RequestTargetHost;
-import org.apache.http.protocol.RequestUserAgent;
-import org.apache.http.util.VersionInfo;
-
-
-
-/**
- * Default implementation of an HTTP client.
- *
- * This class replaces HttpClient in HttpClient 3.
- *
- * @author Roland Weber
- * @author Oleg Kalnichevski
- *
- *
- * @version $Revision: 677250 $
- *
- * @since 4.0
- */
-public class DefaultHttpClient extends AbstractHttpClient {
-
-
- /**
- * Creates a new HTTP client from parameters and a connection manager.
- *
- * @param params the parameters
- * @param conman the connection manager
- */
- public DefaultHttpClient(
- final ClientConnectionManager conman,
- final HttpParams params) {
- super(conman, params);
- }
-
-
- public DefaultHttpClient(final HttpParams params) {
- super(null, params);
- }
-
-
- public DefaultHttpClient() {
- super(null, null);
- }
-
-
- @Override
- protected HttpParams createHttpParams() {
- HttpParams params = new BasicHttpParams();
- HttpProtocolParams.setVersion(params,
- HttpVersion.HTTP_1_1);
- HttpProtocolParams.setContentCharset(params,
- HTTP.DEFAULT_CONTENT_CHARSET);
- HttpProtocolParams.setUseExpectContinue(params,
- true);
-
- // determine the release version from packaged version info
- final VersionInfo vi = VersionInfo.loadVersionInfo
- ("org.apache.http.client", getClass().getClassLoader());
- final String release = (vi != null) ?
- vi.getRelease() : VersionInfo.UNAVAILABLE;
- HttpProtocolParams.setUserAgent(params,
- "Apache-HttpClient/" + release + " (java 1.4)");
-
- return params;
- }
-
-
- @Override
- protected HttpRequestExecutor createRequestExecutor() {
- return new HttpRequestExecutor();
- }
-
-
- @Override
- protected ClientConnectionManager createClientConnectionManager() {
- SchemeRegistry registry = new SchemeRegistry();
- registry.register(
- new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
- registry.register(
- new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
-
- ClientConnectionManager connManager = null;
- HttpParams params = getParams();
-
- ClientConnectionManagerFactory factory = null;
-
- // Try first getting the factory directly as an object.
- factory = (ClientConnectionManagerFactory) params
- .getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
- if (factory == null) { // then try getting its class name.
- String className = (String) params.getParameter(
- ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
- if (className != null) {
- try {
- Class> clazz = Class.forName(className);
- factory = (ClientConnectionManagerFactory) clazz.newInstance();
- } catch (ClassNotFoundException ex) {
- throw new IllegalStateException("Invalid class name: " + className);
- } catch (IllegalAccessException ex) {
- throw new IllegalAccessError(ex.getMessage());
- } catch (InstantiationException ex) {
- throw new InstantiationError(ex.getMessage());
- }
- }
- }
-
- if(factory != null) {
- connManager = factory.newInstance(params, registry);
- } else {
- connManager = new SingleClientConnManager(getParams(), registry);
- }
-
- return connManager;
- }
-
-
- @Override
- protected HttpContext createHttpContext() {
- HttpContext context = new BasicHttpContext();
- context.setAttribute(
- ClientContext.AUTHSCHEME_REGISTRY,
- getAuthSchemes());
- context.setAttribute(
- ClientContext.COOKIESPEC_REGISTRY,
- getCookieSpecs());
- context.setAttribute(
- ClientContext.COOKIE_STORE,
- getCookieStore());
- context.setAttribute(
- ClientContext.CREDS_PROVIDER,
- getCredentialsProvider());
- return context;
- }
-
-
- @Override
- protected ConnectionReuseStrategy createConnectionReuseStrategy() {
- return new DefaultConnectionReuseStrategy();
- }
-
- @Override
- protected ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy() {
- return new DefaultConnectionKeepAliveStrategy();
- }
-
-
- @Override
- protected AuthSchemeRegistry createAuthSchemeRegistry() {
- AuthSchemeRegistry registry = new AuthSchemeRegistry();
- registry.register(
- AuthPolicy.BASIC,
- new BasicSchemeFactory());
- registry.register(
- AuthPolicy.DIGEST,
- new DigestSchemeFactory());
- return registry;
- }
-
-
- @Override
- protected CookieSpecRegistry createCookieSpecRegistry() {
- CookieSpecRegistry registry = new CookieSpecRegistry();
- registry.register(
- CookiePolicy.BEST_MATCH,
- new BestMatchSpecFactory());
- registry.register(
- CookiePolicy.BROWSER_COMPATIBILITY,
- new BrowserCompatSpecFactory());
- registry.register(
- CookiePolicy.NETSCAPE,
- new NetscapeDraftSpecFactory());
- registry.register(
- CookiePolicy.RFC_2109,
- new RFC2109SpecFactory());
- registry.register(
- CookiePolicy.RFC_2965,
- new RFC2965SpecFactory());
- return registry;
- }
-
-
- @Override
- protected BasicHttpProcessor createHttpProcessor() {
- BasicHttpProcessor httpproc = new BasicHttpProcessor();
- httpproc.addInterceptor(new RequestDefaultHeaders());
- // Required protocol interceptors
- httpproc.addInterceptor(new RequestContent());
- httpproc.addInterceptor(new RequestTargetHost());
- // Recommended protocol interceptors
- httpproc.addInterceptor(new RequestConnControl());
- httpproc.addInterceptor(new RequestUserAgent());
- httpproc.addInterceptor(new RequestExpectContinue());
- // HTTP state management interceptors
- httpproc.addInterceptor(new RequestAddCookies());
- httpproc.addInterceptor(new ResponseProcessCookies());
- // HTTP authentication interceptors
- httpproc.addInterceptor(new RequestTargetAuthentication());
- httpproc.addInterceptor(new RequestProxyAuthentication());
- return httpproc;
- }
-
-
- @Override
- protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
- return new DefaultHttpRequestRetryHandler();
- }
-
-
- @Override
- protected RedirectHandler createRedirectHandler() {
- return new DefaultRedirectHandler();
- }
-
-
- @Override
- protected AuthenticationHandler createTargetAuthenticationHandler() {
- return new DefaultTargetAuthenticationHandler();
- }
-
-
- @Override
- protected AuthenticationHandler createProxyAuthenticationHandler() {
- return new DefaultProxyAuthenticationHandler();
- }
-
-
- @Override
- protected CookieStore createCookieStore() {
- return new BasicCookieStore();
- }
-
-
- @Override
- protected CredentialsProvider createCredentialsProvider() {
- return new BasicCredentialsProvider();
- }
-
-
- @Override
- protected HttpRoutePlanner createHttpRoutePlanner() {
- return new DefaultHttpRoutePlanner
- (getConnectionManager().getSchemeRegistry());
- }
-
-
- @Override
- protected UserTokenHandler createUserTokenHandler() {
- return new DefaultUserTokenHandler();
- }
-
-} // class DefaultHttpClient
diff --git a/src/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/src/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
deleted file mode 100644
index 7f669902b63af85ade495bd7e439dd62c3c84ccf..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java $
- * $Revision: 652726 $
- * $Date: 2008-05-01 18:16:51 -0700 (Thu, 01 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.UnknownHostException;
-
-import javax.net.ssl.SSLHandshakeException;
-
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.ExecutionContext;
-
-/**
- * The default {@link HttpRequestRetryHandler} used by request executors.
- *
- * @author Michael Becke
- * @author Oleg Kalnichevski
- */
-public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
-
- /** the number of times a method will be retried */
- private final int retryCount;
-
- /** Whether or not methods that have successfully sent their request will be retried */
- private final boolean requestSentRetryEnabled;
-
- /**
- * Default constructor
- */
- public DefaultHttpRequestRetryHandler(int retryCount, boolean requestSentRetryEnabled) {
- super();
- this.retryCount = retryCount;
- this.requestSentRetryEnabled = requestSentRetryEnabled;
- }
-
- /**
- * Default constructor
- */
- public DefaultHttpRequestRetryHandler() {
- this(3, false);
- }
- /**
- * Used retryCount and requestSentRetryEnabled to determine
- * if the given method should be retried.
- */
- public boolean retryRequest(
- final IOException exception,
- int executionCount,
- final HttpContext context) {
- if (exception == null) {
- throw new IllegalArgumentException("Exception parameter may not be null");
- }
- if (context == null) {
- throw new IllegalArgumentException("HTTP context may not be null");
- }
- if (executionCount > this.retryCount) {
- // Do not retry if over max retry count
- return false;
- }
- if (exception instanceof NoHttpResponseException) {
- // Retry if the server dropped connection on us
- return true;
- }
- if (exception instanceof InterruptedIOException) {
- // Timeout
- return false;
- }
- if (exception instanceof UnknownHostException) {
- // Unknown host
- return false;
- }
- if (exception instanceof SSLHandshakeException) {
- // SSL handshake exception
- return false;
- }
- Boolean b = (Boolean)
- context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
- boolean sent = (b != null && b.booleanValue());
- if (!sent || this.requestSentRetryEnabled) {
- // Retry if the request has not been sent fully or
- // if it's OK to retry methods that have been sent
- return true;
- }
- // otherwise do not retry
- return false;
- }
-
- /**
- * @return true if this handler will retry methods that have
- * successfully sent their request, false otherwise
- */
- public boolean isRequestSentRetryEnabled() {
- return requestSentRetryEnabled;
- }
-
- /**
- * @return the maximum number of times a method will be retried
- */
- public int getRetryCount() {
- return retryCount;
- }
-}
diff --git a/src/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java b/src/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
deleted file mode 100644
index c188da80f5e6767423df293fe2f5a87e883ae2e9..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java $
- * $Revision: 603615 $
- * $Date: 2007-12-12 06:03:21 -0800 (Wed, 12 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.Map;
-
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * @author Oleg Kalnichevski
- */
-public class DefaultProxyAuthenticationHandler extends AbstractAuthenticationHandler {
-
- public DefaultProxyAuthenticationHandler() {
- super();
- }
-
- public boolean isAuthenticationRequested(
- final HttpResponse response,
- final HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- int status = response.getStatusLine().getStatusCode();
- return status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED;
- }
-
- public Map getChallenges(
- final HttpResponse response,
- final HttpContext context) throws MalformedChallengeException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- Header[] headers = response.getHeaders(AUTH.PROXY_AUTH);
- return parseChallenges(headers);
- }
-
-}
diff --git a/src/org/apache/http/impl/client/DefaultRedirectHandler.java b/src/org/apache/http/impl/client/DefaultRedirectHandler.java
deleted file mode 100644
index 0811b28429bcb2ffad42e00fdeeb0da7d7b431fa..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultRedirectHandler.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.client.CircularRedirectException;
-import org.apache.http.client.RedirectHandler;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.utils.URIUtils;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.ExecutionContext;
-
-
-/**
- * Default implementation of {@link RedirectHandler}.
- *
- * @author Oleg Kalnichevski
- *
- *
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class DefaultRedirectHandler implements RedirectHandler {
-
- private final Log log = LogFactory.getLog(getClass());
-
- private static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
-
- public DefaultRedirectHandler() {
- super();
- }
-
- public boolean isRedirectRequested(
- final HttpResponse response,
- final HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- int statusCode = response.getStatusLine().getStatusCode();
- switch (statusCode) {
- case HttpStatus.SC_MOVED_TEMPORARILY:
- case HttpStatus.SC_MOVED_PERMANENTLY:
- case HttpStatus.SC_SEE_OTHER:
- case HttpStatus.SC_TEMPORARY_REDIRECT:
- return true;
- default:
- return false;
- } //end of switch
- }
-
- public URI getLocationURI(
- final HttpResponse response,
- final HttpContext context) throws ProtocolException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- //get the location header to find out where to redirect to
- Header locationHeader = response.getFirstHeader("location");
- if (locationHeader == null) {
- // got a redirect response, but no location header
- throw new ProtocolException(
- "Received redirect response " + response.getStatusLine()
- + " but no location header");
- }
- String location = locationHeader.getValue();
- if (this.log.isDebugEnabled()) {
- this.log.debug("Redirect requested to location '" + location + "'");
- }
-
- URI uri;
- try {
- uri = new URI(location);
- } catch (URISyntaxException ex) {
- throw new ProtocolException("Invalid redirect URI: " + location, ex);
- }
-
- HttpParams params = response.getParams();
- // rfc2616 demands the location value be a complete URI
- // Location = "Location" ":" absoluteURI
- if (!uri.isAbsolute()) {
- if (params.isParameterTrue(ClientPNames.REJECT_RELATIVE_REDIRECT)) {
- throw new ProtocolException("Relative redirect location '"
- + uri + "' not allowed");
- }
- // Adjust location URI
- HttpHost target = (HttpHost) context.getAttribute(
- ExecutionContext.HTTP_TARGET_HOST);
- if (target == null) {
- throw new IllegalStateException("Target host not available " +
- "in the HTTP context");
- }
-
- HttpRequest request = (HttpRequest) context.getAttribute(
- ExecutionContext.HTTP_REQUEST);
-
- try {
- URI requestURI = new URI(request.getRequestLine().getUri());
- URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, true);
- uri = URIUtils.resolve(absoluteRequestURI, uri);
- } catch (URISyntaxException ex) {
- throw new ProtocolException(ex.getMessage(), ex);
- }
- }
-
- if (params.isParameterFalse(ClientPNames.ALLOW_CIRCULAR_REDIRECTS)) {
-
- RedirectLocations redirectLocations = (RedirectLocations) context.getAttribute(
- REDIRECT_LOCATIONS);
-
- if (redirectLocations == null) {
- redirectLocations = new RedirectLocations();
- context.setAttribute(REDIRECT_LOCATIONS, redirectLocations);
- }
-
- URI redirectURI;
- if (uri.getFragment() != null) {
- try {
- HttpHost target = new HttpHost(
- uri.getHost(),
- uri.getPort(),
- uri.getScheme());
- redirectURI = URIUtils.rewriteURI(uri, target, true);
- } catch (URISyntaxException ex) {
- throw new ProtocolException(ex.getMessage(), ex);
- }
- } else {
- redirectURI = uri;
- }
-
- if (redirectLocations.contains(redirectURI)) {
- throw new CircularRedirectException("Circular redirect to '" +
- redirectURI + "'");
- } else {
- redirectLocations.add(redirectURI);
- }
- }
-
- return uri;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/DefaultRequestDirector.java b/src/org/apache/http/impl/client/DefaultRequestDirector.java
deleted file mode 100644
index 511f8a0cb2308a11b1afff67d166736166d16758..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultRequestDirector.java
+++ /dev/null
@@ -1,1088 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java $
- * $Revision: 676023 $
- * $Date: 2008-07-11 09:40:56 -0700 (Fri, 11 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.client.AuthenticationHandler;
-import org.apache.http.client.RequestDirector;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.NonRepeatableRequestException;
-import org.apache.http.client.RedirectException;
-import org.apache.http.client.RedirectHandler;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.methods.AbortableHttpRequest;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.params.HttpClientParams;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.client.utils.URIUtils;
-import org.apache.http.conn.BasicManagedEntity;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.params.ConnManagerParams;
-import org.apache.http.conn.routing.BasicRouteDirector;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.HttpRouteDirector;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.entity.BufferedHttpEntity;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-
-/**
- * Default implementation of {@link RequestDirector}.
- *
- * This class replaces the HttpMethodDirector in HttpClient 3.
- *
- * @author Roland Weber
- * @author Oleg Kalnichevski
- *
- *
- * @version $Revision: 676023 $
- *
- * @since 4.0
- */
-public class DefaultRequestDirector implements RequestDirector {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /** The connection manager. */
- protected final ClientConnectionManager connManager;
-
- /** The route planner. */
- protected final HttpRoutePlanner routePlanner;
-
- /** The connection re-use strategy. */
- protected final ConnectionReuseStrategy reuseStrategy;
-
- /** The keep-alive duration strategy. */
- protected final ConnectionKeepAliveStrategy keepAliveStrategy;
-
- /** The request executor. */
- protected final HttpRequestExecutor requestExec;
-
- /** The HTTP protocol processor. */
- protected final HttpProcessor httpProcessor;
-
- /** The request retry handler. */
- protected final HttpRequestRetryHandler retryHandler;
-
- /** The redirect handler. */
- protected final RedirectHandler redirectHandler;
-
- /** The target authentication handler. */
- private final AuthenticationHandler targetAuthHandler;
-
- /** The proxy authentication handler. */
- private final AuthenticationHandler proxyAuthHandler;
-
- /** The user token handler. */
- private final UserTokenHandler userTokenHandler;
-
- /** The HTTP parameters. */
- protected final HttpParams params;
-
- /** The currently allocated connection. */
- protected ManagedClientConnection managedConn;
-
- private int redirectCount;
-
- private int maxRedirects;
-
- private final AuthState targetAuthState;
-
- private final AuthState proxyAuthState;
-
- public DefaultRequestDirector(
- final HttpRequestExecutor requestExec,
- final ClientConnectionManager conman,
- final ConnectionReuseStrategy reustrat,
- final ConnectionKeepAliveStrategy kastrat,
- final HttpRoutePlanner rouplan,
- final HttpProcessor httpProcessor,
- final HttpRequestRetryHandler retryHandler,
- final RedirectHandler redirectHandler,
- final AuthenticationHandler targetAuthHandler,
- final AuthenticationHandler proxyAuthHandler,
- final UserTokenHandler userTokenHandler,
- final HttpParams params) {
-
- if (requestExec == null) {
- throw new IllegalArgumentException
- ("Request executor may not be null.");
- }
- if (conman == null) {
- throw new IllegalArgumentException
- ("Client connection manager may not be null.");
- }
- if (reustrat == null) {
- throw new IllegalArgumentException
- ("Connection reuse strategy may not be null.");
- }
- if (kastrat == null) {
- throw new IllegalArgumentException
- ("Connection keep alive strategy may not be null.");
- }
- if (rouplan == null) {
- throw new IllegalArgumentException
- ("Route planner may not be null.");
- }
- if (httpProcessor == null) {
- throw new IllegalArgumentException
- ("HTTP protocol processor may not be null.");
- }
- if (retryHandler == null) {
- throw new IllegalArgumentException
- ("HTTP request retry handler may not be null.");
- }
- if (redirectHandler == null) {
- throw new IllegalArgumentException
- ("Redirect handler may not be null.");
- }
- if (targetAuthHandler == null) {
- throw new IllegalArgumentException
- ("Target authentication handler may not be null.");
- }
- if (proxyAuthHandler == null) {
- throw new IllegalArgumentException
- ("Proxy authentication handler may not be null.");
- }
- if (userTokenHandler == null) {
- throw new IllegalArgumentException
- ("User token handler may not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException
- ("HTTP parameters may not be null");
- }
- this.requestExec = requestExec;
- this.connManager = conman;
- this.reuseStrategy = reustrat;
- this.keepAliveStrategy = kastrat;
- this.routePlanner = rouplan;
- this.httpProcessor = httpProcessor;
- this.retryHandler = retryHandler;
- this.redirectHandler = redirectHandler;
- this.targetAuthHandler = targetAuthHandler;
- this.proxyAuthHandler = proxyAuthHandler;
- this.userTokenHandler = userTokenHandler;
- this.params = params;
-
- this.managedConn = null;
-
- this.redirectCount = 0;
- this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
- this.targetAuthState = new AuthState();
- this.proxyAuthState = new AuthState();
- } // constructor
-
-
- private RequestWrapper wrapRequest(
- final HttpRequest request) throws ProtocolException {
- if (request instanceof HttpEntityEnclosingRequest) {
- return new EntityEnclosingRequestWrapper(
- (HttpEntityEnclosingRequest) request);
- } else {
- return new RequestWrapper(
- request);
- }
- }
-
-
- protected void rewriteRequestURI(
- final RequestWrapper request,
- final HttpRoute route) throws ProtocolException {
- try {
-
- URI uri = request.getURI();
- if (route.getProxyHost() != null && !route.isTunnelled()) {
- // Make sure the request URI is absolute
- if (!uri.isAbsolute()) {
- HttpHost target = route.getTargetHost();
- uri = URIUtils.rewriteURI(uri, target);
- request.setURI(uri);
- }
- } else {
- // Make sure the request URI is relative
- if (uri.isAbsolute()) {
- uri = URIUtils.rewriteURI(uri, null);
- request.setURI(uri);
- }
- }
-
- } catch (URISyntaxException ex) {
- throw new ProtocolException("Invalid URI: " +
- request.getRequestLine().getUri(), ex);
- }
- }
-
-
- // non-javadoc, see interface ClientRequestDirector
- public HttpResponse execute(HttpHost target, HttpRequest request,
- HttpContext context)
- throws HttpException, IOException {
-
- HttpRequest orig = request;
- RequestWrapper origWrapper = wrapRequest(orig);
- origWrapper.setParams(params);
- HttpRoute origRoute = determineRoute(target, origWrapper, context);
-
- RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
-
- long timeout = ConnManagerParams.getTimeout(params);
-
- int execCount = 0;
-
- boolean reuse = false;
- HttpResponse response = null;
- boolean done = false;
- try {
- while (!done) {
- // In this loop, the RoutedRequest may be replaced by a
- // followup request and route. The request and route passed
- // in the method arguments will be replaced. The original
- // request is still available in 'orig'.
-
- RequestWrapper wrapper = roureq.getRequest();
- HttpRoute route = roureq.getRoute();
-
- // See if we have a user token bound to the execution context
- Object userToken = context.getAttribute(ClientContext.USER_TOKEN);
-
- // Allocate connection if needed
- if (managedConn == null) {
- ClientConnectionRequest connRequest = connManager.requestConnection(
- route, userToken);
- if (orig instanceof AbortableHttpRequest) {
- ((AbortableHttpRequest) orig).setConnectionRequest(connRequest);
- }
-
- try {
- managedConn = connRequest.getConnection(timeout, TimeUnit.MILLISECONDS);
- } catch(InterruptedException interrupted) {
- InterruptedIOException iox = new InterruptedIOException();
- iox.initCause(interrupted);
- throw iox;
- }
-
- if (HttpConnectionParams.isStaleCheckingEnabled(params)) {
- // validate connection
- this.log.debug("Stale connection check");
- if (managedConn.isStale()) {
- this.log.debug("Stale connection detected");
- managedConn.close();
- }
- }
- }
-
- if (orig instanceof AbortableHttpRequest) {
- ((AbortableHttpRequest) orig).setReleaseTrigger(managedConn);
- }
-
- // Reopen connection if needed
- if (!managedConn.isOpen()) {
- managedConn.open(route, context, params);
- }
-
- try {
- establishRoute(route, context);
- } catch (TunnelRefusedException ex) {
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage());
- }
- response = ex.getResponse();
- break;
- }
-
- // Reset headers on the request wrapper
- wrapper.resetHeaders();
-
- // Re-write request URI if needed
- rewriteRequestURI(wrapper, route);
-
- // Use virtual host if set
- target = (HttpHost) wrapper.getParams().getParameter(
- ClientPNames.VIRTUAL_HOST);
-
- if (target == null) {
- target = route.getTargetHost();
- }
-
- HttpHost proxy = route.getProxyHost();
-
- // Populate the execution context
- context.setAttribute(ExecutionContext.HTTP_TARGET_HOST,
- target);
- context.setAttribute(ExecutionContext.HTTP_PROXY_HOST,
- proxy);
- context.setAttribute(ExecutionContext.HTTP_CONNECTION,
- managedConn);
- context.setAttribute(ClientContext.TARGET_AUTH_STATE,
- targetAuthState);
- context.setAttribute(ClientContext.PROXY_AUTH_STATE,
- proxyAuthState);
-
- // Run request protocol interceptors
- requestExec.preProcess(wrapper, httpProcessor, context);
-
- context.setAttribute(ExecutionContext.HTTP_REQUEST,
- wrapper);
-
- boolean retrying = true;
- while (retrying) {
- // Increment total exec count (with redirects)
- execCount++;
- // Increment exec count for this particular request
- wrapper.incrementExecCount();
- if (wrapper.getExecCount() > 1 && !wrapper.isRepeatable()) {
- throw new NonRepeatableRequestException("Cannot retry request " +
- "with a non-repeatable request entity");
- }
-
- try {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Attempt " + execCount + " to execute request");
- }
- response = requestExec.execute(wrapper, managedConn, context);
- retrying = false;
-
- } catch (IOException ex) {
- this.log.debug("Closing the connection.");
- managedConn.close();
- if (retryHandler.retryRequest(ex, execCount, context)) {
- if (this.log.isInfoEnabled()) {
- this.log.info("I/O exception ("+ ex.getClass().getName() +
- ") caught when processing request: "
- + ex.getMessage());
- }
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage(), ex);
- }
- this.log.info("Retrying request");
- } else {
- throw ex;
- }
-
- // If we have a direct route to the target host
- // just re-open connection and re-try the request
- if (route.getHopCount() == 1) {
- this.log.debug("Reopening the direct connection.");
- managedConn.open(route, context, params);
- } else {
- // otherwise give up
- retrying = false;
- }
-
- }
-
- }
-
- // Run response protocol interceptors
- response.setParams(params);
- requestExec.postProcess(response, httpProcessor, context);
-
-
- // The connection is in or can be brought to a re-usable state.
- reuse = reuseStrategy.keepAlive(response, context);
- if(reuse) {
- // Set the idle duration of this connection
- long duration = keepAliveStrategy.getKeepAliveDuration(response, context);
- managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
- }
-
- RoutedRequest followup = handleResponse(roureq, response, context);
- if (followup == null) {
- done = true;
- } else {
- if (reuse) {
- this.log.debug("Connection kept alive");
- // Make sure the response body is fully consumed, if present
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- entity.consumeContent();
- }
- // entity consumed above is not an auto-release entity,
- // need to mark the connection re-usable explicitly
- managedConn.markReusable();
- } else {
- managedConn.close();
- }
- // check if we can use the same connection for the followup
- if (!followup.getRoute().equals(roureq.getRoute())) {
- releaseConnection();
- }
- roureq = followup;
- }
-
- userToken = this.userTokenHandler.getUserToken(context);
- context.setAttribute(ClientContext.USER_TOKEN, userToken);
- if (managedConn != null) {
- managedConn.setState(userToken);
- }
- } // while not done
-
-
- // check for entity, release connection if possible
- if ((response == null) || (response.getEntity() == null) ||
- !response.getEntity().isStreaming()) {
- // connection not needed and (assumed to be) in re-usable state
- if (reuse)
- managedConn.markReusable();
- releaseConnection();
- } else {
- // install an auto-release entity
- HttpEntity entity = response.getEntity();
- entity = new BasicManagedEntity(entity, managedConn, reuse);
- response.setEntity(entity);
- }
-
- return response;
-
- } catch (HttpException ex) {
- abortConnection();
- throw ex;
- } catch (IOException ex) {
- abortConnection();
- throw ex;
- } catch (RuntimeException ex) {
- abortConnection();
- throw ex;
- }
- } // execute
-
- /**
- * Returns the connection back to the connection manager
- * and prepares for retrieving a new connection during
- * the next request.
- */
- protected void releaseConnection() {
- // Release the connection through the ManagedConnection instead of the
- // ConnectionManager directly. This lets the connection control how
- // it is released.
- try {
- managedConn.releaseConnection();
- } catch(IOException ignored) {
- this.log.debug("IOException releasing connection", ignored);
- }
- managedConn = null;
- }
-
- /**
- * Determines the route for a request.
- * Called by {@link #execute}
- * to determine the route for either the original or a followup request.
- *
- * @param target the target host for the request.
- * Implementations may accept null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param context the context to use for the execution,
- * never null
- *
- * @return the route the request should take
- *
- * @throws HttpException in case of a problem
- */
- protected HttpRoute determineRoute(HttpHost target,
- HttpRequest request,
- HttpContext context)
- throws HttpException {
-
- if (target == null) {
- target = (HttpHost) request.getParams().getParameter(
- ClientPNames.DEFAULT_HOST);
- }
- if (target == null) {
- throw new IllegalStateException
- ("Target host must not be null, or set in parameters.");
- }
-
- return this.routePlanner.determineRoute(target, request, context);
- }
-
-
- /**
- * Establishes the target route.
- *
- * @param route the route to establish
- * @param context the context for the request execution
- *
- * @throws HttpException in case of a problem
- * @throws IOException in case of an IO problem
- */
- protected void establishRoute(HttpRoute route, HttpContext context)
- throws HttpException, IOException {
-
- //@@@ how to handle CONNECT requests for tunnelling?
- //@@@ refuse to send external CONNECT via director? special handling?
-
- //@@@ should the request parameters already be used below?
- //@@@ probably yes, but they're not linked yet
- //@@@ will linking above cause problems with linking in reqExec?
- //@@@ probably not, because the parent is replaced
- //@@@ just make sure we don't link parameters to themselves
-
- HttpRouteDirector rowdy = new BasicRouteDirector();
- int step;
- do {
- HttpRoute fact = managedConn.getRoute();
- step = rowdy.nextStep(route, fact);
-
- switch (step) {
-
- case HttpRouteDirector.CONNECT_TARGET:
- case HttpRouteDirector.CONNECT_PROXY:
- managedConn.open(route, context, this.params);
- break;
-
- case HttpRouteDirector.TUNNEL_TARGET: {
- boolean secure = createTunnelToTarget(route, context);
- this.log.debug("Tunnel to target created.");
- managedConn.tunnelTarget(secure, this.params);
- } break;
-
- case HttpRouteDirector.TUNNEL_PROXY: {
- // The most simple example for this case is a proxy chain
- // of two proxies, where P1 must be tunnelled to P2.
- // route: Source -> P1 -> P2 -> Target (3 hops)
- // fact: Source -> P1 -> Target (2 hops)
- final int hop = fact.getHopCount()-1; // the hop to establish
- boolean secure = createTunnelToProxy(route, hop, context);
- this.log.debug("Tunnel to proxy created.");
- managedConn.tunnelProxy(route.getHopTarget(hop),
- secure, this.params);
- } break;
-
-
- case HttpRouteDirector.LAYER_PROTOCOL:
- managedConn.layerProtocol(context, this.params);
- break;
-
- case HttpRouteDirector.UNREACHABLE:
- throw new IllegalStateException
- ("Unable to establish route." +
- "\nplanned = " + route +
- "\ncurrent = " + fact);
-
- case HttpRouteDirector.COMPLETE:
- // do nothing
- break;
-
- default:
- throw new IllegalStateException
- ("Unknown step indicator "+step+" from RouteDirector.");
- } // switch
-
- } while (step > HttpRouteDirector.COMPLETE);
-
- } // establishConnection
-
-
- /**
- * Creates a tunnel to the target server.
- * The connection must be established to the (last) proxy.
- * A CONNECT request for tunnelling through the proxy will
- * be created and sent, the response received and checked.
- * This method does not update the connection with
- * information about the tunnel, that is left to the caller.
- *
- * @param route the route to establish
- * @param context the context for request execution
- *
- * @return true if the tunnelled route is secure,
- * false otherwise.
- * The implementation here always returns false,
- * but derived classes may override.
- *
- * @throws HttpException in case of a problem
- * @throws IOException in case of an IO problem
- */
- protected boolean createTunnelToTarget(HttpRoute route,
- HttpContext context)
- throws HttpException, IOException {
-
- HttpHost proxy = route.getProxyHost();
- HttpHost target = route.getTargetHost();
- HttpResponse response = null;
-
- boolean done = false;
- while (!done) {
-
- done = true;
-
- if (!this.managedConn.isOpen()) {
- this.managedConn.open(route, context, this.params);
- }
-
- HttpRequest connect = createConnectRequest(route, context);
-
- String agent = HttpProtocolParams.getUserAgent(params);
- if (agent != null) {
- connect.addHeader(HTTP.USER_AGENT, agent);
- }
- connect.addHeader(HTTP.TARGET_HOST, target.toHostString());
-
- AuthScheme authScheme = this.proxyAuthState.getAuthScheme();
- AuthScope authScope = this.proxyAuthState.getAuthScope();
- Credentials creds = this.proxyAuthState.getCredentials();
- if (creds != null) {
- if (authScope != null || !authScheme.isConnectionBased()) {
- try {
- connect.addHeader(authScheme.authenticate(creds, connect));
- } catch (AuthenticationException ex) {
- if (this.log.isErrorEnabled()) {
- this.log.error("Proxy authentication error: " + ex.getMessage());
- }
- }
- }
- }
-
- response = requestExec.execute(connect, this.managedConn, context);
-
- int status = response.getStatusLine().getStatusCode();
- if (status < 200) {
- throw new HttpException("Unexpected response to CONNECT request: " +
- response.getStatusLine());
- }
-
- CredentialsProvider credsProvider = (CredentialsProvider)
- context.getAttribute(ClientContext.CREDS_PROVIDER);
-
- if (credsProvider != null && HttpClientParams.isAuthenticating(params)) {
- if (this.proxyAuthHandler.isAuthenticationRequested(response, context)) {
-
- this.log.debug("Proxy requested authentication");
- Map challenges = this.proxyAuthHandler.getChallenges(
- response, context);
- try {
- processChallenges(
- challenges, this.proxyAuthState, this.proxyAuthHandler,
- response, context);
- } catch (AuthenticationException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Authentication error: " + ex.getMessage());
- break;
- }
- }
- updateAuthState(this.proxyAuthState, proxy, credsProvider);
-
- if (this.proxyAuthState.getCredentials() != null) {
- done = false;
-
- // Retry request
- if (this.reuseStrategy.keepAlive(response, context)) {
- this.log.debug("Connection kept alive");
- // Consume response content
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- entity.consumeContent();
- }
- } else {
- this.managedConn.close();
- }
-
- }
-
- } else {
- // Reset proxy auth scope
- this.proxyAuthState.setAuthScope(null);
- }
- }
- }
-
- int status = response.getStatusLine().getStatusCode();
-
- if (status > 299) {
-
- // Buffer response content
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- response.setEntity(new BufferedHttpEntity(entity));
- }
-
- this.managedConn.close();
- throw new TunnelRefusedException("CONNECT refused by proxy: " +
- response.getStatusLine(), response);
- }
-
- this.managedConn.markReusable();
-
- // How to decide on security of the tunnelled connection?
- // The socket factory knows only about the segment to the proxy.
- // Even if that is secure, the hop to the target may be insecure.
- // Leave it to derived classes, consider insecure by default here.
- return false;
-
- } // createTunnelToTarget
-
-
-
- /**
- * Creates a tunnel to an intermediate proxy.
- * This method is not implemented in this class.
- * It just throws an exception here.
- *
- * @param route the route to establish
- * @param hop the hop in the route to establish now.
- * route.getHopTarget(hop)
- * will return the proxy to tunnel to.
- * @param context the context for request execution
- *
- * @return true if the partially tunnelled connection
- * is secure, false otherwise.
- *
- * @throws HttpException in case of a problem
- * @throws IOException in case of an IO problem
- */
- protected boolean createTunnelToProxy(HttpRoute route, int hop,
- HttpContext context)
- throws HttpException, IOException {
-
- // Have a look at createTunnelToTarget and replicate the parts
- // you need in a custom derived class. If your proxies don't require
- // authentication, it is not too hard. But for the stock version of
- // HttpClient, we cannot make such simplifying assumptions and would
- // have to include proxy authentication code. The HttpComponents team
- // is currently not in a position to support rarely used code of this
- // complexity. Feel free to submit patches that refactor the code in
- // createTunnelToTarget to facilitate re-use for proxy tunnelling.
-
- throw new UnsupportedOperationException
- ("Proxy chains are not supported.");
- }
-
-
-
- /**
- * Creates the CONNECT request for tunnelling.
- * Called by {@link #createTunnelToTarget createTunnelToTarget}.
- *
- * @param route the route to establish
- * @param context the context for request execution
- *
- * @return the CONNECT request for tunnelling
- */
- protected HttpRequest createConnectRequest(HttpRoute route,
- HttpContext context) {
- // see RFC 2817, section 5.2 and
- // INTERNET-DRAFT: Tunneling TCP based protocols through
- // Web proxy servers
-
- HttpHost target = route.getTargetHost();
-
- String host = target.getHostName();
- int port = target.getPort();
- if (port < 0) {
- Scheme scheme = connManager.getSchemeRegistry().
- getScheme(target.getSchemeName());
- port = scheme.getDefaultPort();
- }
-
- StringBuilder buffer = new StringBuilder(host.length() + 6);
- buffer.append(host);
- buffer.append(':');
- buffer.append(Integer.toString(port));
-
- String authority = buffer.toString();
- ProtocolVersion ver = HttpProtocolParams.getVersion(params);
- HttpRequest req = new BasicHttpRequest
- ("CONNECT", authority, ver);
-
- return req;
- }
-
-
- /**
- * Analyzes a response to check need for a followup.
- *
- * @param roureq the request and route.
- * @param response the response to analayze
- * @param context the context used for the current request execution
- *
- * @return the followup request and route if there is a followup, or
- * null if the response should be returned as is
- *
- * @throws HttpException in case of a problem
- * @throws IOException in case of an IO problem
- */
- protected RoutedRequest handleResponse(RoutedRequest roureq,
- HttpResponse response,
- HttpContext context)
- throws HttpException, IOException {
-
- HttpRoute route = roureq.getRoute();
- HttpHost proxy = route.getProxyHost();
- RequestWrapper request = roureq.getRequest();
-
- HttpParams params = request.getParams();
- if (HttpClientParams.isRedirecting(params) &&
- this.redirectHandler.isRedirectRequested(response, context)) {
-
- if (redirectCount >= maxRedirects) {
- throw new RedirectException("Maximum redirects ("
- + maxRedirects + ") exceeded");
- }
- redirectCount++;
-
- URI uri = this.redirectHandler.getLocationURI(response, context);
-
- HttpHost newTarget = new HttpHost(
- uri.getHost(),
- uri.getPort(),
- uri.getScheme());
-
- HttpGet redirect = new HttpGet(uri);
-
- HttpRequest orig = request.getOriginal();
- redirect.setHeaders(orig.getAllHeaders());
-
- RequestWrapper wrapper = new RequestWrapper(redirect);
- wrapper.setParams(params);
-
- HttpRoute newRoute = determineRoute(newTarget, wrapper, context);
- RoutedRequest newRequest = new RoutedRequest(wrapper, newRoute);
-
- if (this.log.isDebugEnabled()) {
- this.log.debug("Redirecting to '" + uri + "' via " + newRoute);
- }
-
- return newRequest;
- }
-
- CredentialsProvider credsProvider = (CredentialsProvider)
- context.getAttribute(ClientContext.CREDS_PROVIDER);
-
- if (credsProvider != null && HttpClientParams.isAuthenticating(params)) {
-
- if (this.targetAuthHandler.isAuthenticationRequested(response, context)) {
-
- HttpHost target = (HttpHost)
- context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
- if (target == null) {
- target = route.getTargetHost();
- }
-
- this.log.debug("Target requested authentication");
- Map challenges = this.targetAuthHandler.getChallenges(
- response, context);
- try {
- processChallenges(challenges,
- this.targetAuthState, this.targetAuthHandler,
- response, context);
- } catch (AuthenticationException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Authentication error: " + ex.getMessage());
- return null;
- }
- }
- updateAuthState(this.targetAuthState, target, credsProvider);
-
- if (this.targetAuthState.getCredentials() != null) {
- // Re-try the same request via the same route
- return roureq;
- } else {
- return null;
- }
- } else {
- // Reset target auth scope
- this.targetAuthState.setAuthScope(null);
- }
-
- if (this.proxyAuthHandler.isAuthenticationRequested(response, context)) {
-
- this.log.debug("Proxy requested authentication");
- Map challenges = this.proxyAuthHandler.getChallenges(
- response, context);
- try {
- processChallenges(challenges,
- this.proxyAuthState, this.proxyAuthHandler,
- response, context);
- } catch (AuthenticationException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Authentication error: " + ex.getMessage());
- return null;
- }
- }
- updateAuthState(this.proxyAuthState, proxy, credsProvider);
-
- if (this.proxyAuthState.getCredentials() != null) {
- // Re-try the same request via the same route
- return roureq;
- } else {
- return null;
- }
- } else {
- // Reset proxy auth scope
- this.proxyAuthState.setAuthScope(null);
- }
- }
- return null;
- } // handleResponse
-
-
- /**
- * Shuts down the connection.
- * This method is called from a catch block in
- * {@link #execute execute} during exception handling.
- */
- private void abortConnection() {
- ManagedClientConnection mcc = managedConn;
- if (mcc != null) {
- // we got here as the result of an exception
- // no response will be returned, release the connection
- managedConn = null;
- try {
- mcc.abortConnection();
- } catch (IOException ex) {
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage(), ex);
- }
- }
- // ensure the connection manager properly releases this connection
- try {
- mcc.releaseConnection();
- } catch(IOException ignored) {
- this.log.debug("Error releasing connection", ignored);
- }
- }
- } // abortConnection
-
-
- private void processChallenges(
- final Map challenges,
- final AuthState authState,
- final AuthenticationHandler authHandler,
- final HttpResponse response,
- final HttpContext context)
- throws MalformedChallengeException, AuthenticationException {
-
- AuthScheme authScheme = authState.getAuthScheme();
- if (authScheme == null) {
- // Authentication not attempted before
- authScheme = authHandler.selectScheme(challenges, response, context);
- authState.setAuthScheme(authScheme);
- }
- String id = authScheme.getSchemeName();
-
- Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
- if (challenge == null) {
- throw new AuthenticationException(id +
- " authorization challenge expected, but not found");
- }
- authScheme.processChallenge(challenge);
- this.log.debug("Authorization challenge processed");
- }
-
-
- private void updateAuthState(
- final AuthState authState,
- final HttpHost host,
- final CredentialsProvider credsProvider) {
-
- if (!authState.isValid()) {
- return;
- }
-
- String hostname = host.getHostName();
- int port = host.getPort();
- if (port < 0) {
- Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
- port = scheme.getDefaultPort();
- }
-
- AuthScheme authScheme = authState.getAuthScheme();
- AuthScope authScope = new AuthScope(
- hostname,
- port,
- authScheme.getRealm(),
- authScheme.getSchemeName());
-
- if (this.log.isDebugEnabled()) {
- this.log.debug("Authentication scope: " + authScope);
- }
- Credentials creds = authState.getCredentials();
- if (creds == null) {
- creds = credsProvider.getCredentials(authScope);
- if (this.log.isDebugEnabled()) {
- if (creds != null) {
- this.log.debug("Found credentials");
- } else {
- this.log.debug("Credentials not found");
- }
- }
- } else {
- if (authScheme.isComplete()) {
- this.log.debug("Authentication failed");
- creds = null;
- }
- }
- authState.setAuthScope(authScope);
- authState.setCredentials(creds);
- }
-
-} // class DefaultClientRequestDirector
diff --git a/src/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java b/src/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
deleted file mode 100644
index 57945497581b8088923d0620876d405f36208c91..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java $
- * $Revision: 603615 $
- * $Date: 2007-12-12 06:03:21 -0800 (Wed, 12 Dec 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.Map;
-
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * @author Oleg Kalnichevski
- */
-public class DefaultTargetAuthenticationHandler extends AbstractAuthenticationHandler {
-
- public DefaultTargetAuthenticationHandler() {
- super();
- }
-
- public boolean isAuthenticationRequested(
- final HttpResponse response,
- final HttpContext context) {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- int status = response.getStatusLine().getStatusCode();
- return status == HttpStatus.SC_UNAUTHORIZED;
- }
-
- public Map getChallenges(
- final HttpResponse response,
- final HttpContext context) throws MalformedChallengeException {
- if (response == null) {
- throw new IllegalArgumentException("HTTP response may not be null");
- }
- Header[] headers = response.getHeaders(AUTH.WWW_AUTH);
- return parseChallenges(headers);
- }
-
-}
diff --git a/src/org/apache/http/impl/client/DefaultUserTokenHandler.java b/src/org/apache/http/impl/client/DefaultUserTokenHandler.java
deleted file mode 100644
index c8a409f86e055f29d0d3a809e4c18a441eb21a65..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/DefaultUserTokenHandler.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java $
- * $Revision: 659971 $
- * $Date: 2008-05-25 05:01:22 -0700 (Sun, 25 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.security.Principal;
-
-import javax.net.ssl.SSLSession;
-
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.protocol.HttpContext;
-
-public class DefaultUserTokenHandler implements UserTokenHandler {
-
- public Object getUserToken(final HttpContext context) {
-
- Principal userPrincipal = null;
-
- AuthState targetAuthState = (AuthState) context.getAttribute(
- ClientContext.TARGET_AUTH_STATE);
- if (targetAuthState != null) {
- userPrincipal = getAuthPrincipal(targetAuthState);
- if (userPrincipal == null) {
- AuthState proxyAuthState = (AuthState) context.getAttribute(
- ClientContext.PROXY_AUTH_STATE);
- userPrincipal = getAuthPrincipal(proxyAuthState);
- }
- }
-
- if (userPrincipal == null) {
- ManagedClientConnection conn = (ManagedClientConnection) context.getAttribute(
- ExecutionContext.HTTP_CONNECTION);
- if (conn.isOpen()) {
- SSLSession sslsession = conn.getSSLSession();
- if (sslsession != null) {
- userPrincipal = sslsession.getLocalPrincipal();
- }
- }
- }
-
- return userPrincipal;
- }
-
- private static Principal getAuthPrincipal(final AuthState authState) {
- AuthScheme scheme = authState.getAuthScheme();
- if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
- Credentials creds = authState.getCredentials();
- if (creds != null) {
- return creds.getUserPrincipal();
- }
- }
- return null;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/src/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
deleted file mode 100644
index 05098cff12d3c948c1b04a8d0fb56baf0699904e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.protocol.HTTP;
-
-/**
- * A wrapper class for {@link HttpEntityEnclosingRequest}s that can
- * be used to change properties of the current request without
- * modifying the original object.
- *
- * This class is also capable of resetting the request headers to
- * the state of the original request.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 674186 $
- *
- * @since 4.0
- */
-public class EntityEnclosingRequestWrapper extends RequestWrapper
- implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
-
- public EntityEnclosingRequestWrapper(final HttpEntityEnclosingRequest request)
- throws ProtocolException {
- super(request);
- this.entity = request.getEntity();
- }
-
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- public void setEntity(final HttpEntity entity) {
- this.entity = entity;
- }
-
- public boolean expectContinue() {
- Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- @Override
- public boolean isRepeatable() {
- return this.entity == null || this.entity.isRepeatable();
- }
-
-}
diff --git a/src/org/apache/http/impl/client/RedirectLocations.java b/src/org/apache/http/impl/client/RedirectLocations.java
deleted file mode 100644
index d5c47e764ee1ee42277295caf1a55f721cb89f52..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/RedirectLocations.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java $
- * $Revision: 652020 $
- * $Date: 2008-04-27 14:23:31 -0700 (Sun, 27 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A collection of URIs that were used as redirects.
- */
-public class RedirectLocations {
-
- private final Set uris;
-
- public RedirectLocations() {
- super();
- this.uris = new HashSet();
- }
-
- /**
- * Returns true if this collection contains the given URI.
- */
- public boolean contains(final URI uri) {
- return this.uris.contains(uri);
- }
-
- /**
- * Adds a new URI to the list of redirects.
- */
- public void add(final URI uri) {
- this.uris.add(uri);
- }
-
- /**
- * Removes a URI from the list of redirects.
- */
- public boolean remove(final URI uri) {
- return this.uris.remove(uri);
- }
-
-}
diff --git a/src/org/apache/http/impl/client/RequestWrapper.java b/src/org/apache/http/impl/client/RequestWrapper.java
deleted file mode 100644
index 04a641d6aa26153195184ef82efb669a554a3519..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/RequestWrapper.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RequestWrapper.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.message.AbstractHttpMessage;
-import org.apache.http.message.BasicRequestLine;
-import org.apache.http.params.HttpProtocolParams;
-
-/**
- * A wrapper class for {@link HttpRequest}s that can be used to change
- * properties of the current request without modifying the original
- * object.
- *
- * This class is also capable of resetting the request headers to
- * the state of the original request.
- *
- * @author Oleg Kalnichevski
- *
- * @version $Revision: 674186 $
- *
- * @since 4.0
- */
-public class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest {
-
- private final HttpRequest original;
-
- private URI uri;
- private String method;
- private ProtocolVersion version;
- private int execCount;
-
- public RequestWrapper(final HttpRequest request) throws ProtocolException {
- super();
- if (request == null) {
- throw new IllegalArgumentException("HTTP request may not be null");
- }
- this.original = request;
- setParams(request.getParams());
- // Make a copy of the original URI
- if (request instanceof HttpUriRequest) {
- this.uri = ((HttpUriRequest) request).getURI();
- this.method = ((HttpUriRequest) request).getMethod();
- this.version = null;
- } else {
- RequestLine requestLine = request.getRequestLine();
- try {
- this.uri = new URI(requestLine.getUri());
- } catch (URISyntaxException ex) {
- throw new ProtocolException("Invalid request URI: "
- + requestLine.getUri(), ex);
- }
- this.method = requestLine.getMethod();
- this.version = request.getProtocolVersion();
- }
- this.execCount = 0;
- }
-
- public void resetHeaders() {
- // Make a copy of original headers
- this.headergroup.clear();
- setHeaders(this.original.getAllHeaders());
- }
-
- public String getMethod() {
- return this.method;
- }
-
- public void setMethod(final String method) {
- if (method == null) {
- throw new IllegalArgumentException("Method name may not be null");
- }
- this.method = method;
- }
-
- public ProtocolVersion getProtocolVersion() {
- if (this.version != null) {
- return this.version;
- } else {
- return HttpProtocolParams.getVersion(getParams());
- }
- }
-
- public void setProtocolVersion(final ProtocolVersion version) {
- this.version = version;
- }
-
-
- public URI getURI() {
- return this.uri;
- }
-
- public void setURI(final URI uri) {
- this.uri = uri;
- }
-
- public RequestLine getRequestLine() {
- String method = getMethod();
- ProtocolVersion ver = getProtocolVersion();
- String uritext = null;
- if (uri != null) {
- uritext = uri.toASCIIString();
- }
- if (uritext == null || uritext.length() == 0) {
- uritext = "/";
- }
- return new BasicRequestLine(method, uritext, ver);
- }
-
- public void abort() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isAborted() {
- return false;
- }
-
- public HttpRequest getOriginal() {
- return this.original;
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public int getExecCount() {
- return this.execCount;
- }
-
- public void incrementExecCount() {
- this.execCount++;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/RoutedRequest.java b/src/org/apache/http/impl/client/RoutedRequest.java
deleted file mode 100644
index 954ebe5bd71cbe9d136e4e9242ecc6bf9e884249..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/RoutedRequest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RoutedRequest.java $
- * $Revision: 645846 $
- * $Date: 2008-04-08 03:53:39 -0700 (Tue, 08 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.conn.routing.HttpRoute;
-
-
-/**
- * A request with the route along which it should be sent.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 645846 $
- *
- * @since 4.0
- */
-public class RoutedRequest {
-
- protected final RequestWrapper request;
- protected final HttpRoute route;
-
- /**
- * Creates a new routed request.
- *
- * @param req the request
- * @param route the route
- */
- public RoutedRequest(final RequestWrapper req, final HttpRoute route) {
- super();
- this.request = req;
- this.route = route;
- }
-
- public final RequestWrapper getRequest() {
- return request;
- }
-
- public final HttpRoute getRoute() {
- return route;
- }
-
-} // interface RoutedRequest
diff --git a/src/org/apache/http/impl/client/TunnelRefusedException.java b/src/org/apache/http/impl/client/TunnelRefusedException.java
deleted file mode 100644
index 601626fa6a4518043e110e238f4b94ed5184a8bc..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/TunnelRefusedException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/TunnelRefusedException.java $
- * $Revision: 537650 $
- * $Date: 2007-05-13 12:58:22 -0700 (Sun, 13 May 2007) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-
-public class TunnelRefusedException extends HttpException {
-
- private static final long serialVersionUID = -8646722842745617323L;
-
- private final HttpResponse response;
-
- public TunnelRefusedException(final String message, final HttpResponse response) {
- super(message);
- this.response = response;
- }
-
- public HttpResponse getResponse() {
- return this.response;
- }
-
-}
diff --git a/src/org/apache/http/impl/client/package.html b/src/org/apache/http/impl/client/package.html
deleted file mode 100644
index e301283df7104685ade8ae0e8887fb7917b4d61f..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/client/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/org/apache/http/impl/conn/AbstractClientConnAdapter.java b/src/org/apache/http/impl/conn/AbstractClientConnAdapter.java
deleted file mode 100644
index 5cbe0104fc762269bc4b7af0e889e37a083bf5ed..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/AbstractClientConnAdapter.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java $
- * $Revision: 672969 $
- * $Date: 2008-06-30 18:09:50 -0700 (Mon, 30 Jun 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSession;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.ClientConnectionManager;
-
-
-/**
- * Abstract adapter from {@link OperatedClientConnection operated} to
- * {@link ManagedClientConnection managed} client connections.
- * Read and write methods are delegated to the wrapped connection.
- * Operations affecting the connection state have to be implemented
- * by derived classes. Operations for querying the connection state
- * are delegated to the wrapped connection if there is one, or
- * return a default value if there is none.
- *
- * This adapter tracks the checkpoints for reusable communication states,
- * as indicated by {@link #markReusable markReusable} and queried by
- * {@link #isMarkedReusable isMarkedReusable}.
- * All send and receive operations will automatically clear the mark.
- *
- * Connection release calls are delegated to the connection manager,
- * if there is one. {@link #abortConnection abortConnection} will
- * clear the reusability mark first. The connection manager is
- * expected to tolerate multiple calls to the release method.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 672969 $ $Date: 2008-06-30 18:09:50 -0700 (Mon, 30 Jun 2008) $
- *
- * @since 4.0
- */
-public abstract class AbstractClientConnAdapter
- implements ManagedClientConnection {
-
- /** Thread that requested this connection. */
- private final Thread executionThread;
-
- /**
- * The connection manager, if any.
- * This attribute MUST NOT be final, so the adapter can be detached
- * from the connection manager without keeping a hard reference there.
- */
- private volatile ClientConnectionManager connManager;
-
- /** The wrapped connection. */
- private volatile OperatedClientConnection wrappedConnection;
-
- /** The reusability marker. */
- private volatile boolean markedReusable;
-
- /** True if the connection has been aborted. */
- private volatile boolean aborted;
-
- /** The duration this is valid for while idle (in ms). */
- private volatile long duration;
-
- /**
- * Creates a new connection adapter.
- * The adapter is initially not
- * {@link #isMarkedReusable marked} as reusable.
- *
- * @param mgr the connection manager, or null
- * @param conn the connection to wrap, or null
- */
- protected AbstractClientConnAdapter(ClientConnectionManager mgr,
- OperatedClientConnection conn) {
- super();
- executionThread = Thread.currentThread();
- connManager = mgr;
- wrappedConnection = conn;
- markedReusable = false;
- aborted = false;
- duration = Long.MAX_VALUE;
- } //
-
-
- /**
- * Detaches this adapter from the wrapped connection.
- * This adapter becomes useless.
- */
- protected void detach() {
- wrappedConnection = null;
- connManager = null; // base class attribute
- duration = Long.MAX_VALUE;
- }
-
- protected OperatedClientConnection getWrappedConnection() {
- return wrappedConnection;
- }
-
- protected ClientConnectionManager getManager() {
- return connManager;
- }
-
- /**
- * Asserts that the connection has not been aborted.
- *
- * @throws InterruptedIOException if the connection has been aborted
- */
- protected final void assertNotAborted() throws InterruptedIOException {
- if (aborted) {
- throw new InterruptedIOException("Connection has been shut down.");
- }
- }
-
- /**
- * Asserts that there is a wrapped connection to delegate to.
- *
- * @throws IllegalStateException if there is no wrapped connection
- * or connection has been aborted
- */
- protected final void assertValid(
- final OperatedClientConnection wrappedConn) {
- if (wrappedConn == null) {
- throw new IllegalStateException("No wrapped connection.");
- }
- }
-
- // non-javadoc, see interface HttpConnection
- public boolean isOpen() {
- OperatedClientConnection conn = getWrappedConnection();
- if (conn == null)
- return false;
-
- return conn.isOpen();
- }
-
-
- // non-javadoc, see interface HttpConnection
- public boolean isStale() {
- if (aborted)
- return true;
- OperatedClientConnection conn = getWrappedConnection();
- if (conn == null)
- return true;
-
- return conn.isStale();
- }
-
-
- // non-javadoc, see interface HttpConnection
- public void setSocketTimeout(int timeout) {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- conn.setSocketTimeout(timeout);
- }
-
-
- // non-javadoc, see interface HttpConnection
- public int getSocketTimeout() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getSocketTimeout();
- }
-
-
- // non-javadoc, see interface HttpConnection
- public HttpConnectionMetrics getMetrics() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getMetrics();
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public void flush()
- throws IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- conn.flush();
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public boolean isResponseAvailable(int timeout)
- throws IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- return conn.isResponseAvailable(timeout);
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public void receiveResponseEntity(HttpResponse response)
- throws HttpException, IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- unmarkReusable();
- conn.receiveResponseEntity(response);
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public HttpResponse receiveResponseHeader()
- throws HttpException, IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- unmarkReusable();
- return conn.receiveResponseHeader();
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public void sendRequestEntity(HttpEntityEnclosingRequest request)
- throws HttpException, IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- unmarkReusable();
- conn.sendRequestEntity(request);
- }
-
-
- // non-javadoc, see interface HttpClientConnection
- public void sendRequestHeader(HttpRequest request)
- throws HttpException, IOException {
-
- assertNotAborted();
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
-
- unmarkReusable();
- conn.sendRequestHeader(request);
- }
-
-
- // non-javadoc, see interface HttpInetConnection
- public InetAddress getLocalAddress() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getLocalAddress();
- }
-
- // non-javadoc, see interface HttpInetConnection
- public int getLocalPort() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getLocalPort();
- }
-
-
- // non-javadoc, see interface HttpInetConnection
- public InetAddress getRemoteAddress() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getRemoteAddress();
- }
-
- // non-javadoc, see interface HttpInetConnection
- public int getRemotePort() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.getRemotePort();
- }
-
- // non-javadoc, see interface ManagedClientConnection
- public boolean isSecure() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- return conn.isSecure();
- }
-
- // non-javadoc, see interface ManagedClientConnection
- public SSLSession getSSLSession() {
- OperatedClientConnection conn = getWrappedConnection();
- assertValid(conn);
- if (!isOpen())
- return null;
-
- SSLSession result = null;
- Socket sock = conn.getSocket();
- if (sock instanceof SSLSocket) {
- result = ((SSLSocket)sock).getSession();
- }
- return result;
- }
-
- // non-javadoc, see interface ManagedClientConnection
- public void markReusable() {
- markedReusable = true;
- }
-
- // non-javadoc, see interface ManagedClientConnection
- public void unmarkReusable() {
- markedReusable = false;
- }
-
- // non-javadoc, see interface ManagedClientConnection
- public boolean isMarkedReusable() {
- return markedReusable;
- }
-
- public void setIdleDuration(long duration, TimeUnit unit) {
- if(duration > 0) {
- this.duration = unit.toMillis(duration);
- } else {
- this.duration = -1;
- }
- }
-
- // non-javadoc, see interface ConnectionReleaseTrigger
- public void releaseConnection() {
- if (connManager != null) {
- connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
- }
- }
-
- // non-javadoc, see interface ConnectionReleaseTrigger
- public void abortConnection() {
- if (aborted) {
- return;
- }
- aborted = true;
- unmarkReusable();
- try {
- shutdown();
- } catch (IOException ignore) {
- }
- // Usually #abortConnection() is expected to be called from
- // a helper thread in order to unblock the main execution thread
- // blocked in an I/O operation. It may be unsafe to call
- // #releaseConnection() from the helper thread, so we have to rely
- // on an IOException thrown by the closed socket on the main thread
- // to trigger the release of the connection back to the
- // connection manager.
- //
- // However, if this method is called from the main execution thread
- // it should be safe to release the connection immediately. Besides,
- // this also helps ensure the connection gets released back to the
- // manager if #abortConnection() is called from the main execution
- // thread while there is no blocking I/O operation.
- if (executionThread.equals(Thread.currentThread())) {
- releaseConnection();
- }
- }
-
-} // class AbstractClientConnAdapter
diff --git a/src/org/apache/http/impl/conn/AbstractPoolEntry.java b/src/org/apache/http/impl/conn/AbstractPoolEntry.java
deleted file mode 100644
index 0e7d95fb9293a24e9ea1b20c763ed6ea4b340c79..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/AbstractPoolEntry.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java $
- * $Revision: 658775 $
- * $Date: 2008-05-21 10:30:45 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.io.IOException;
-
-import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.RouteTracker;
-import org.apache.http.conn.ClientConnectionOperator;
-import org.apache.http.conn.OperatedClientConnection;
-
-
-
-/**
- * A pool entry for use by connection manager implementations.
- * Pool entries work in conjunction with an
- * {@link AbstractClientConnAdapter adapter}.
- * The adapter is handed out to applications that obtain a connection.
- * The pool entry stores the underlying connection and tracks the
- * {@link HttpRoute route} established.
- * The adapter delegates methods for establishing the route to
- * it's pool entry.
- *
- * If the managed connections is released or revoked, the adapter
- * gets disconnected, but the pool entry still contains the
- * underlying connection and the established route.
- *
- * @author Roland Weber
- * @author Michael Becke
- *
- *
- *
- * @version $Revision: 658775 $
- *
- * @since 4.0
- */
-public abstract class AbstractPoolEntry {
-
- /** The connection operator. */
- protected final ClientConnectionOperator connOperator;
-
- /** The underlying connection being pooled or used. */
- protected final OperatedClientConnection connection;
-
- /** The route for which this entry gets allocated. */
- //@@@ currently accessed from connection manager(s) as attribute
- //@@@ avoid that, derived classes should decide whether update is allowed
- //@@@ SCCM: yes, TSCCM: no
- protected volatile HttpRoute route;
-
- /** Connection state object */
- protected volatile Object state;
-
- /** The tracked route, or null before tracking starts. */
- protected volatile RouteTracker tracker;
-
-
- /**
- * Creates a new pool entry.
- *
- * @param connOperator the Connection Operator for this entry
- * @param route the planned route for the connection,
- * or null
- */
- protected AbstractPoolEntry(ClientConnectionOperator connOperator,
- HttpRoute route) {
- super();
- if (connOperator == null) {
- throw new IllegalArgumentException("Connection operator may not be null");
- }
- this.connOperator = connOperator;
- this.connection = connOperator.createConnection();
- this.route = route;
- this.tracker = null;
- }
-
- /**
- * Returns the state object associated with this pool entry.
- *
- * @return The state object
- */
- public Object getState() {
- return state;
- }
-
- /**
- * Assigns a state object to this pool entry.
- *
- * @param state The state object
- */
- public void setState(final Object state) {
- this.state = state;
- }
-
- /**
- * Opens the underlying connection.
- *
- * @param route the route along which to open the connection
- * @param context the context for opening the connection
- * @param params the parameters for opening the connection
- *
- * @throws IOException in case of a problem
- */
- public void open(HttpRoute route,
- HttpContext context, HttpParams params)
- throws IOException {
-
- if (route == null) {
- throw new IllegalArgumentException
- ("Route must not be null.");
- }
- //@@@ is context allowed to be null? depends on operator?
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
- if ((this.tracker != null) && this.tracker.isConnected()) {
- throw new IllegalStateException("Connection already open.");
- }
-
- // - collect the arguments
- // - call the operator
- // - update the tracking data
- // In this order, we can be sure that only a successful
- // opening of the connection will be tracked.
-
- //@@@ verify route against planned route?
-
- this.tracker = new RouteTracker(route);
- final HttpHost proxy = route.getProxyHost();
-
- connOperator.openConnection
- (this.connection,
- (proxy != null) ? proxy : route.getTargetHost(),
- route.getLocalAddress(),
- context, params);
-
- RouteTracker localTracker = tracker; // capture volatile
-
- // If this tracker was reset while connecting,
- // fail early.
- if (localTracker == null) {
- throw new IOException("Request aborted");
- }
-
- if (proxy == null) {
- localTracker.connectTarget(this.connection.isSecure());
- } else {
- localTracker.connectProxy(proxy, this.connection.isSecure());
- }
-
- } // open
-
-
- /**
- * Tracks tunnelling of the connection to the target.
- * The tunnel has to be established outside by sending a CONNECT
- * request to the (last) proxy.
- *
- * @param secure true if the tunnel should be
- * considered secure, false otherwise
- * @param params the parameters for tunnelling the connection
- *
- * @throws IOException in case of a problem
- */
- public void tunnelTarget(boolean secure, HttpParams params)
- throws IOException {
-
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
-
- //@@@ check for proxy in planned route?
- if ((this.tracker == null) || !this.tracker.isConnected()) {
- throw new IllegalStateException("Connection not open.");
- }
- if (this.tracker.isTunnelled()) {
- throw new IllegalStateException
- ("Connection is already tunnelled.");
- }
-
- // LOG.debug?
-
- this.connection.update(null, tracker.getTargetHost(),
- secure, params);
- this.tracker.tunnelTarget(secure);
-
- } // tunnelTarget
-
-
- /**
- * Tracks tunnelling of the connection to a chained proxy.
- * The tunnel has to be established outside by sending a CONNECT
- * request to the previous proxy.
- *
- * @param next the proxy to which the tunnel was established.
- * See {@link org.apache.http.conn.ManagedClientConnection#tunnelProxy
- * ManagedClientConnection.tunnelProxy}
- * for details.
- * @param secure true if the tunnel should be
- * considered secure, false otherwise
- * @param params the parameters for tunnelling the connection
- *
- * @throws IOException in case of a problem
- */
- public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
- throws IOException {
-
- if (next == null) {
- throw new IllegalArgumentException
- ("Next proxy must not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
-
- //@@@ check for proxy in planned route?
- if ((this.tracker == null) || !this.tracker.isConnected()) {
- throw new IllegalStateException("Connection not open.");
- }
-
- // LOG.debug?
-
- this.connection.update(null, next, secure, params);
- this.tracker.tunnelProxy(next, secure);
-
- } // tunnelProxy
-
-
- /**
- * Layers a protocol on top of an established tunnel.
- *
- * @param context the context for layering
- * @param params the parameters for layering
- *
- * @throws IOException in case of a problem
- */
- public void layerProtocol(HttpContext context, HttpParams params)
- throws IOException {
-
- //@@@ is context allowed to be null? depends on operator?
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
-
- if ((this.tracker == null) || !this.tracker.isConnected()) {
- throw new IllegalStateException("Connection not open.");
- }
- if (!this.tracker.isTunnelled()) {
- //@@@ allow this?
- throw new IllegalStateException
- ("Protocol layering without a tunnel not supported.");
- }
- if (this.tracker.isLayered()) {
- throw new IllegalStateException
- ("Multiple protocol layering not supported.");
- }
-
- // - collect the arguments
- // - call the operator
- // - update the tracking data
- // In this order, we can be sure that only a successful
- // layering on top of the connection will be tracked.
-
- final HttpHost target = tracker.getTargetHost();
-
- connOperator.updateSecureConnection(this.connection, target,
- context, params);
-
- this.tracker.layerProtocol(this.connection.isSecure());
-
- } // layerProtocol
-
-
- /**
- * Shuts down the entry.
- *
- * If {@link #open(HttpRoute, HttpContext, HttpParams)} is in progress,
- * this will cause that open to possibly throw an {@link IOException}.
- */
- protected void shutdownEntry() {
- tracker = null;
- }
-
-
-} // class AbstractPoolEntry
-
diff --git a/src/org/apache/http/impl/conn/AbstractPooledConnAdapter.java b/src/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
deleted file mode 100644
index 2c5fd30a9e4f27465ec6348868049431d35e8269..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java $
- * $Revision: 658775 $
- * $Date: 2008-05-21 10:30:45 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.io.IOException;
-
-import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.OperatedClientConnection;
-
-
-
-/**
- * Abstract adapter from pool {@link AbstractPoolEntry entries} to
- * {@link org.apache.http.conn.ManagedClientConnection managed}
- * client connections.
- * The connection in the pool entry is used to initialize the base class.
- * In addition, methods to establish a route are delegated to the
- * pool entry. {@link #shutdown shutdown} and {@link #close close}
- * will clear the tracked route in the pool entry and call the
- * respective method of the wrapped connection.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 658775 $ $Date: 2008-05-21 10:30:45 -0700 (Wed, 21 May 2008) $
- *
- * @since 4.0
- */
-public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapter {
-
- /** The wrapped pool entry. */
- protected volatile AbstractPoolEntry poolEntry;
-
-
- /**
- * Creates a new connection adapter.
- *
- * @param manager the connection manager
- * @param entry the pool entry for the connection being wrapped
- */
- protected AbstractPooledConnAdapter(ClientConnectionManager manager,
- AbstractPoolEntry entry) {
- super(manager, entry.connection);
- this.poolEntry = entry;
- }
-
-
- /**
- * Asserts that this adapter is still attached.
- *
- * @throws IllegalStateException
- * if it is {@link #detach detach}ed
- */
- protected final void assertAttached() {
- if (poolEntry == null) {
- throw new IllegalStateException("Adapter is detached.");
- }
- }
-
- /**
- * Detaches this adapter from the wrapped connection.
- * This adapter becomes useless.
- */
- @Override
- protected void detach() {
- super.detach();
- poolEntry = null;
- }
-
-
- // non-javadoc, see interface ManagedHttpConnection
- public HttpRoute getRoute() {
-
- assertAttached();
- return (poolEntry.tracker == null) ?
- null : poolEntry.tracker.toRoute();
- }
-
- // non-javadoc, see interface ManagedHttpConnection
- public void open(HttpRoute route,
- HttpContext context, HttpParams params)
- throws IOException {
-
- assertAttached();
- poolEntry.open(route, context, params);
- }
-
-
- // non-javadoc, see interface ManagedHttpConnection
- public void tunnelTarget(boolean secure, HttpParams params)
- throws IOException {
-
- assertAttached();
- poolEntry.tunnelTarget(secure, params);
- }
-
-
- // non-javadoc, see interface ManagedHttpConnection
- public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
- throws IOException {
-
- assertAttached();
- poolEntry.tunnelProxy(next, secure, params);
- }
-
-
- // non-javadoc, see interface ManagedHttpConnection
- public void layerProtocol(HttpContext context, HttpParams params)
- throws IOException {
-
- assertAttached();
- poolEntry.layerProtocol(context, params);
- }
-
-
-
- // non-javadoc, see interface HttpConnection
- public void close() throws IOException {
- if (poolEntry != null)
- poolEntry.shutdownEntry();
-
- OperatedClientConnection conn = getWrappedConnection();
- if (conn != null) {
- conn.close();
- }
- }
-
- // non-javadoc, see interface HttpConnection
- public void shutdown() throws IOException {
- if (poolEntry != null)
- poolEntry.shutdownEntry();
-
- OperatedClientConnection conn = getWrappedConnection();
- if (conn != null) {
- conn.shutdown();
- }
- }
-
-
- // non-javadoc, see interface ManagedClientConnection
- public Object getState() {
- assertAttached();
- return poolEntry.getState();
- }
-
-
- // non-javadoc, see interface ManagedClientConnection
- public void setState(final Object state) {
- assertAttached();
- poolEntry.setState(state);
- }
-
-
-} // class AbstractPooledConnAdapter
diff --git a/src/org/apache/http/impl/conn/DefaultClientConnection.java b/src/org/apache/http/impl/conn/DefaultClientConnection.java
deleted file mode 100644
index a41f57af46c09a83fe910268576c08872a3d5862..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/DefaultClientConnection.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.params.HttpParams;
-import org.apache.http.impl.SocketHttpClientConnection;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-
-import org.apache.http.conn.OperatedClientConnection;
-
-
-/**
- * Default implementation of an operated client connection.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 673450 $ $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * @since 4.0
- */
-public class DefaultClientConnection extends SocketHttpClientConnection
- implements OperatedClientConnection {
-
- private final Log log = LogFactory.getLog(getClass());
- private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
- private final Log wireLog = LogFactory.getLog("org.apache.http.wire");
-
- /** The unconnected socket */
- private volatile Socket socket;
-
- /** The target host of this connection. */
- private HttpHost targetHost;
-
- /** Whether this connection is secure. */
- private boolean connSecure;
-
- /** True if this connection was shutdown. */
- private volatile boolean shutdown;
-
- public DefaultClientConnection() {
- super();
- }
-
-
- // non-javadoc, see interface OperatedClientConnection
- public final HttpHost getTargetHost() {
- return this.targetHost;
- }
-
-
- // non-javadoc, see interface OperatedClientConnection
- public final boolean isSecure() {
- return this.connSecure;
- }
-
-
- @Override
- public final Socket getSocket() {
- return this.socket;
- }
-
-
- public void opening(Socket sock, HttpHost target) throws IOException {
- assertNotOpen();
- this.socket = sock;
- this.targetHost = target;
-
- // Check for shutdown after assigning socket, so that
- if (this.shutdown) {
- sock.close(); // allow this to throw...
- // ...but if it doesn't, explicitly throw one ourselves.
- throw new IOException("Connection already shutdown");
- }
- }
-
-
- public void openCompleted(boolean secure, HttpParams params) throws IOException {
- assertNotOpen();
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
- this.connSecure = secure;
- bind(this.socket, params);
- }
-
- /**
- * Force-closes this connection.
- * If the connection is still in the process of being open (the method
- * {@link #opening opening} was already called but
- * {@link #openCompleted openCompleted} was not), the associated
- * socket that is being connected to a remote address will be closed.
- * That will interrupt a thread that is blocked on connecting
- * the socket.
- * If the connection is not yet open, this will prevent the connection
- * from being opened.
- *
- * @throws IOException in case of a problem
- */
- @Override
- public void shutdown() throws IOException {
- log.debug("Connection shut down");
- shutdown = true;
-
- super.shutdown();
- Socket sock = this.socket; // copy volatile attribute
- if (sock != null)
- sock.close();
-
- } // shutdown
-
-
- @Override
- public void close() throws IOException {
- log.debug("Connection closed");
- super.close();
- }
-
-
- @Override
- protected SessionInputBuffer createSessionInputBuffer(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- SessionInputBuffer inbuffer = super.createSessionInputBuffer(
- socket,
- buffersize,
- params);
- if (wireLog.isDebugEnabled()) {
- inbuffer = new LoggingSessionInputBuffer(inbuffer, new Wire(wireLog));
- }
- return inbuffer;
- }
-
-
- @Override
- protected SessionOutputBuffer createSessionOutputBuffer(
- final Socket socket,
- int buffersize,
- final HttpParams params) throws IOException {
- SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
- socket,
- buffersize,
- params);
- if (wireLog.isDebugEnabled()) {
- outbuffer = new LoggingSessionOutputBuffer(outbuffer, new Wire(wireLog));
- }
- return outbuffer;
- }
-
-
- @Override
- protected HttpMessageParser createResponseParser(
- final SessionInputBuffer buffer,
- final HttpResponseFactory responseFactory,
- final HttpParams params) {
- // override in derived class to specify a line parser
- return new DefaultResponseParser
- (buffer, null, responseFactory, params);
- }
-
-
- // non-javadoc, see interface OperatedClientConnection
- public void update(Socket sock, HttpHost target,
- boolean secure, HttpParams params)
- throws IOException {
-
- assertOpen();
- if (target == null) {
- throw new IllegalArgumentException
- ("Target host must not be null.");
- }
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
-
- if (sock != null) {
- this.socket = sock;
- bind(sock, params);
- }
- targetHost = target;
- connSecure = secure;
-
- } // update
-
-
- @Override
- public HttpResponse receiveResponseHeader() throws HttpException, IOException {
- HttpResponse response = super.receiveResponseHeader();
- if (headerLog.isDebugEnabled()) {
- headerLog.debug("<< " + response.getStatusLine().toString());
- Header[] headers = response.getAllHeaders();
- for (Header header : headers) {
- headerLog.debug("<< " + header.toString());
- }
- }
- return response;
- }
-
-
- @Override
- public void sendRequestHeader(HttpRequest request) throws HttpException, IOException {
- super.sendRequestHeader(request);
- if (headerLog.isDebugEnabled()) {
- headerLog.debug(">> " + request.getRequestLine().toString());
- Header[] headers = request.getAllHeaders();
- for (Header header : headers) {
- headerLog.debug(">> " + header.toString());
- }
- }
- }
-
-} // class DefaultClientConnection
diff --git a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java b/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
deleted file mode 100644
index 41488e1139ceb801ba0797f54b07f89f483a2b53..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionOperator.java $
- * $Revision: 652193 $
- * $Date: 2008-04-29 17:10:36 -0700 (Tue, 29 Apr 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.Socket;
-import java.net.InetAddress;
-
-import org.apache.http.HttpHost;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.protocol.HttpContext;
-
-import org.apache.http.conn.HttpHostConnectException;
-import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.ClientConnectionOperator;
-import org.apache.http.conn.scheme.LayeredSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.scheme.SocketFactory;
-
-
-/**
- * Default implementation of a
- * {@link ClientConnectionOperator ClientConnectionOperator}.
- * It uses a {@link SchemeRegistry SchemeRegistry} to look up
- * {@link SocketFactory SocketFactory} objects.
- *
- * @author Roland Weber
- *
- *
- *
- * @version $Revision: 652193 $ $Date: 2008-04-29 17:10:36 -0700 (Tue, 29 Apr 2008) $
- *
- * @since 4.0
- */
-public class DefaultClientConnectionOperator
- implements ClientConnectionOperator {
-
-
- /** The scheme registry for looking up socket factories. */
- protected SchemeRegistry schemeRegistry;
-
-
- /**
- * Creates a new client connection operator for the given scheme registry.
- *
- * @param schemes the scheme registry
- */
- public DefaultClientConnectionOperator(SchemeRegistry schemes) {
- if (schemes == null) {
- throw new IllegalArgumentException
- ("Scheme registry must not be null.");
- }
- schemeRegistry = schemes;
- }
-
-
- // non-javadoc, see interface ClientConnectionOperator
- public OperatedClientConnection createConnection() {
- return new DefaultClientConnection();
- }
-
-
- // non-javadoc, see interface ClientConnectionOperator
- public void openConnection(OperatedClientConnection conn,
- HttpHost target,
- InetAddress local,
- HttpContext context,
- HttpParams params)
- throws IOException {
-
- if (conn == null) {
- throw new IllegalArgumentException
- ("Connection must not be null.");
- }
- if (target == null) {
- throw new IllegalArgumentException
- ("Target host must not be null.");
- }
- // local address may be null
- //@@@ is context allowed to be null?
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
- if (conn.isOpen()) {
- throw new IllegalArgumentException
- ("Connection must not be open.");
- }
-
- final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
- final SocketFactory sf = schm.getSocketFactory();
-
- Socket sock = sf.createSocket();
- conn.opening(sock, target);
-
- try {
- sock = sf.connectSocket(sock, target.getHostName(),
- schm.resolvePort(target.getPort()),
- local, 0, params);
- } catch (ConnectException ex) {
- throw new HttpHostConnectException(target, ex);
- }
- prepareSocket(sock, context, params);
- conn.openCompleted(sf.isSecure(sock), params);
- } // openConnection
-
-
- // non-javadoc, see interface ClientConnectionOperator
- public void updateSecureConnection(OperatedClientConnection conn,
- HttpHost target,
- HttpContext context,
- HttpParams params)
- throws IOException {
-
-
- if (conn == null) {
- throw new IllegalArgumentException
- ("Connection must not be null.");
- }
- if (target == null) {
- throw new IllegalArgumentException
- ("Target host must not be null.");
- }
- //@@@ is context allowed to be null?
- if (params == null) {
- throw new IllegalArgumentException
- ("Parameters must not be null.");
- }
- if (!conn.isOpen()) {
- throw new IllegalArgumentException
- ("Connection must be open.");
- }
-
- final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
- if (!(schm.getSocketFactory() instanceof LayeredSocketFactory)) {
- throw new IllegalArgumentException
- ("Target scheme (" + schm.getName() +
- ") must have layered socket factory.");
- }
-
- final LayeredSocketFactory lsf = (LayeredSocketFactory) schm.getSocketFactory();
- final Socket sock;
- try {
- sock = lsf.createSocket
- (conn.getSocket(), target.getHostName(), target.getPort(), true);
- } catch (ConnectException ex) {
- throw new HttpHostConnectException(target, ex);
- }
- prepareSocket(sock, context, params);
- conn.update(sock, target, lsf.isSecure(sock), params);
- //@@@ error handling: close the layered socket in case of exception?
-
- } // updateSecureConnection
-
-
- /**
- * Performs standard initializations on a newly created socket.
- *
- * @param sock the socket to prepare
- * @param context the context for the connection
- * @param params the parameters from which to prepare the socket
- *
- * @throws IOException in case of an IO problem
- */
- protected void prepareSocket(Socket sock, HttpContext context,
- HttpParams params)
- throws IOException {
-
- // context currently not used, but derived classes may need it
- //@@@ is context allowed to be null?
-
- sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
- sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
-
- int linger = HttpConnectionParams.getLinger(params);
- if (linger >= 0) {
- sock.setSoLinger(linger > 0, linger);
- }
-
- } // prepareSocket
-
-
-} // class DefaultClientConnectionOperator
-
diff --git a/src/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java b/src/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
deleted file mode 100644
index 90fd55f42d8f7f01bb2ef95840ad11dd792e9396..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java $
- * $Revision: 658785 $
- * $Date: 2008-05-21 10:47:40 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.net.InetAddress;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
-
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-
-import org.apache.http.conn.params.ConnRouteParams;
-
-
-/**
- * Default implementation of an {@link HttpRoutePlanner}.
- * This implementation is based on
- * {@link org.apache.http.conn.params.ConnRoutePNames parameters}.
- * It will not make use of any Java system properties,
- * nor of system or browser proxy settings.
- */
-public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
-
- /** The scheme registry. */
- protected SchemeRegistry schemeRegistry;
-
-
- /**
- * Creates a new default route planner.
- *
- * @param schreg the scheme registry
- */
- public DefaultHttpRoutePlanner(SchemeRegistry schreg) {
- if (schreg == null) {
- throw new IllegalArgumentException
- ("SchemeRegistry must not be null.");
- }
- schemeRegistry = schreg;
- }
-
-
- // non-javadoc, see interface HttpRoutePlanner
- public HttpRoute determineRoute(HttpHost target,
- HttpRequest request,
- HttpContext context)
- throws HttpException {
-
- if (request == null) {
- throw new IllegalStateException
- ("Request must not be null.");
- }
-
- // If we have a forced route, we can do without a target.
- HttpRoute route =
- ConnRouteParams.getForcedRoute(request.getParams());
- if (route != null)
- return route;
-
- // If we get here, there is no forced route.
- // So we need a target to compute a route.
-
- if (target == null) {
- throw new IllegalStateException
- ("Target host must not be null.");
- }
-
- final InetAddress local =
- ConnRouteParams.getLocalAddress(request.getParams());
- final HttpHost proxy =
- ConnRouteParams.getDefaultProxy(request.getParams());
-
- final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
- // as it is typically used for TLS/SSL, we assume that
- // a layered scheme implies a secure connection
- final boolean secure = schm.isLayered();
-
- if (proxy == null) {
- route = new HttpRoute(target, local, secure);
- } else {
- route = new HttpRoute(target, local, proxy, secure);
- }
- return route;
- }
-
-
-}
diff --git a/src/org/apache/http/impl/conn/DefaultResponseParser.java b/src/org/apache/http/impl/conn/DefaultResponseParser.java
deleted file mode 100644
index f817a10ea49bf423c799a6e0a451394ba8433a33..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/DefaultResponseParser.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java $
- * $Revision: 617638 $
- * $Date: 2008-02-01 12:49:26 -0800 (Fri, 01 Feb 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpMessage;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.ProtocolException;
-import org.apache.http.StatusLine;
-import org.apache.http.conn.params.ConnConnectionPNames;
-import org.apache.http.impl.io.AbstractMessageParser;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.message.LineParser;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.params.HttpParams;
-import org.apache.http.util.CharArrayBuffer;
-
-public class DefaultResponseParser extends AbstractMessageParser {
-
- private final HttpResponseFactory responseFactory;
- private final CharArrayBuffer lineBuf;
- private final int maxGarbageLines;
-
- public DefaultResponseParser(
- final SessionInputBuffer buffer,
- final LineParser parser,
- final HttpResponseFactory responseFactory,
- final HttpParams params) {
- super(buffer, parser, params);
- if (responseFactory == null) {
- throw new IllegalArgumentException
- ("Response factory may not be null");
- }
- this.responseFactory = responseFactory;
- this.lineBuf = new CharArrayBuffer(128);
- this.maxGarbageLines = params.getIntParameter(
- ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.MAX_VALUE);
- }
-
-
- @Override
- protected HttpMessage parseHead(
- final SessionInputBuffer sessionBuffer) throws IOException, HttpException {
- // clear the buffer
- this.lineBuf.clear();
- //read out the HTTP status string
- int count = 0;
- ParserCursor cursor = null;
- do {
- int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1 && count == 0) {
- // The server just dropped connection on us
- throw new NoHttpResponseException("The target server failed to respond");
- }
- cursor = new ParserCursor(0, this.lineBuf.length());
- if (lineParser.hasProtocolVersion(this.lineBuf, cursor)) {
- // Got one
- break;
- } else if (i == -1 || count >= this.maxGarbageLines) {
- // Giving up
- throw new ProtocolException("The server failed to respond with a " +
- "valid HTTP response");
- }
- count++;
- } while(true);
- //create the status line from the status string
- StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
- return this.responseFactory.newHttpResponse(statusline, null);
- }
-
-}
diff --git a/src/org/apache/http/impl/conn/IdleConnectionHandler.java b/src/org/apache/http/impl/conn/IdleConnectionHandler.java
deleted file mode 100644
index 2cacda3853791b4e04286fcd1e8d2e9d4284664e..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/IdleConnectionHandler.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpConnection;
-
-
-/**
- * A helper class for connection managers to track idle connections.
- *
- * This class is not synchronized.
- *
- * @see org.apache.http.conn.ClientConnectionManager#closeIdleConnections
- *
- * @since 4.0
- */
-public class IdleConnectionHandler {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /** Holds connections and the time they were added. */
- private final Map connectionToTimes;
-
-
- public IdleConnectionHandler() {
- super();
- connectionToTimes = new HashMap();
- }
-
- /**
- * Registers the given connection with this handler. The connection will be held until
- * {@link #remove} or {@link #closeIdleConnections} is called.
- *
- * @param connection the connection to add
- *
- * @see #remove
- */
- public void add(HttpConnection connection, long validDuration, TimeUnit unit) {
-
- Long timeAdded = Long.valueOf(System.currentTimeMillis());
-
- if (log.isDebugEnabled()) {
- log.debug("Adding connection at: " + timeAdded);
- }
-
- connectionToTimes.put(connection, new TimeValues(timeAdded, validDuration, unit));
- }
-
- /**
- * Removes the given connection from the list of connections to be closed when idle.
- * This will return true if the connection is still valid, and false
- * if the connection should be considered expired and not used.
- *
- * @param connection
- * @return True if the connection is still valid.
- */
- public boolean remove(HttpConnection connection) {
- TimeValues times = connectionToTimes.remove(connection);
- if(times == null) {
- log.warn("Removing a connection that never existed!");
- return true;
- } else {
- return System.currentTimeMillis() <= times.timeExpires;
- }
- }
-
- /**
- * Removes all connections referenced by this handler.
- */
- public void removeAll() {
- this.connectionToTimes.clear();
- }
-
- /**
- * Closes connections that have been idle for at least the given amount of time.
- *
- * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
- */
- //@@@ add TimeUnit argument here?
- public void closeIdleConnections(long idleTime) {
-
- // the latest time for which connections will be closed
- long idleTimeout = System.currentTimeMillis() - idleTime;
-
- if (log.isDebugEnabled()) {
- log.debug("Checking for connections, idleTimeout: " + idleTimeout);
- }
-
- Iterator connectionIter =
- connectionToTimes.keySet().iterator();
-
- while (connectionIter.hasNext()) {
- HttpConnection conn = connectionIter.next();
- TimeValues times = connectionToTimes.get(conn);
- Long connectionTime = times.timeAdded;
- if (connectionTime.longValue() <= idleTimeout) {
- if (log.isDebugEnabled()) {
- log.debug("Closing connection, connection time: " + connectionTime);
- }
- connectionIter.remove();
- try {
- conn.close();
- } catch (IOException ex) {
- log.debug("I/O error closing connection", ex);
- }
- }
- }
- }
-
-
- public void closeExpiredConnections() {
- long now = System.currentTimeMillis();
- if (log.isDebugEnabled()) {
- log.debug("Checking for expired connections, now: " + now);
- }
-
- Iterator connectionIter =
- connectionToTimes.keySet().iterator();
-
- while (connectionIter.hasNext()) {
- HttpConnection conn = connectionIter.next();
- TimeValues times = connectionToTimes.get(conn);
- if(times.timeExpires <= now) {
- if (log.isDebugEnabled()) {
- log.debug("Closing connection, expired @: " + times.timeExpires);
- }
- connectionIter.remove();
- try {
- conn.close();
- } catch (IOException ex) {
- log.debug("I/O error closing connection", ex);
- }
- }
- }
- }
-
- private static class TimeValues {
- private final long timeAdded;
- private final long timeExpires;
-
- /**
- * @param now The current time in milliseconds
- * @param validDuration The duration this connection is valid for
- * @param validUnit The unit of time the duration is specified in.
- */
- TimeValues(long now, long validDuration, TimeUnit validUnit) {
- this.timeAdded = now;
- if(validDuration > 0) {
- this.timeExpires = now + validUnit.toMillis(validDuration);
- } else {
- this.timeExpires = Long.MAX_VALUE;
- }
- }
- }
-}
diff --git a/src/org/apache/http/impl/conn/LoggingSessionInputBuffer.java b/src/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
deleted file mode 100644
index 4f6477e19ddecc9b553449f36c97d530221e5590..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-
-import org.apache.http.io.HttpTransportMetrics;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Logs all data read to the wire LOG.
- *
- * @author Ortwin Glueck
- * @author Mike Bowler
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class LoggingSessionInputBuffer implements SessionInputBuffer {
-
- /** Original session input buffer. */
- private final SessionInputBuffer in;
-
- /** The wire log to use for writing. */
- private final Wire wire;
-
- /**
- * Create an instance that wraps the specified session input buffer.
- * @param in The session input buffer.
- * @param wire The wire log to use.
- */
- public LoggingSessionInputBuffer(final SessionInputBuffer in, final Wire wire) {
- super();
- this.in = in;
- this.wire = wire;
- }
-
- public boolean isDataAvailable(int timeout) throws IOException {
- return this.in.isDataAvailable(timeout);
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- int l = this.in.read(b, off, len);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, off, l);
- }
- return l;
- }
-
- public int read() throws IOException {
- int l = this.in.read();
- if (this.wire.enabled() && l > 0) {
- this.wire.input(l);
- }
- return l;
- }
-
- public int read(byte[] b) throws IOException {
- int l = this.in.read(b);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, 0, l);
- }
- return l;
- }
-
- public String readLine() throws IOException {
- String s = this.in.readLine();
- if (this.wire.enabled() && s != null) {
- this.wire.input(s + "[EOL]");
- }
- return s;
- }
-
- public int readLine(final CharArrayBuffer buffer) throws IOException {
- int l = this.in.readLine(buffer);
- if (this.wire.enabled() && l > 0) {
- int pos = buffer.length() - l;
- String s = new String(buffer.buffer(), pos, l);
- this.wire.input(s + "[EOL]");
- }
- return l;
- }
-
- public HttpTransportMetrics getMetrics() {
- return this.in.getMetrics();
- }
-
-}
diff --git a/src/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java b/src/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
deleted file mode 100644
index 1afab7da2379b50d1d2a23b7e86ef697382a3278..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java $
- * $Revision: 674186 $
- * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-
-import org.apache.http.io.HttpTransportMetrics;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Logs all data written to the wire LOG.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class LoggingSessionOutputBuffer implements SessionOutputBuffer {
-
- /** Original data transmitter. */
- private final SessionOutputBuffer out;
-
- /** The wire log to use. */
- private final Wire wire;
-
- /**
- * Create an instance that wraps the specified session output buffer.
- * @param out The session output buffer.
- * @param wire The Wire log to use.
- */
- public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
- super();
- this.out = out;
- this.wire = wire;
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
- this.out.write(b, off, len);
- if (this.wire.enabled()) {
- this.wire.output(b, off, len);
- }
- }
-
- public void write(int b) throws IOException {
- this.out.write(b);
- if (this.wire.enabled()) {
- this.wire.output(b);
- }
- }
-
- public void write(byte[] b) throws IOException {
- this.out.write(b);
- if (this.wire.enabled()) {
- this.wire.output(b);
- }
- }
-
- public void flush() throws IOException {
- this.out.flush();
- }
-
- public void writeLine(final CharArrayBuffer buffer) throws IOException {
- this.out.writeLine(buffer);
- if (this.wire.enabled()) {
- String s = new String(buffer.buffer(), 0, buffer.length());
- this.wire.output(s + "[EOL]");
- }
- }
-
- public void writeLine(final String s) throws IOException {
- this.out.writeLine(s);
- if (this.wire.enabled()) {
- this.wire.output(s + "[EOL]");
- }
- }
-
- public HttpTransportMetrics getMetrics() {
- return this.out.getMetrics();
- }
-
-}
diff --git a/src/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java b/src/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
deleted file mode 100644
index 136caf411c3f16129d26041d8686369cd7754df3..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java $
- * $Revision: 658785 $
- * $Date: 2008-05-21 10:47:40 -0700 (Wed, 21 May 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.ProxySelector;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
-
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-
-import org.apache.http.conn.params.ConnRouteParams;
-
-
-/**
- * Default implementation of an {@link HttpRoutePlanner}.
- * This implementation is based on {@link java.net.ProxySelector}.
- * By default, it will pick up the proxy settings of the JVM, either
- * from system properties or from the browser running the application.
- * Additionally, it interprets some
- * {@link org.apache.http.conn.params.ConnRoutePNames parameters},
- * though not the {@link
- * org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}.
- */
-public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
-
- /** The scheme registry. */
- protected SchemeRegistry schemeRegistry;
-
- /** The proxy selector to use, or null for system default. */
- protected ProxySelector proxySelector;
-
-
- /**
- * Creates a new proxy selector route planner.
- *
- * @param schreg the scheme registry
- * @param prosel the proxy selector, or
- * null for the system default
- */
- public ProxySelectorRoutePlanner(SchemeRegistry schreg,
- ProxySelector prosel) {
-
- if (schreg == null) {
- throw new IllegalArgumentException
- ("SchemeRegistry must not be null.");
- }
- schemeRegistry = schreg;
- proxySelector = prosel;
- }
-
-
- /**
- * Obtains the proxy selector to use.
- *
- * @return the proxy selector, or null for the system default
- */
- public ProxySelector getProxySelector() {
- return this.proxySelector;
- }
-
-
- /**
- * Sets the proxy selector to use.
- *
- * @param prosel the proxy selector, or
- * null to use the system default
- */
- public void setProxySelector(ProxySelector prosel) {
- this.proxySelector = prosel;
- }
-
-
-
- // non-javadoc, see interface HttpRoutePlanner
- public HttpRoute determineRoute(HttpHost target,
- HttpRequest request,
- HttpContext context)
- throws HttpException {
-
- if (request == null) {
- throw new IllegalStateException
- ("Request must not be null.");
- }
-
- // If we have a forced route, we can do without a target.
- HttpRoute route =
- ConnRouteParams.getForcedRoute(request.getParams());
- if (route != null)
- return route;
-
- // If we get here, there is no forced route.
- // So we need a target to compute a route.
-
- if (target == null) {
- throw new IllegalStateException
- ("Target host must not be null.");
- }
-
- final InetAddress local =
- ConnRouteParams.getLocalAddress(request.getParams());
- final HttpHost proxy = determineProxy(target, request, context);
-
- final Scheme schm =
- this.schemeRegistry.getScheme(target.getSchemeName());
- // as it is typically used for TLS/SSL, we assume that
- // a layered scheme implies a secure connection
- final boolean secure = schm.isLayered();
-
- if (proxy == null) {
- route = new HttpRoute(target, local, secure);
- } else {
- route = new HttpRoute(target, local, proxy, secure);
- }
- return route;
- }
-
-
- /**
- * Determines a proxy for the given target.
- *
- * @param target the planned target, never null
- * @param request the request to be sent, never null
- * @param context the context, or null
- *
- * @return the proxy to use, or null for a direct route
- *
- * @throws HttpException
- * in case of system proxy settings that cannot be handled
- */
- protected HttpHost determineProxy(HttpHost target,
- HttpRequest request,
- HttpContext context)
- throws HttpException {
-
- // the proxy selector can be 'unset', so we better deal with null here
- ProxySelector psel = this.proxySelector;
- if (psel == null)
- psel = ProxySelector.getDefault();
- if (psel == null)
- return null;
-
- URI targetURI = null;
- try {
- targetURI = new URI(target.toURI());
- } catch (URISyntaxException usx) {
- throw new HttpException
- ("Cannot convert host to URI: " + target, usx);
- }
- List proxies = psel.select(targetURI);
-
- Proxy p = chooseProxy(proxies, target, request, context);
-
- HttpHost result = null;
- if (p.type() == Proxy.Type.HTTP) {
- // convert the socket address to an HttpHost
- if (!(p.address() instanceof InetSocketAddress)) {
- throw new HttpException
- ("Unable to handle non-Inet proxy address: "+p.address());
- }
- final InetSocketAddress isa = (InetSocketAddress) p.address();
- // assume default scheme (http)
- result = new HttpHost(getHost(isa), isa.getPort());
- }
-
- return result;
- }
-
-
- /**
- * Obtains a host from an {@link InetSocketAddress}.
- *
- * @param isa the socket address
- *
- * @return a host string, either as a symbolic name or
- * as a literal IP address string
- *
- * (TODO: determine format for IPv6 addresses, with or without [brackets])
- */
- protected String getHost(InetSocketAddress isa) {
-
- //@@@ Will this work with literal IPv6 addresses, or do we
- //@@@ need to wrap these in [] for the string representation?
- //@@@ Having it in this method at least allows for easy workarounds.
- return isa.isUnresolved() ?
- isa.getHostName() : isa.getAddress().getHostAddress();
-
- }
-
-
- /*
- * Chooses a proxy from a list of available proxies.
- * The default implementation just picks the first non-SOCKS proxy
- * from the list. If there are only SOCKS proxies,
- * {@link Proxy#NO_PROXY Proxy.NO_PROXY} is returned.
- * Derived classes may implement more advanced strategies,
- * such as proxy rotation if there are multiple options.
- *
- * @param proxies the list of proxies to choose from,
- * never null or empty
- * @param target the planned target, never null
- * @param request the request to be sent, never null
- * @param context the context, or null
- *
- * @return a proxy of type {@link Proxy.Type#DIRECT DIRECT}
- * or {@link Proxy.Type#HTTP HTTP}, never null
- */
- protected Proxy chooseProxy(List proxies,
- HttpHost target,
- HttpRequest request,
- HttpContext context) {
-
- if ((proxies == null) || proxies.isEmpty()) {
- throw new IllegalArgumentException
- ("Proxy list must not be empty.");
- }
-
- Proxy result = null;
-
- // check the list for one we can use
- for (int i=0; (result == null) && (i < proxies.size()); i++) {
-
- Proxy p = proxies.get(i);
- switch (p.type()) {
-
- case DIRECT:
- case HTTP:
- result = p;
- break;
-
- case SOCKS:
- // SOCKS hosts are not handled on the route level.
- // The socket may make use of the SOCKS host though.
- break;
- }
- }
-
- if (result == null) {
- //@@@ log as warning or info that only a socks proxy is available?
- // result can only be null if all proxies are socks proxies
- // socks proxies are not handled on the route planning level
- result = Proxy.NO_PROXY;
- }
-
- return result;
- }
-
-} // class ProxySelectorRoutePlanner
-
diff --git a/src/org/apache/http/impl/conn/SingleClientConnManager.java b/src/org/apache/http/impl/conn/SingleClientConnManager.java
deleted file mode 100644
index 7999f3e8aee798dc34264256c6c02ededeeea246..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/SingleClientConnManager.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionOperator;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.RouteTracker;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.params.HttpParams;
-
-
-/**
- * A connection "manager" for a single connection.
- * This manager is good only for single-threaded use.
- * Allocation always returns the connection immediately,
- * even if it has not been released after the previous allocation.
- * In that case, a {@link #MISUSE_MESSAGE warning} is logged
- * and the previously issued connection is revoked.
- *
- * This class is derived from SimpleHttpConnectionManager
- * in HttpClient 3. See there for original authors.
- *
- *
- * @author Roland Weber
- * @author Michael Becke
- *
- *
- *
- * @version $Revision: 673450 $
- *
- * @since 4.0
- */
-public class SingleClientConnManager implements ClientConnectionManager {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /** The message to be logged on multiple allocation. */
- public final static String MISUSE_MESSAGE =
- "Invalid use of SingleClientConnManager: connection still allocated.\n" +
- "Make sure to release the connection before allocating another one.";
-
-
- /** The schemes supported by this connection manager. */
- protected SchemeRegistry schemeRegistry;
-
- /** The operator for opening and updating connections. */
- protected ClientConnectionOperator connOperator;
-
- /** The one and only entry in this pool. */
- protected PoolEntry uniquePoolEntry;
-
- /** The currently issued managed connection, if any. */
- protected ConnAdapter managedConn;
-
- /** The time of the last connection release, or -1. */
- protected long lastReleaseTime;
-
- /** The time the last released connection expires and shouldn't be reused. */
- protected long connectionExpiresTime;
-
- /** Whether the connection should be shut down on release. */
- protected boolean alwaysShutDown;
-
- /** Indicates whether this connection manager is shut down. */
- protected volatile boolean isShutDown;
-
-
-
-
- /**
- * Creates a new simple connection manager.
- *
- * @param params the parameters for this manager
- * @param schreg the scheme registry, or
- * null for the default registry
- */
- public SingleClientConnManager(HttpParams params,
- SchemeRegistry schreg) {
-
- if (schreg == null) {
- throw new IllegalArgumentException
- ("Scheme registry must not be null.");
- }
- this.schemeRegistry = schreg;
- this.connOperator = createConnectionOperator(schreg);
- this.uniquePoolEntry = new PoolEntry();
- this.managedConn = null;
- this.lastReleaseTime = -1L;
- this.alwaysShutDown = false; //@@@ from params? as argument?
- this.isShutDown = false;
-
- } //
-
-
- @Override
- protected void finalize() throws Throwable {
- shutdown();
- super.finalize();
- }
-
-
- // non-javadoc, see interface ClientConnectionManager
- public SchemeRegistry getSchemeRegistry() {
- return this.schemeRegistry;
- }
-
-
- /**
- * Hook for creating the connection operator.
- * It is called by the constructor.
- * Derived classes can override this method to change the
- * instantiation of the operator.
- * The default implementation here instantiates
- * {@link DefaultClientConnectionOperator DefaultClientConnectionOperator}.
- *
- * @param schreg the scheme registry to use, or null
- *
- * @return the connection operator to use
- */
- protected ClientConnectionOperator
- createConnectionOperator(SchemeRegistry schreg) {
-
- return new DefaultClientConnectionOperator(schreg);
- }
-
-
- /**
- * Asserts that this manager is not shut down.
- *
- * @throws IllegalStateException if this manager is shut down
- */
- protected final void assertStillUp()
- throws IllegalStateException {
-
- if (this.isShutDown)
- throw new IllegalStateException("Manager is shut down.");
- }
-
-
- public final ClientConnectionRequest requestConnection(
- final HttpRoute route,
- final Object state) {
-
- return new ClientConnectionRequest() {
-
- public void abortRequest() {
- // Nothing to abort, since requests are immediate.
- }
-
- public ManagedClientConnection getConnection(
- long timeout, TimeUnit tunit) {
- return SingleClientConnManager.this.getConnection(
- route, state);
- }
-
- };
- }
-
-
- /**
- * Obtains a connection.
- * This method does not block.
- *
- * @param route where the connection should point to
- *
- * @return a connection that can be used to communicate
- * along the given route
- */
- public ManagedClientConnection getConnection(HttpRoute route, Object state) {
-
- if (route == null) {
- throw new IllegalArgumentException("Route may not be null.");
- }
- assertStillUp();
-
- if (log.isDebugEnabled()) {
- log.debug("Get connection for route " + route);
- }
-
- if (managedConn != null)
- revokeConnection();
-
- // check re-usability of the connection
- boolean recreate = false;
- boolean shutdown = false;
-
- // Kill the connection if it expired.
- closeExpiredConnections();
-
- if (uniquePoolEntry.connection.isOpen()) {
- RouteTracker tracker = uniquePoolEntry.tracker;
- shutdown = (tracker == null || // can happen if method is aborted
- !tracker.toRoute().equals(route));
- } else {
- // If the connection is not open, create a new PoolEntry,
- // as the connection may have been marked not reusable,
- // due to aborts -- and the PoolEntry should not be reused
- // either. There's no harm in recreating an entry if
- // the connection is closed.
- recreate = true;
- }
-
- if (shutdown) {
- recreate = true;
- try {
- uniquePoolEntry.shutdown();
- } catch (IOException iox) {
- log.debug("Problem shutting down connection.", iox);
- }
- }
-
- if (recreate)
- uniquePoolEntry = new PoolEntry();
-
- managedConn = new ConnAdapter(uniquePoolEntry, route);
-
- return managedConn;
- }
-
-
- // non-javadoc, see interface ClientConnectionManager
- public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
- assertStillUp();
-
- if (!(conn instanceof ConnAdapter)) {
- throw new IllegalArgumentException
- ("Connection class mismatch, " +
- "connection not obtained from this manager.");
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Releasing connection " + conn);
- }
-
- ConnAdapter sca = (ConnAdapter) conn;
- if (sca.poolEntry == null)
- return; // already released
- ClientConnectionManager manager = sca.getManager();
- if (manager != null && manager != this) {
- throw new IllegalArgumentException
- ("Connection not obtained from this manager.");
- }
-
- try {
- // make sure that the response has been read completely
- if (sca.isOpen() && (this.alwaysShutDown ||
- !sca.isMarkedReusable())
- ) {
- if (log.isDebugEnabled()) {
- log.debug
- ("Released connection open but not reusable.");
- }
-
- // make sure this connection will not be re-used
- // we might have gotten here because of a shutdown trigger
- // shutdown of the adapter also clears the tracked route
- sca.shutdown();
- }
- } catch (IOException iox) {
- //@@@ log as warning? let pass?
- if (log.isDebugEnabled())
- log.debug("Exception shutting down released connection.",
- iox);
- } finally {
- sca.detach();
- managedConn = null;
- lastReleaseTime = System.currentTimeMillis();
- if(validDuration > 0)
- connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime;
- else
- connectionExpiresTime = Long.MAX_VALUE;
- }
- } // releaseConnection
-
- public void closeExpiredConnections() {
- if(System.currentTimeMillis() >= connectionExpiresTime) {
- closeIdleConnections(0, TimeUnit.MILLISECONDS);
- }
- }
-
-
- // non-javadoc, see interface ClientConnectionManager
- public void closeIdleConnections(long idletime, TimeUnit tunit) {
- assertStillUp();
-
- // idletime can be 0 or negative, no problem there
- if (tunit == null) {
- throw new IllegalArgumentException("Time unit must not be null.");
- }
-
- if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
- final long cutoff =
- System.currentTimeMillis() - tunit.toMillis(idletime);
- if (lastReleaseTime <= cutoff) {
- try {
- uniquePoolEntry.close();
- } catch (IOException iox) {
- // ignore
- log.debug("Problem closing idle connection.", iox);
- }
- }
- }
- }
-
-
- // non-javadoc, see interface ClientConnectionManager
- public void shutdown() {
-
- this.isShutDown = true;
-
- if (managedConn != null)
- managedConn.detach();
-
- try {
- if (uniquePoolEntry != null) // and connection open?
- uniquePoolEntry.shutdown();
- } catch (IOException iox) {
- // ignore
- log.debug("Problem while shutting down manager.", iox);
- } finally {
- uniquePoolEntry = null;
- }
- }
-
-
- /**
- * Revokes the currently issued connection.
- * The adapter gets disconnected, the connection will be shut down.
- */
- protected void revokeConnection() {
- if (managedConn == null)
- return;
-
- log.warn(MISUSE_MESSAGE);
-
- managedConn.detach();
-
- try {
- uniquePoolEntry.shutdown();
- } catch (IOException iox) {
- // ignore
- log.debug("Problem while shutting down connection.", iox);
- }
- }
-
-
- /**
- * The pool entry for this connection manager.
- */
- protected class PoolEntry extends AbstractPoolEntry {
-
- /**
- * Creates a new pool entry.
- *
- */
- protected PoolEntry() {
- super(SingleClientConnManager.this.connOperator, null);
- }
-
- /**
- * Closes the connection in this pool entry.
- */
- protected void close()
- throws IOException {
-
- shutdownEntry();
- if (connection.isOpen())
- connection.close();
- }
-
-
- /**
- * Shuts down the connection in this pool entry.
- */
- protected void shutdown()
- throws IOException {
-
- shutdownEntry();
- if (connection.isOpen())
- connection.shutdown();
- }
-
- } // class PoolEntry
-
-
-
- /**
- * The connection adapter used by this manager.
- */
- protected class ConnAdapter extends AbstractPooledConnAdapter {
-
- /**
- * Creates a new connection adapter.
- *
- * @param entry the pool entry for the connection being wrapped
- * @param route the planned route for this connection
- */
- protected ConnAdapter(PoolEntry entry, HttpRoute route) {
- super(SingleClientConnManager.this, entry);
- markReusable();
- entry.route = route;
- }
-
- }
-
-
-} // class SingleClientConnManager
diff --git a/src/org/apache/http/impl/conn/Wire.java b/src/org/apache/http/impl/conn/Wire.java
deleted file mode 100644
index 147b7f592b77f1e448ef591094671c7c19adaf0d..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/Wire.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/Wire.java,v 1.9 2004/06/24 21:39:52 mbecke Exp $
- * $Revision: 653041 $
- * $Date: 2008-05-03 03:39:28 -0700 (Sat, 03 May 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import org.apache.commons.logging.Log;
-
-/**
- * Logs data to the wire LOG.
- *
- * @author Oleg Kalnichevski
- *
- * @since 4.0
- */
-public class Wire {
-
- private final Log log;
-
- public Wire(Log log) {
- this.log = log;
- }
-
- private void wire(String header, InputStream instream)
- throws IOException {
- StringBuilder buffer = new StringBuilder();
- int ch;
- while ((ch = instream.read()) != -1) {
- if (ch == 13) {
- buffer.append("[\\r]");
- } else if (ch == 10) {
- buffer.append("[\\n]\"");
- buffer.insert(0, "\"");
- buffer.insert(0, header);
- log.debug(buffer.toString());
- buffer.setLength(0);
- } else if ((ch < 32) || (ch > 127)) {
- buffer.append("[0x");
- buffer.append(Integer.toHexString(ch));
- buffer.append("]");
- } else {
- buffer.append((char) ch);
- }
- }
- if (buffer.length() > 0) {
- buffer.append('\"');
- buffer.insert(0, '\"');
- buffer.insert(0, header);
- log.debug(buffer.toString());
- }
- }
-
-
- public boolean enabled() {
- return log.isDebugEnabled();
- }
-
- public void output(InputStream outstream)
- throws IOException {
- if (outstream == null) {
- throw new IllegalArgumentException("Output may not be null");
- }
- wire(">> ", outstream);
- }
-
- public void input(InputStream instream)
- throws IOException {
- if (instream == null) {
- throw new IllegalArgumentException("Input may not be null");
- }
- wire("<< ", instream);
- }
-
- public void output(byte[] b, int off, int len)
- throws IOException {
- if (b == null) {
- throw new IllegalArgumentException("Output may not be null");
- }
- wire(">> ", new ByteArrayInputStream(b, off, len));
- }
-
- public void input(byte[] b, int off, int len)
- throws IOException {
- if (b == null) {
- throw new IllegalArgumentException("Input may not be null");
- }
- wire("<< ", new ByteArrayInputStream(b, off, len));
- }
-
- public void output(byte[] b)
- throws IOException {
- if (b == null) {
- throw new IllegalArgumentException("Output may not be null");
- }
- wire(">> ", new ByteArrayInputStream(b));
- }
-
- public void input(byte[] b)
- throws IOException {
- if (b == null) {
- throw new IllegalArgumentException("Input may not be null");
- }
- wire("<< ", new ByteArrayInputStream(b));
- }
-
- public void output(int b)
- throws IOException {
- output(new byte[] {(byte) b});
- }
-
- public void input(int b)
- throws IOException {
- input(new byte[] {(byte) b});
- }
-
- public void output(final String s)
- throws IOException {
- if (s == null) {
- throw new IllegalArgumentException("Output may not be null");
- }
- output(s.getBytes());
- }
-
- public void input(final String s)
- throws IOException {
- if (s == null) {
- throw new IllegalArgumentException("Input may not be null");
- }
- input(s.getBytes());
- }
-}
diff --git a/src/org/apache/http/impl/conn/package.html b/src/org/apache/http/impl/conn/package.html
deleted file mode 100644
index 54eb3c23e81149f6ca54fa91977617fdb88c0085..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/src/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/src/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
deleted file mode 100644
index 2b37d7293a347c9b095c05831a548af3f6cda137..0000000000000000000000000000000000000000
--- a/src/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java $
- * $Revision: 673450 $
- * $Date: 2008-07-02 10:35:05 -0700 (Wed, 02 Jul 2008) $
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.conn.tsccm;
-
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.conn.ConnectionPoolTimeoutException;
-import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.impl.conn.IdleConnectionHandler;
-
-
-/**
- * An abstract connection pool.
- * It is used by the {@link ThreadSafeClientConnManager}.
- * The abstract pool includes a {@link #poolLock}, which is used to
- * synchronize access to the internal pool datastructures.
- * Don't use synchronized for that purpose!
- */
-public abstract class AbstractConnPool implements RefQueueHandler {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /**
- * The global lock for this pool.
- */
- protected final Lock poolLock;
-
-
- /**
- * References to issued connections.
- * Objects in this set are of class
- * {@link BasicPoolEntryRef BasicPoolEntryRef},
- * and point to the pool entry for the issued connection.
- * GCed connections are detected by the missing pool entries.
- */
- protected Set issuedConnections;
-
- /** The handler for idle connections. */
- protected IdleConnectionHandler idleConnHandler;
-
- /** The current total number of connections. */
- protected int numConnections;
-
- /**
- * A reference queue to track loss of pool entries to GC.
- * The same queue is used to track loss of the connection manager,
- * so we cannot specialize the type.
- */
- protected ReferenceQueue