summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
index 5a53490eed..281154fb1a 100644
--- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
+++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
@@ -323,8 +323,17 @@ public class HttpClientConnection implements HttpConnection {
}
public int getContentLength() {
- return Integer.parseInt(resp.getFirstHeader("content-length") //$NON-NLS-1$
- .getValue());
+ Header contentLength = resp.getFirstHeader("content-length"); //$NON-NLS-1$
+ if (contentLength == null) {
+ return -1;
+ }
+
+ try {
+ int l = Integer.parseInt(contentLength.getValue());
+ return l < 0 ? -1 : l;
+ } catch (NumberFormatException e) {
+ return -1;
+ }
}
public void setInstanceFollowRedirects(boolean followRedirects) {