HTTPCLIENT-674: use VersionInfo from core

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@558325 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2007-07-21 12:29:49 +00:00
parent 83273bbe10
commit 8621fbf232
7 changed files with 83 additions and 87 deletions

View File

@ -1,5 +1,8 @@
Changes since release 4.0 Alpha 1
* [HTTPCLIENT-674] use org.apache.http.util.VersionInfo instead of a local one
Contributed by Roland Weber <rolandw at apache.org>
* [HTTPCLIENT-666] Replaced HttpState with CredentialsProvier and CookieStore interfaces
Contributed by Oleg Kalnichevski <olegk at apache.org>

View File

@ -1,82 +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
* <http://www.apache.org/>.
*
*/
package org.apache.http.client;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class VersionInfo {
private static final String RESOURCE = "org/apache/http/client/version.properties";
private static Properties RELEASE_PROPERTIES;
private static String RELEASE_VERSION;
private static Properties getReleaseProperties() {
if (RELEASE_PROPERTIES == null) {
try {
ClassLoader cl = VersionInfo.class.getClassLoader();
InputStream instream = cl.getResourceAsStream(RESOURCE);
try {
Properties props = new Properties();
props.load(instream);
RELEASE_PROPERTIES = props;
} finally {
instream.close();
}
} catch (IOException ex) {
// shamelessly munch this exception
}
if (RELEASE_PROPERTIES == null) {
// Create dummy properties instance
RELEASE_PROPERTIES = new Properties();
}
}
return RELEASE_PROPERTIES;
}
public static String getReleaseVersion() {
if (RELEASE_VERSION == null) {
Properties props = getReleaseProperties();
RELEASE_VERSION = (String) props.get("httpclient.release");
if (RELEASE_VERSION == null
|| RELEASE_VERSION.length() == 0
|| RELEASE_VERSION.equals("${pom.version}")) {
RELEASE_VERSION = "UNKNOWN_SNAPSHOT";
}
}
return RELEASE_VERSION;
}
}

View File

@ -43,7 +43,6 @@
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.RoutedRequest;
import org.apache.http.client.VersionInfo;
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.params.HttpClientParams;
@ -79,6 +78,7 @@
import org.apache.http.protocol.RequestTargetHost;
import org.apache.http.protocol.RequestUserAgent;
import org.apache.http.protocol.SyncBasicHttpContext;
import org.apache.http.util.VersionInfo;
@ -127,10 +127,17 @@ protected HttpParams createHttpParams() {
HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params,
HTTP.DEFAULT_CONTENT_CHARSET);
HttpProtocolParams.setUserAgent(params,
"Apache-HttpClient/" + VersionInfo.getReleaseVersion() + " (java 1.4)");
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;
}

View File

@ -0,0 +1,22 @@
#
# 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.
#
info.module = HttpClient/auth
info.release = ${pom.version}
info.timestamp = ${mvn.timestamp}
# timestamp requires Maven 2.1

View File

@ -16,5 +16,7 @@
# specific language governing permissions and limitations
# under the License.
#
httpclient.release=${pom.version}
info.module = HttpClient
info.release = ${pom.version}
info.timestamp = ${mvn.timestamp}
# timestamp requires Maven 2.1

View File

@ -0,0 +1,22 @@
#
# 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.
#
info.module = HttpClient/conn
info.release = ${pom.version}
info.timestamp = ${mvn.timestamp}
# timestamp requires Maven 2.1

View File

@ -0,0 +1,22 @@
#
# 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.
#
info.module = HttpClient/cookie
info.release = ${pom.version}
info.timestamp = ${mvn.timestamp}
# timestamp requires Maven 2.1