Skip to content

Commit d8c93b2

Browse files
committed
Drop unused request.getContentLength, close AsyncHttpClient#1138
1 parent 2165f80 commit d8c93b2

File tree

3 files changed

+0
-42
lines changed

3 files changed

+0
-42
lines changed

client/src/main/java/org/asynchttpclient/DefaultRequest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class DefaultRequest implements Request {
5151
private final List<Param> formParams;
5252
private final List<Part> bodyParts;
5353
private final String virtualHost;
54-
private final long contentLength;
5554
public final ProxyServer proxyServer;
5655
private final Realm realm;
5756
private final File file;
@@ -79,7 +78,6 @@ public DefaultRequest(String method,//
7978
List<Param> formParams,//
8079
List<Part> bodyParts,//
8180
String virtualHost,//
82-
long contentLength,//
8381
ProxyServer proxyServer,//
8482
Realm realm,//
8583
File file,//
@@ -104,7 +102,6 @@ public DefaultRequest(String method,//
104102
this.formParams = formParams;
105103
this.bodyParts = bodyParts;
106104
this.virtualHost = virtualHost;
107-
this.contentLength = contentLength;
108105
this.proxyServer = proxyServer;
109106
this.realm = realm;
110107
this.file = file;
@@ -196,11 +193,6 @@ public String getVirtualHost() {
196193
return virtualHost;
197194
}
198195

199-
@Override
200-
public long getContentLength() {
201-
return contentLength;
202-
}
203-
204196
@Override
205197
public ProxyServer getProxyServer() {
206198
return proxyServer;

client/src/main/java/org/asynchttpclient/Request.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ public interface Request {
119119
*/
120120
BodyGenerator getBodyGenerator();
121121

122-
/**
123-
* Return the current size of the content-lenght header based on the body's size.
124-
*
125-
* @return the current size of the content-lenght header based on the body's size.
126-
*/
127-
long getContentLength();
128-
129122
/**
130123
* Return the current form parameters.
131124
*

client/src/main/java/org/asynchttpclient/RequestBuilderBase.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public abstract class RequestBuilderBase<T extends RequestBuilderBase<T>> {
8080
protected List<Param> formParams;
8181
protected List<Part> bodyParts;
8282
protected String virtualHost;
83-
protected long contentLength = -1;
8483
protected ProxyServer proxyServer;
8584
protected Realm realm;
8685
protected File file;
@@ -129,7 +128,6 @@ protected RequestBuilderBase(Request prototype, boolean disableUrlEncoding, bool
129128
this.bodyParts = new ArrayList<>(prototype.getBodyParts());
130129
}
131130
this.virtualHost = prototype.getVirtualHost();
132-
this.contentLength = prototype.getContentLength();
133131
this.proxyServer = prototype.getProxyServer();
134132
this.realm = prototype.getRealm();
135133
this.file = prototype.getFile();
@@ -204,11 +202,6 @@ public T setHeaders(Map<String, Collection<String>> headers) {
204202
return asDerivedType();
205203
}
206204

207-
public T setContentLength(int contentLength) {
208-
this.contentLength = contentLength;
209-
return asDerivedType();
210-
}
211-
212205
private void lazyInitCookies() {
213206
if (this.cookies == null)
214207
this.cookies = new ArrayList<>(3);
@@ -267,7 +260,6 @@ public void resetNonMultipartData() {
267260
this.stringData = null;
268261
this.streamData = null;
269262
this.bodyGenerator = null;
270-
this.contentLength = -1;
271263
}
272264

273265
public void resetMultipartData() {
@@ -472,7 +464,6 @@ private RequestBuilderBase<?> executeSignatureCalculator() {
472464
rb.streamData = this.streamData;
473465
rb.bodyGenerator = this.bodyGenerator;
474466
rb.virtualHost = this.virtualHost;
475-
rb.contentLength = this.contentLength;
476467
rb.proxyServer = this.proxyServer;
477468
rb.realm = this.realm;
478469
rb.file = this.file;
@@ -508,22 +499,6 @@ private Charset computeCharset() {
508499
return this.charset;
509500
}
510501

511-
private long computeRequestContentLength() {
512-
if (this.contentLength < 0 && this.streamData == null) {
513-
// can't concatenate content-length
514-
final String contentLength = this.headers.get(HttpHeaders.Names.CONTENT_LENGTH);
515-
516-
if (contentLength != null) {
517-
try {
518-
return Long.parseLong(contentLength);
519-
} catch (NumberFormatException e) {
520-
// NoOp -- we won't specify length so it will be chunked?
521-
}
522-
}
523-
}
524-
return this.contentLength;
525-
}
526-
527502
private Uri computeUri() {
528503

529504
Uri tempUri = this.uri;
@@ -541,7 +516,6 @@ public Request build() {
541516
RequestBuilderBase<?> rb = executeSignatureCalculator();
542517
Uri finalUri = rb.computeUri();
543518
Charset finalCharset = rb.computeCharset();
544-
long finalContentLength = rb.computeRequestContentLength();
545519

546520
// make copies of mutable internal collections
547521
List<Cookie> cookiesCopy = rb.cookies == null ? Collections.emptyList() : new ArrayList<>(rb.cookies);
@@ -563,7 +537,6 @@ public Request build() {
563537
formParamsCopy,//
564538
bodyPartsCopy,//
565539
rb.virtualHost,//
566-
finalContentLength,//
567540
rb.proxyServer,//
568541
rb.realm,//
569542
rb.file,//

0 commit comments

Comments
 (0)