diff -Nru httpcomponents-client-4.3.2/debian/changelog httpcomponents-client-4.3.3/debian/changelog --- httpcomponents-client-4.3.2/debian/changelog 2014-01-29 17:47:46.000000000 +0000 +++ httpcomponents-client-4.3.3/debian/changelog 2014-03-08 12:51:16.000000000 +0000 @@ -1,3 +1,15 @@ +httpcomponents-client (4.3.3-1) unstable; urgency=medium + + * New upstream release + - Refreshed the patches + * Removed the unused build dependency on libmaven-assembly-plugin-java + + [ Jakub Adam ] + * Fix OSGi metadata + - prevent org.apache.http.impl.execchain to appear in package imports. + + -- Emmanuel Bourg Sat, 08 Mar 2014 11:38:26 +0100 + httpcomponents-client (4.3.2-1) unstable; urgency=low * New upstream release diff -Nru httpcomponents-client-4.3.2/debian/control httpcomponents-client-4.3.3/debian/control --- httpcomponents-client-4.3.2/debian/control 2014-01-29 17:52:48.000000000 +0000 +++ httpcomponents-client-4.3.3/debian/control 2014-03-08 12:51:16.000000000 +0000 @@ -9,14 +9,12 @@ Build-Depends: debhelper (>= 9), default-jdk, javahelper, - maven-debian-helper, - maven-repo-helper + maven-debian-helper Build-Depends-Indep: junit, libbuild-helper-maven-plugin-java (>= 1.8), libcommons-codec-java, libhttpcore-java (>= 4.3.1), libmaven-antrun-plugin-java, - libmaven-assembly-plugin-java, libmaven-bundle-plugin-java, libmaven-javadoc-plugin-java, libmockito-java diff -Nru httpcomponents-client-4.3.2/debian/patches/00-fix_build.patch httpcomponents-client-4.3.3/debian/patches/00-fix_build.patch --- httpcomponents-client-4.3.2/debian/patches/00-fix_build.patch 2014-01-29 16:51:54.000000000 +0000 +++ httpcomponents-client-4.3.3/debian/patches/00-fix_build.patch 2014-03-08 12:51:16.000000000 +0000 @@ -3,12 +3,11 @@ Forwarded: no --- a/pom.xml +++ b/pom.xml -@@ -163,9 +163,7 @@ +@@ -163,8 +163,6 @@ httpclient httpmime fluent-hc - httpclient-cache - - httpclient-osgi diff -Nru httpcomponents-client-4.3.2/debian/patches/01-generate_osgi_metadata.patch httpcomponents-client-4.3.3/debian/patches/01-generate_osgi_metadata.patch --- httpcomponents-client-4.3.2/debian/patches/01-generate_osgi_metadata.patch 2014-01-29 16:52:12.000000000 +0000 +++ httpcomponents-client-4.3.3/debian/patches/01-generate_osgi_metadata.patch 2014-03-08 12:45:22.000000000 +0000 @@ -38,7 +38,7 @@ + Apache ${project.name} + ${project.groupId}.httpclient + ${debian.originalVersion} -+ org.apache.http.auth.*,org.apache.http.client.*,org.apache.http.conn.*,org.apache.http.cookie.*,org.apache.http.impl.auth*,org.apache.http.impl.client*,org.apache.http.impl.conn*,org.apache.http.impl.cookie* ++ org.apache.http.auth.*,org.apache.http.client.*,org.apache.http.conn.*,org.apache.http.cookie.*,org.apache.http.impl.* + + <_nouses>true + diff -Nru httpcomponents-client-4.3.2/fluent-hc/pom.xml httpcomponents-client-4.3.3/fluent-hc/pom.xml --- httpcomponents-client-4.3.2/fluent-hc/pom.xml 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/pom.xml 2014-02-21 22:31:59.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-client - 4.3.2 + 4.3.3 fluent-hc Fluent API for Apache HttpClient diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java httpcomponents-client-4.3.3/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java --- httpcomponents-client-4.3.2/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java 2014-01-15 18:33:44.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/examples/org/apache/http/client/fluent/FluentResponseHandling.java 2014-02-21 22:31:59.000000000 +0000 @@ -33,6 +33,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.http.Consts; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.StatusLine; @@ -40,7 +41,6 @@ import org.apache.http.client.HttpResponseException; import org.apache.http.client.ResponseHandler; import org.apache.http.entity.ContentType; -import org.apache.http.protocol.HTTP; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -74,7 +74,7 @@ } Charset charset = contentType.getCharset(); if (charset == null) { - charset = HTTP.DEF_CONTENT_CHARSET; + charset = Consts.ISO_8859_1; } return docBuilder.parse(entity.getContent(), charset.name()); } catch (ParserConfigurationException ex) { diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Content.java 2014-02-21 22:32:01.000000000 +0000 @@ -31,8 +31,8 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; +import org.apache.http.Consts; import org.apache.http.entity.ContentType; -import org.apache.http.protocol.HTTP; public class Content { @@ -58,7 +58,7 @@ public String asString() { Charset charset = this.type.getCharset(); if (charset == null) { - charset = HTTP.DEF_CONTENT_CHARSET; + charset = Consts.ISO_8859_1; } try { return new String(this.raw, charset.name()); diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Executor.java 2014-02-21 22:32:01.000000000 +0000 @@ -44,7 +44,6 @@ import org.apache.http.client.CookieStore; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; @@ -125,7 +124,8 @@ } public Executor auth(final HttpHost host, final Credentials creds) { - final AuthScope authScope = host != null ? new AuthScope(host) : AuthScope.ANY; + final AuthScope authScope = host != null ? + new AuthScope(host.getHostName(), host.getPort()) : AuthScope.ANY; return auth(authScope, creds); } @@ -202,8 +202,7 @@ localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider); localContext.setAttribute(HttpClientContext.AUTH_CACHE, this.authCache); localContext.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore); - final HttpRequestBase httprequest = request.prepareRequest(); - httprequest.reset(); + final InternalHttpRequest httprequest = request.prepareRequest(); return new Response(this.httpclient.execute(httprequest, localContext)); } diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java 1970-01-01 00:00:00.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalByteArrayEntity.java 2014-02-21 22:32:01.000000000 +0000 @@ -0,0 +1,100 @@ +/* + * ==================================================================== + * 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.fluent; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.util.Args; + +class InternalByteArrayEntity extends AbstractHttpEntity implements Cloneable { + + private final byte[] b; + private final int off, len; + + public InternalByteArrayEntity(final byte[] b, final ContentType contentType) { + super(); + Args.notNull(b, "Source byte array"); + this.b = b; + this.off = 0; + this.len = this.b.length; + if (contentType != null) { + setContentType(contentType.toString()); + } + } + + public InternalByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) { + super(); + Args.notNull(b, "Source byte array"); + if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) < 0) || ((off + len) > b.length)) { + throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length); + } + this.b = b; + this.off = off; + this.len = len; + if (contentType != null) { + setContentType(contentType.toString()); + } + } + + public InternalByteArrayEntity(final byte[] b) { + this(b, null); + } + + public InternalByteArrayEntity(final byte[] b, final int off, final int len) { + this(b, off, len, null); + } + + public boolean isRepeatable() { + return true; + } + + public long getContentLength() { + return this.len; + } + + public InputStream getContent() { + return new ByteArrayInputStream(this.b, this.off, this.len); + } + + public void writeTo(final OutputStream outstream) throws IOException { + Args.notNull(outstream, "Output stream"); + outstream.write(this.b, this.off, this.len); + outstream.flush(); + } + + public boolean isStreaming() { + return false; + } + +} diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java 1970-01-01 00:00:00.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalFileEntity.java 2014-02-21 22:32:01.000000000 +0000 @@ -0,0 +1,83 @@ +/* + * ==================================================================== + * 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.fluent; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.util.Args; + +class InternalFileEntity extends AbstractHttpEntity implements Cloneable { + + private final File file; + + public InternalFileEntity(final File file, final ContentType contentType) { + super(); + this.file = Args.notNull(file, "File"); + if (contentType != null) { + setContentType(contentType.toString()); + } + } + + 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 { + Args.notNull(outstream, "Output stream"); + final InputStream instream = new FileInputStream(this.file); + try { + final byte[] tmp = new byte[4096]; + int l; + while ((l = instream.read(tmp)) != -1) { + outstream.write(tmp, 0, l); + } + outstream.flush(); + } finally { + instream.close(); + } + } + + public boolean isStreaming() { + return false; + } + +} diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java 1970-01-01 00:00:00.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalHttpRequest.java 2014-02-21 22:32:01.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * ==================================================================== + * 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.fluent; + +import java.net.URI; + +import org.apache.http.HttpVersion; +import org.apache.http.ProtocolVersion; +import org.apache.http.RequestLine; +import org.apache.http.annotation.NotThreadSafe; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.Configurable; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.message.AbstractHttpMessage; +import org.apache.http.message.BasicRequestLine; +import org.apache.http.util.Args; + +@NotThreadSafe +class InternalHttpRequest extends AbstractHttpMessage implements HttpUriRequest, Configurable { + + private final String method; + private ProtocolVersion version; + private URI uri; + private RequestConfig config; + + InternalHttpRequest(final String method, final URI requestURI) { + Args.notBlank(method, "Method"); + Args.notNull(requestURI, "Request URI"); + this.method = method; + this.uri = requestURI; + } + + public void setProtocolVersion(final ProtocolVersion version) { + this.version = version; + } + + public ProtocolVersion getProtocolVersion() { + return version != null ? version : HttpVersion.HTTP_1_1; + } + + public String getMethod() { + return this.method; + } + + public URI getURI() { + return this.uri; + } + + public void abort() throws UnsupportedOperationException { + } + + public boolean isAborted() { + return false; + } + + public RequestLine getRequestLine() { + final String method = getMethod(); + final ProtocolVersion ver = getProtocolVersion(); + final 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 RequestConfig getConfig() { + return config; + } + + public void setConfig(final RequestConfig config) { + this.config = config; + } + + public void setURI(final URI uri) { + this.uri = uri; + } + + @Override + public String toString() { + return getMethod() + " " + getURI() + " " + getProtocolVersion(); + } + +} diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java 1970-01-01 00:00:00.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/InternalInputStreamEntity.java 2014-02-21 22:32:01.000000000 +0000 @@ -0,0 +1,96 @@ +/* + * ==================================================================== + * 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.fluent; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ContentType; +import org.apache.http.util.Args; + +class InternalInputStreamEntity extends AbstractHttpEntity { + + private final InputStream content; + private final long length; + + public InternalInputStreamEntity(final InputStream instream, final long length, final ContentType contentType) { + super(); + this.content = Args.notNull(instream, "Source input stream"); + this.length = length; + if (contentType != null) { + setContentType(contentType.toString()); + } + } + + 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 { + Args.notNull(outstream, "Output stream"); + final InputStream instream = this.content; + try { + final byte[] buffer = new byte[4096]; + 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(4096, remaining)); + if (l == -1) { + break; + } + outstream.write(buffer, 0, l); + remaining -= l; + } + } + } finally { + instream.close(); + } + } + + public boolean isStreaming() { + return true; + } + +} diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Request.java 2014-02-21 22:32:00.000000000 +0000 @@ -29,14 +29,18 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.nio.charset.Charset; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.List; import java.util.Locale; import java.util.TimeZone; +import org.apache.http.Consts; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -45,20 +49,15 @@ import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpOptions; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpTrace; -import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.entity.ContentType; -import org.apache.http.entity.FileEntity; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; public class Request { @@ -67,74 +66,74 @@ public static final Locale DATE_LOCALE = Locale.US; public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT"); - private final HttpRequestBase request; + private final InternalHttpRequest request; private final RequestConfig.Builder configBuilder; private SimpleDateFormat dateFormatter; public static Request Get(final URI uri) { - return new Request(new HttpGet(uri)); + return new Request(HttpGet.METHOD_NAME, uri); } public static Request Get(final String uri) { - return new Request(new HttpGet(uri)); + return new Request(HttpGet.METHOD_NAME, URI.create(uri)); } public static Request Head(final URI uri) { - return new Request(new HttpHead(uri)); + return new Request(HttpHead.METHOD_NAME, uri); } public static Request Head(final String uri) { - return new Request(new HttpHead(uri)); + return new Request(HttpHead.METHOD_NAME, URI.create(uri)); } public static Request Post(final URI uri) { - return new Request(new HttpPost(uri)); + return new Request(HttpPost.METHOD_NAME, uri); } public static Request Post(final String uri) { - return new Request(new HttpPost(uri)); + return new Request(HttpPost.METHOD_NAME, URI.create(uri)); } public static Request Put(final URI uri) { - return new Request(new HttpPut(uri)); + return new Request(HttpPut.METHOD_NAME, uri); } public static Request Put(final String uri) { - return new Request(new HttpPut(uri)); + return new Request(HttpPut.METHOD_NAME, URI.create(uri)); } public static Request Trace(final URI uri) { - return new Request(new HttpTrace(uri)); + return new Request(HttpTrace.METHOD_NAME, uri); } public static Request Trace(final String uri) { - return new Request(new HttpTrace(uri)); + return new Request(HttpTrace.METHOD_NAME, URI.create(uri)); } public static Request Delete(final URI uri) { - return new Request(new HttpDelete(uri)); + return new Request(HttpDelete.METHOD_NAME, uri); } public static Request Delete(final String uri) { - return new Request(new HttpDelete(uri)); + return new Request(HttpDelete.METHOD_NAME, URI.create(uri)); } public static Request Options(final URI uri) { - return new Request(new HttpOptions(uri)); + return new Request(HttpOptions.METHOD_NAME, uri); } public static Request Options(final String uri) { - return new Request(new HttpOptions(uri)); + return new Request(HttpOptions.METHOD_NAME, URI.create(uri)); } - Request(final HttpRequestBase request) { + Request(final String method, final URI requestURI) { super(); - this.request = request; + this.request = new InternalHttpRequest(method, requestURI); this.configBuilder = RequestConfig.custom(); } - HttpRequestBase prepareRequest() { + InternalHttpRequest prepareRequest() { this.request.setConfig(this.configBuilder.build()); return this.request; } @@ -304,39 +303,52 @@ } public Request bodyForm(final Iterable formParams, final Charset charset) { - return body(new UrlEncodedFormEntity(formParams, charset)); + final List paramList = new ArrayList(); + for (NameValuePair param : formParams) { + paramList.add(param); + } + final ContentType contentType = ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset); + final String s = URLEncodedUtils.format(paramList, charset != null ? charset.name() : null); + return bodyString(s, contentType); } public Request bodyForm(final Iterable formParams) { - return bodyForm(formParams, HTTP.DEF_CONTENT_CHARSET); + return bodyForm(formParams, Consts.ISO_8859_1); } public Request bodyForm(final NameValuePair... formParams) { - return bodyForm(Arrays.asList(formParams), HTTP.DEF_CONTENT_CHARSET); + return bodyForm(Arrays.asList(formParams), Consts.ISO_8859_1); } public Request bodyString(final String s, final ContentType contentType) { - return body(new StringEntity(s, contentType)); + final Charset charset = contentType != null ? contentType.getCharset() : null; + byte[] raw; + try { + raw = charset != null ? s.getBytes(charset.name()) : s.getBytes(); + } catch (UnsupportedEncodingException ex) { + raw = s.getBytes(); + } + return body(new InternalByteArrayEntity(raw, contentType)); } public Request bodyFile(final File file, final ContentType contentType) { - return body(new FileEntity(file, contentType)); + return body(new InternalFileEntity(file, contentType)); } public Request bodyByteArray(final byte[] b) { - return body(new ByteArrayEntity(b)); + return body(new InternalByteArrayEntity(b)); } public Request bodyByteArray(final byte[] b, final int off, final int len) { - return body(new ByteArrayEntity(b, off, len)); + return body(new InternalByteArrayEntity(b, off, len)); } public Request bodyStream(final InputStream instream) { - return body(new InputStreamEntity(instream, -1)); + return body(new InternalInputStreamEntity(instream, -1, null)); } public Request bodyStream(final InputStream instream, final ContentType contentType) { - return body(new InputStreamEntity(instream, -1, contentType)); + return body(new InternalInputStreamEntity(instream, -1, contentType)); } @Override diff -Nru httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java --- httpcomponents-client-4.3.2/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/fluent-hc/src/main/java/org/apache/http/client/fluent/Response.java 2014-02-21 22:32:01.000000000 +0000 @@ -29,6 +29,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -61,7 +62,11 @@ return; } try { - EntityUtils.consume(this.response.getEntity()); + final HttpEntity entity = this.response.getEntity(); + final InputStream content = entity.getContent(); + if (content != null) { + content.close(); + } } catch (final Exception ignore) { } finally { this.consumed = true; @@ -97,8 +102,11 @@ try { final HttpEntity entity = this.response.getEntity(); if (entity != null) { - this.response.setEntity(new ByteArrayEntity(EntityUtils.toByteArray(entity), - ContentType.getOrDefault(entity))); + final ByteArrayEntity byteArrayEntity = new ByteArrayEntity( + EntityUtils.toByteArray(entity)); + final ContentType contentType = ContentType.getOrDefault(entity); + byteArrayEntity.setContentType(contentType.toString()); + this.response.setEntity(byteArrayEntity); } return this.response; } finally { diff -Nru httpcomponents-client-4.3.2/httpclient/pom.xml httpcomponents-client-4.3.3/httpclient/pom.xml --- httpcomponents-client-4.3.2/httpclient/pom.xml 2014-01-15 18:34:11.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/pom.xml 2014-02-21 22:31:38.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-client - 4.3.2 + 4.3.3 httpclient Apache HttpClient diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java 2014-01-15 18:34:05.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java 2014-02-21 22:31:24.000000000 +0000 @@ -50,6 +50,12 @@ this.decompressingEntity = decompressingEntity; } + private void initWrapper() throws IOException { + if (wrapperStream == null) { + wrapperStream = decompressingEntity.decorate(wrappedStream); + } + } + @Override public int read() throws IOException { initWrapper(); @@ -57,23 +63,43 @@ } @Override - public int available() throws IOException { + public int read(final byte[] b) throws IOException { initWrapper(); - return wrapperStream.available(); + return wrapperStream.read(b); } - private void initWrapper() throws IOException { - if (wrapperStream == null) { - wrapperStream = decompressingEntity.decorate(wrappedStream); - } + @Override + public int read(final byte[] b, final int off, final int len) throws IOException { + initWrapper(); + return wrapperStream.read(b, off, len); + } + + @Override + public long skip(final long n) throws IOException { + initWrapper(); + return wrapperStream.skip(n); + } + + @Override + public boolean markSupported() { + return false; + } + + @Override + public int available() throws IOException { + initWrapper(); + return wrapperStream.available(); } @Override public void close() throws IOException { - if (wrapperStream != null) { - wrapperStream.close(); + try { + if (wrapperStream != null) { + wrapperStream.close(); + } + } finally { + wrappedStream.close(); } - wrappedStream.close(); } } diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java 2014-01-15 18:34:08.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java 2014-02-21 22:31:37.000000000 +0000 @@ -35,6 +35,7 @@ import org.apache.http.annotation.ThreadSafe; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; +import org.apache.http.auth.NTCredentials; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.AuthSchemes; @@ -85,11 +86,14 @@ private static PasswordAuthentication getSystemCreds( final AuthScope authscope, final Authenticator.RequestorType requestorType) { + final String hostname = authscope.getHost(); + final int port = authscope.getPort(); + final String protocol = port == 443 ? "https" : "http"; return Authenticator.requestPasswordAuthentication( - authscope.getHost(), + hostname, null, - authscope.getPort(), - "http", + port, + protocol, null, translateScheme(authscope.getScheme()), null, @@ -110,8 +114,25 @@ authscope, Authenticator.RequestorType.PROXY); } if (systemcreds != null) { - return new UsernamePasswordCredentials( - systemcreds.getUserName(), new String(systemcreds.getPassword())); + final String domain = System.getProperty("http.auth.ntlm.domain"); + if (domain != null) { + return new NTCredentials( + systemcreds.getUserName(), + new String(systemcreds.getPassword()), + null, domain); + } else { + if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) { + // Domian may be specified in a fully qualified user name + return new NTCredentials( + systemcreds.getUserName(), + new String(systemcreds.getPassword()), + null, null); + } else { + return new UsernamePasswordCredentials( + systemcreds.getUserName(), + new String(systemcreds.getPassword())); + } + } } } return null; diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java 2014-01-15 18:34:07.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java 2014-02-21 22:31:34.000000000 +0000 @@ -42,7 +42,6 @@ import org.apache.http.config.SocketConfig; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.DnsResolver; -import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.HttpHostConnectException; import org.apache.http.conn.ManagedHttpClientConnection; import org.apache.http.conn.SchemePortResolver; @@ -57,7 +56,7 @@ static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry"; - private final Log log = LogFactory.getLog(HttpClientConnectionManager.class); + private final Log log = LogFactory.getLog(getClass()); private final Lookup socketFactoryRegistry; private final SchemePortResolver schemePortResolver; @@ -124,6 +123,9 @@ sock.setSoLinger(linger > 0, linger); } conn.bind(sock); + if (this.log.isDebugEnabled()) { + this.log.debug("Connection established " + conn); + } return; } catch (final SocketTimeoutException ex) { if (last) { diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java 2014-01-15 18:34:07.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/LoggingInputStream.java 2014-02-21 22:31:34.000000000 +0000 @@ -51,48 +51,79 @@ @Override public int read() throws IOException { - final int b = in.read(); - if (b != -1) { - wire.input(b); + try { + final int b = in.read(); + if (b == -1) { + wire.input("end of stream"); + } else { + wire.input(b); + } + return b; + } catch (IOException ex) { + wire.input("[read] I/O error: " + ex.getMessage()); + throw ex; } - return b; } @Override public int read(final byte[] b) throws IOException { - final int bytesRead = in.read(b); - if (bytesRead != -1) { - wire.input(b, 0, bytesRead); + try { + final int bytesRead = in.read(b); + if (bytesRead == -1) { + wire.input("end of stream"); + } else if (bytesRead > 0) { + wire.input(b, 0, bytesRead); + } + return bytesRead; + } catch (IOException ex) { + wire.input("[read] I/O error: " + ex.getMessage()); + throw ex; } - return bytesRead; } @Override public int read(final byte[] b, final int off, final int len) throws IOException { - final int bytesRead = in.read(b, off, len); - if (bytesRead != -1) { - wire.input(b, off, bytesRead); + try { + final int bytesRead = in.read(b, off, len); + if (bytesRead == -1) { + wire.input("end of stream"); + } else if (bytesRead > 0) { + wire.input(b, off, bytesRead); + } + return bytesRead; + } catch (IOException ex) { + wire.input("[read] I/O error: " + ex.getMessage()); + throw ex; } - return bytesRead; } @Override public long skip(final long n) throws IOException { - return super.skip(n); + try { + return super.skip(n); + } catch (IOException ex) { + wire.input("[skip] I/O error: " + ex.getMessage()); + throw ex; + } } @Override public int available() throws IOException { - return in.available(); + try { + return in.available(); + } catch (IOException ex) { + wire.input("[available] I/O error : " + ex.getMessage()); + throw ex; + } } @Override - public synchronized void mark(final int readlimit) { + public void mark(final int readlimit) { super.mark(readlimit); } @Override - public synchronized void reset() throws IOException { + public void reset() throws IOException { super.reset(); } @@ -103,7 +134,12 @@ @Override public void close() throws IOException { - in.close(); + try { + in.close(); + } catch (IOException ex) { + wire.input("[close] I/O error: " + ex.getMessage()); + throw ex; + } } } diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java 2014-01-15 18:34:07.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/LoggingOutputStream.java 2014-02-21 22:31:34.000000000 +0000 @@ -51,29 +51,54 @@ @Override public void write(final int b) throws IOException { - wire.output(b); + try { + wire.output(b); + } catch (IOException ex) { + wire.output("[write] I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void write(final byte[] b) throws IOException { - wire.output(b); - out.write(b); + try { + wire.output(b); + out.write(b); + } catch (IOException ex) { + wire.output("[write] I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void write(final byte[] b, final int off, final int len) throws IOException { - wire.output(b, off, len); - out.write(b, off, len); + try { + wire.output(b, off, len); + out.write(b, off, len); + } catch (IOException ex) { + wire.output("[write] I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void flush() throws IOException { - out.flush(); + try { + out.flush(); + } catch (IOException ex) { + wire.output("[flush] I/O error: " + ex.getMessage()); + throw ex; + } } @Override public void close() throws IOException { - out.close(); + try { + out.close(); + } catch (IOException ex) { + wire.output("[close] I/O error: " + ex.getMessage()); + throw ex; + } } } diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java 2014-01-15 18:34:07.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java 2014-02-21 22:31:34.000000000 +0000 @@ -138,20 +138,12 @@ input(new byte[] {(byte) b}); } - /** - * @deprecated (4.1) do not use - */ - @Deprecated public void output(final String s) throws IOException { Args.notNull(s, "Output"); output(s.getBytes()); } - /** - * @deprecated (4.1) do not use - */ - @Deprecated public void input(final String s) throws IOException { Args.notNull(s, "Input"); diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java 2014-01-15 18:34:09.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/execchain/RetryExec.java 2014-02-21 22:31:31.000000000 +0000 @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.http.Header; import org.apache.http.HttpException; +import org.apache.http.NoHttpResponseException; import org.apache.http.annotation.Immutable; import org.apache.http.client.HttpRequestRetryHandler; import org.apache.http.client.NonRepeatableRequestException; @@ -91,7 +92,9 @@ if (retryHandler.retryRequest(ex, execCount, context)) { if (this.log.isInfoEnabled()) { this.log.info("I/O exception ("+ ex.getClass().getName() + - ") caught when processing request: " + ") caught when processing request to " + + route + + ": " + ex.getMessage()); } if (this.log.isDebugEnabled()) { @@ -103,9 +106,18 @@ "with a non-repeatable request entity", ex); } request.setHeaders(origheaders); - this.log.info("Retrying request"); + if (this.log.isInfoEnabled()) { + this.log.info("Retrying request to " + route); + } } else { - throw ex; + if (ex instanceof NoHttpResponseException) { + final NoHttpResponseException updatedex = new NoHttpResponseException( + route.getTargetHost().toHostString() + " failed to respond"); + updatedex.setStackTrace(ex.getStackTrace()); + throw updatedex; + } else { + throw ex; + } } } } diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java --- httpcomponents-client-4.3.2/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java 2014-01-15 18:34:09.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java 2014-02-21 22:31:31.000000000 +0000 @@ -32,6 +32,7 @@ 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.annotation.Immutable; import org.apache.http.client.ServiceUnavailableRetryStrategy; @@ -76,6 +77,7 @@ final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { + final Header[] origheaders = request.getAllHeaders(); for (int c = 1;; c++) { final CloseableHttpResponse response = this.requestExecutor.execute( route, request, context, execAware); @@ -92,6 +94,7 @@ throw new InterruptedIOException(); } } + request.setHeaders(origheaders); } else { return response; } diff -Nru httpcomponents-client-4.3.2/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java httpcomponents-client-4.3.3/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java --- httpcomponents-client-4.3.2/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java 2014-01-15 18:33:59.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient/src/main/java-deprecated/org/apache/http/impl/client/DefaultRequestDirector.java 2014-02-21 22:31:18.000000000 +0000 @@ -42,6 +42,7 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; +import org.apache.http.NoHttpResponseException; import org.apache.http.ProtocolException; import org.apache.http.ProtocolVersion; import org.apache.http.annotation.NotThreadSafe; @@ -621,12 +622,14 @@ if (retryHandler.retryRequest(ex, connectCount, context)) { if (this.log.isInfoEnabled()) { this.log.info("I/O exception ("+ ex.getClass().getName() + - ") caught when connecting to the target host: " + ") caught when connecting to " + + route + + ": " + ex.getMessage()); if (this.log.isDebugEnabled()) { this.log.debug(ex.getMessage(), ex); } - this.log.info("Retrying connect"); + this.log.info("Retrying connect to " + route); } } else { throw ex; @@ -691,16 +694,27 @@ if (retryHandler.retryRequest(ex, wrapper.getExecCount(), context)) { if (this.log.isInfoEnabled()) { this.log.info("I/O exception ("+ ex.getClass().getName() + - ") caught when processing request: " + ") caught when processing request to " + + route + + ": " + ex.getMessage()); } if (this.log.isDebugEnabled()) { this.log.debug(ex.getMessage(), ex); } - this.log.info("Retrying request"); + if (this.log.isInfoEnabled()) { + this.log.info("Retrying request to " + route); + } retryReason = ex; } else { - throw ex; + if (ex instanceof NoHttpResponseException) { + final NoHttpResponseException updatedex = new NoHttpResponseException( + route.getTargetHost().toHostString() + " failed to respond"); + updatedex.setStackTrace(ex.getStackTrace()); + throw updatedex; + } else { + throw ex; + } } } } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/pom.xml httpcomponents-client-4.3.3/httpclient-cache/pom.xml --- httpcomponents-client-4.3.2/httpclient-cache/pom.xml 2014-01-15 18:33:44.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/pom.xml 2014-02-21 22:31:53.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-client - 4.3.2 + 4.3.3 httpclient-cache Apache HttpClient Cache diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java 2014-01-15 18:33:43.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java 2014-02-21 22:31:47.000000000 +0000 @@ -64,7 +64,6 @@ import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; -import org.apache.http.util.EntityUtils; import org.apache.http.util.VersionInfo; /** @@ -634,7 +633,7 @@ final Header resultEtagHeader = backendResponse.getFirstHeader(HeaderConstants.ETAG); if (resultEtagHeader == null) { log.warn("304 response did not contain ETag"); - EntityUtils.consume(backendResponse.getEntity()); + IOUtils.consume(backendResponse.getEntity()); backendResponse.close(); return callBackend(route, request, context, execAware); } @@ -643,7 +642,7 @@ final Variant matchingVariant = variants.get(resultEtag); if (matchingVariant == null) { log.debug("304 response did not contain ETag matching one sent in If-None-Match"); - EntityUtils.consume(backendResponse.getEntity()); + IOUtils.consume(backendResponse.getEntity()); backendResponse.close(); return callBackend(route, request, context, execAware); } @@ -651,7 +650,7 @@ final HttpCacheEntry matchedEntry = matchingVariant.getEntry(); if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) { - EntityUtils.consume(backendResponse.getEntity()); + IOUtils.consume(backendResponse.getEntity()); backendResponse.close(); return retryRequestUnconditionally(route, request, context, execAware, matchedEntry); } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java 2014-01-15 18:33:44.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/IOUtils.java 2014-02-21 22:31:48.000000000 +0000 @@ -34,11 +34,24 @@ import java.io.RandomAccessFile; import java.nio.channels.FileChannel; +import org.apache.http.HttpEntity; import org.apache.http.annotation.Immutable; @Immutable class IOUtils { + static void consume(final HttpEntity entity) throws IOException { + if (entity == null) { + return; + } + if (entity.isStreaming()) { + final InputStream instream = entity.getContent(); + if (instream != null) { + instream.close(); + } + } + } + static void copy(final InputStream in, final OutputStream out) throws IOException { final byte[] buf = new byte[2048]; int len; diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java 2014-01-15 18:33:43.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java 2014-02-21 22:31:48.000000000 +0000 @@ -31,6 +31,7 @@ import java.lang.ref.ReferenceQueue; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.http.annotation.ThreadSafe; import org.apache.http.client.cache.HttpCacheEntry; @@ -60,18 +61,18 @@ private final CacheMap entries; private final ReferenceQueue morque; private final Set resources; - - private volatile boolean shutdown; + private final AtomicBoolean active; public ManagedHttpCacheStorage(final CacheConfig config) { super(); this.entries = new CacheMap(config.getMaxCacheEntries()); this.morque = new ReferenceQueue(); this.resources = new HashSet(); + this.active = new AtomicBoolean(true); } private void ensureValidState() throws IllegalStateException { - if (this.shutdown) { + if (!this.active.get()) { throw new IllegalStateException("Cache has been shut down"); } } @@ -130,30 +131,27 @@ } public void cleanResources() { - if (this.shutdown) { - return; - } - ResourceReference ref; - while ((ref = (ResourceReference) this.morque.poll()) != null) { - synchronized (this) { - this.resources.remove(ref); + if (this.active.get()) { + ResourceReference ref; + while ((ref = (ResourceReference) this.morque.poll()) != null) { + synchronized (this) { + this.resources.remove(ref); + } + ref.getResource().dispose(); } - ref.getResource().dispose(); } } public void shutdown() { - if (this.shutdown) { - return; - } - this.shutdown = true; - synchronized (this) { - this.entries.clear(); - for (final ResourceReference ref: this.resources) { - ref.getResource().dispose(); - } - this.resources.clear(); - while (this.morque.poll() != null) { + if (this.active.compareAndSet(true, false)) { + synchronized (this) { + this.entries.clear(); + for (final ResourceReference ref: this.resources) { + ref.getResource().dispose(); + } + this.resources.clear(); + while (this.morque.poll() != null) { + } } } } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java 2014-01-15 18:33:44.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java 2014-02-21 22:31:48.000000000 +0000 @@ -46,7 +46,6 @@ import org.apache.http.client.utils.DateUtils; import org.apache.http.message.BasicHeader; import org.apache.http.protocol.HTTP; -import org.apache.http.util.EntityUtils; /** * @since 4.1 @@ -94,7 +93,7 @@ private void consumeBody(final HttpResponse response) throws IOException { final HttpEntity body = response.getEntity(); if (body != null) { - EntityUtils.consume(body); + IOUtils.consume(body); } } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java 2014-01-15 18:33:43.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProxyHandler.java 2014-02-21 22:31:48.000000000 +0000 @@ -35,7 +35,6 @@ import org.apache.http.HttpResponse; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.util.EntityUtils; /** * A proxy class that can enhance an arbitrary {@link HttpResponse} with @@ -64,7 +63,7 @@ } public void close() throws IOException { - EntityUtils.consume(original.getEntity()); + IOUtils.consume(original.getEntity()); } public Object invoke( diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java httpcomponents-client-4.3.3/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java --- httpcomponents-client-4.3.2/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java 2014-01-15 18:33:41.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/main/java-deprecated/org/apache/http/impl/client/cache/CachingHttpClient.java 2014-02-21 22:31:42.000000000 +0000 @@ -78,7 +78,6 @@ import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HttpContext; import org.apache.http.util.Args; -import org.apache.http.util.EntityUtils; import org.apache.http.util.VersionInfo; /** @@ -381,7 +380,7 @@ } catch (final Exception t) { final HttpEntity entity = response.getEntity(); try { - EntityUtils.consume(entity); + IOUtils.consume(entity); } catch (final Exception t2) { // Log this exception. The original exception is more // important and will be thrown to the caller. @@ -399,7 +398,7 @@ // Handling the response was successful. Ensure that the content has // been fully consumed. final HttpEntity entity = response.getEntity(); - EntityUtils.consume(entity); + IOUtils.consume(entity); return result; } @@ -804,7 +803,7 @@ final HttpCacheEntry matchedEntry = matchingVariant.getEntry(); if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) { - EntityUtils.consume(backendResponse.getEntity()); + IOUtils.consume(backendResponse.getEntity()); return retryRequestUnconditionally(target, request, context, matchedEntry); } @@ -875,7 +874,7 @@ Date responseDate = getCurrentDate(); if (revalidationResponseIsTooOld(backendResponse, cacheEntry)) { - EntityUtils.consume(backendResponse.getEntity()); + IOUtils.consume(backendResponse.getEntity()); final HttpRequest unconditional = conditionalRequestBuilder .buildUnconditionalRequest(request, cacheEntry); requestDate = getCurrentDate(); @@ -907,7 +906,7 @@ cachedResponse.addHeader(HeaderConstants.WARNING, "110 localhost \"Response is stale\""); final HttpEntity errorBody = backendResponse.getEntity(); if (errorBody != null) { - EntityUtils.consume(errorBody); + IOUtils.consume(errorBody); } return cachedResponse; } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java --- httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java 2014-01-15 18:33:40.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestBasicHttpCache.java 2014-02-21 22:31:41.000000000 +0000 @@ -62,7 +62,6 @@ import org.apache.http.entity.ByteArrayEntity; import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHttpResponse; -import org.apache.http.util.EntityUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -510,7 +509,7 @@ originResponse.setHeader("ETag", "\"etag\""); final HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived); - EntityUtils.consume(result.getEntity()); + IOUtils.consume(result.getEntity()); assertTrue(inputStream.wasClosed()); } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java --- httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java 2014-01-15 18:33:41.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java 2014-02-21 22:31:40.000000000 +0000 @@ -341,7 +341,7 @@ } return 'y'; } - })); + }, -1)); final CloseableHttpResponse resp = mockBackend.execute( EasyMock.isA(HttpRoute.class), diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java --- httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java 2014-01-15 18:33:40.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheJiraNumber1147.java 2014-02-21 22:31:41.000000000 +0000 @@ -38,11 +38,10 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpRequestWrapper; import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.conn.routing.HttpRoute; import org.apache.http.client.utils.DateUtils; +import org.apache.http.conn.routing.HttpRoute; import org.apache.http.impl.execchain.ClientExecChain; import org.apache.http.message.BasicHttpResponse; -import org.apache.http.util.EntityUtils; import org.easymock.EasyMock; import org.junit.After; import org.junit.Assert; @@ -116,7 +115,7 @@ final HttpResponse response1 = t.execute(route, get, context, null); Assert.assertEquals(200, response1.getStatusLine().getStatusCode()); - EntityUtils.consume(response1.getEntity()); + IOUtils.consume(response1.getEntity()); EasyMock.verify(backend); @@ -132,7 +131,7 @@ final HttpResponse response2 = t.execute(route, get, context, null); Assert.assertEquals(200, response2.getStatusLine().getStatusCode()); - EntityUtils.consume(response2.getEntity()); + IOUtils.consume(response2.getEntity()); EasyMock.verify(backend); } diff -Nru httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java --- httpcomponents-client-4.3.2/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java 2014-01-15 18:33:40.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java 2014-02-21 22:31:41.000000000 +0000 @@ -26,12 +26,12 @@ */ package org.apache.http.impl.client.cache; +import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.MethodNotSupportedException; -import org.apache.http.Header; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.cache.CacheResponseStatus; @@ -41,10 +41,10 @@ import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.localserver.LocalTestServer; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; -import org.apache.http.util.EntityUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -53,10 +53,8 @@ import java.io.UnsupportedEncodingException; import java.util.Locale; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import org.apache.http.localserver.LocalTestServer; /** * Test that after background validation that a subsequent request for non cached @@ -205,7 +203,7 @@ if(response!=null) { final HttpEntity entity = response.getEntity(); try { - EntityUtils.consume(entity); + IOUtils.consume(entity); } catch (final IOException e) { e.printStackTrace(); } diff -Nru httpcomponents-client-4.3.2/httpclient-osgi/pom.xml httpcomponents-client-4.3.3/httpclient-osgi/pom.xml --- httpcomponents-client-4.3.2/httpclient-osgi/pom.xml 2014-01-15 18:33:50.000000000 +0000 +++ httpcomponents-client-4.3.3/httpclient-osgi/pom.xml 2014-02-21 22:31:06.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-client - 4.3.2 + 4.3.3 httpclient-osgi Apache HttpClient OSGi bundle diff -Nru httpcomponents-client-4.3.2/httpmime/pom.xml httpcomponents-client-4.3.3/httpmime/pom.xml --- httpcomponents-client-4.3.2/httpmime/pom.xml 2014-01-15 18:33:47.000000000 +0000 +++ httpcomponents-client-4.3.3/httpmime/pom.xml 2014-02-21 22:32:04.000000000 +0000 @@ -28,7 +28,7 @@ org.apache.httpcomponents httpcomponents-client - 4.3.2 + 4.3.3 httpmime Apache HttpClient Mime diff -Nru httpcomponents-client-4.3.2/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java httpcomponents-client-4.3.3/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java --- httpcomponents-client-4.3.2/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java 2014-01-15 18:33:46.000000000 +0000 +++ httpcomponents-client-4.3.3/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java 2014-02-21 22:32:03.000000000 +0000 @@ -27,6 +27,8 @@ package org.apache.http.entity.mime; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.content.AbstractContentBody; import org.apache.http.entity.mime.content.ContentBody; import org.apache.http.util.Args; @@ -88,13 +90,23 @@ } protected void generateContentType(final ContentBody body) { - final StringBuilder buffer = new StringBuilder(); - buffer.append(body.getMimeType()); // MimeType cannot be null - if (body.getCharset() != null) { // charset may legitimately be null - buffer.append("; charset="); - buffer.append(body.getCharset()); + final ContentType contentType; + if (body instanceof AbstractContentBody) { + contentType = ((AbstractContentBody) body).getContentType(); + } else { + contentType = null; + } + if (contentType != null) { + addField(MIME.CONTENT_TYPE, contentType.toString()); + } else { + final StringBuilder buffer = new StringBuilder(); + buffer.append(body.getMimeType()); // MimeType cannot be null + if (body.getCharset() != null) { // charset may legitimately be null + buffer.append("; charset="); + buffer.append(body.getCharset()); + } + addField(MIME.CONTENT_TYPE, buffer.toString()); } - addField(MIME.CONTENT_TYPE, buffer.toString()); } protected void generateTransferEncoding(final ContentBody body) { diff -Nru httpcomponents-client-4.3.2/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java httpcomponents-client-4.3.3/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java --- httpcomponents-client-4.3.2/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java 2014-01-15 18:33:45.000000000 +0000 +++ httpcomponents-client-4.3.3/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java 2014-02-21 22:32:02.000000000 +0000 @@ -100,6 +100,40 @@ } @Test + public void testMultipartFormCustomContentType() throws Exception { + final FormBodyPart p1 = new FormBodyPart( + "field1", + new StringBody("this stuff", ContentType.DEFAULT_TEXT)); + final FormBodyPart p2 = new FormBodyPart( + "field2", + new StringBody("that stuff", ContentType.parse("stuff/plain; param=value"))); + final HttpStrictMultipart multipart = new HttpStrictMultipart("form-data", null, "foo", + Arrays.asList(p1, p2)); + + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + multipart.writeTo(out); + out.close(); + + final String expected = + "--foo\r\n" + + "Content-Disposition: form-data; name=\"field1\"\r\n" + + "Content-Type: text/plain; charset=ISO-8859-1\r\n" + + "Content-Transfer-Encoding: 8bit\r\n" + + "\r\n" + + "this stuff\r\n" + + "--foo\r\n" + + "Content-Disposition: form-data; name=\"field2\"\r\n" + + "Content-Type: stuff/plain; param=value\r\n" + + "Content-Transfer-Encoding: 8bit\r\n" + + "\r\n" + + "that stuff\r\n" + + "--foo--\r\n"; + final String s = out.toString("US-ASCII"); + Assert.assertEquals(expected, s); + Assert.assertEquals(s.length(), multipart.getTotalLength()); + } + + @Test public void testMultipartFormBinaryParts() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); final Writer writer = new FileWriter(tmpfile); diff -Nru httpcomponents-client-4.3.2/pom.xml httpcomponents-client-4.3.3/pom.xml --- httpcomponents-client-4.3.2/pom.xml 2014-01-15 18:33:47.000000000 +0000 +++ httpcomponents-client-4.3.3/pom.xml 2014-02-21 22:32:06.000000000 +0000 @@ -33,7 +33,7 @@ 4.0.0 httpcomponents-client HttpComponents Client - 4.3.2 + 4.3.3 Apache HttpComponents Client is a library of components for building client side HTTP services http://hc.apache.org/httpcomponents-client 1999 @@ -58,13 +58,13 @@ - scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.2 - scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.2 - https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.2 + scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.3 + scm:svn:https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.3 + https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3.3 - 4.3.1 + 4.3.2 1.1.3 1.6 2.2.0 @@ -164,7 +164,6 @@ httpmime fluent-hc httpclient-cache - httpclient-osgi diff -Nru httpcomponents-client-4.3.2/RELEASE_NOTES.txt httpcomponents-client-4.3.3/RELEASE_NOTES.txt --- httpcomponents-client-4.3.2/RELEASE_NOTES.txt 2014-01-15 18:33:48.000000000 +0000 +++ httpcomponents-client-4.3.3/RELEASE_NOTES.txt 2014-02-21 22:31:05.000000000 +0000 @@ -1,7 +1,38 @@ +Release 4.3.3 +------------------- + +HttpClient 4.3.3 (GA) is a bug fix release that fixes a regression introduced by the previous +release causing a significant performance degradation in compressed content processing. + +Users of HttpClient 4.3 are encouraged to upgrade. + +Changelog: +------------------- + +* [HTTPCLIENT-1466] FileBodyPart#generateContentType() ignores custom ContentType values. + Contributed by Oleg Kalnichevski + +* [HTTPCLIENT-1453] Thread safety regression in PoolingHttpClientConnectionManager + #closeExpiredConnections that can lead to ConcurrentModificationException. + Contributed by Oleg Kalnichevski + +* [HTTPCLIENT-1461] fixed performance degradation in compressed content processing + introduced by HTTPCLIENT-1432. + Contributed by Oleg Kalnichevski + +* [HTTPCLIENT-1457] Incorrect handling of Windows (NT) credentials by + SystemDefaultCredentialsProvider. + Contributed by Oleg Kalnichevski + +* [HTTPCLIENT-1456] Request retrial after status 503 causes ClientProtocolException. + Contributed by Oleg Kalnichevski + + + Release 4.3.2 ------------------- -HttpClient 4.3.2 (GA) is a maintenance release that devliers a number of improvements +HttpClient 4.3.2 (GA) is a maintenance release that delivers a number of improvements as well as bug fixes for issues reported since 4.3.1 release. SNI support for Oracle JRE 1.7+ is being among the most notable improvements. diff -Nru httpcomponents-client-4.3.2/src/docbkx/caching.xml httpcomponents-client-4.3.3/src/docbkx/caching.xml --- httpcomponents-client-4.3.2/src/docbkx/caching.xml 2014-01-15 18:33:47.000000000 +0000 +++ httpcomponents-client-4.3.3/src/docbkx/caching.xml 2014-02-21 22:32:06.000000000 +0000 @@ -151,7 +151,7 @@ .setConnectTimeout(30000) .setSocketTimeout(30000) .build(); -CloseableHttpClient cachingClient = caching HttpClients.custom() +CloseableHttpClient cachingClient = CachingHttpClients.custom() .setCacheConfig(cacheConfig) .setDefaultRequestConfig(requestConfig) .build(); diff -Nru httpcomponents-client-4.3.2/src/docbkx/fundamentals.xml httpcomponents-client-4.3.3/src/docbkx/fundamentals.xml --- httpcomponents-client-4.3.2/src/docbkx/fundamentals.xml 2014-01-15 18:33:47.000000000 +0000 +++ httpcomponents-client-4.3.3/src/docbkx/fundamentals.xml 2014-02-21 22:32:06.000000000 +0000 @@ -394,7 +394,8 @@ FileEntity.