Skip to content

Commit 914453d

Browse files
author
Stephane Landelle
committed
minor clean up
1 parent 8a67808 commit 914453d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/main/java/com/ning/http/client/RequestBuilderBase.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ private URI toURI(boolean encode) {
174174

175175
AsyncHttpProviderUtils.validateSupportedScheme(originalUri);
176176

177-
StringBuilder builder = new StringBuilder();
178-
builder.append(originalUri.getScheme()).append("://").append(originalUri.getRawAuthority());
177+
StringBuilder builder = new StringBuilder()//
178+
.append(originalUri.getScheme())//
179+
.append("://")//
180+
.append(originalUri.getRawAuthority());
179181
if (isNonEmpty(originalUri.getRawPath())) {
180182
builder.append(originalUri.getRawPath());
181183
} else {
@@ -630,8 +632,7 @@ public T setSignatureCalculator(SignatureCalculator signatureCalculator) {
630632
return derived.cast(this);
631633
}
632634

633-
public Request build() {
634-
635+
private void executeSignatureCalculator() {
635636
/* Let's first calculate and inject signature, before finalizing actual build
636637
* (order does not matter with current implementation but may in future)
637638
*/
@@ -644,7 +645,9 @@ public Request build() {
644645
}
645646
signatureCalculator.calculateAndAddSignature(url, request, this);
646647
}
647-
648+
}
649+
650+
private void computeRequestCharset() {
648651
try {
649652
final String contentType = request.headers.getFirstValue("Content-Type");
650653
if (contentType != null) {
@@ -658,6 +661,9 @@ public Request build() {
658661
} catch (Throwable e) {
659662
// NoOp -- we can't fix the Content-Type or charset from here
660663
}
664+
}
665+
666+
private void computeRequestLength() {
661667
if (request.length < 0 && request.streamData == null) {
662668
// can't concatenate content-length
663669
final String contentLength = request.headers.getFirstValue("Content-Length");
@@ -670,6 +676,12 @@ public Request build() {
670676
}
671677
}
672678
}
679+
}
680+
681+
public Request build() {
682+
executeSignatureCalculator();
683+
computeRequestCharset();
684+
computeRequestLength();
673685
return request;
674686
}
675687

0 commit comments

Comments
 (0)