@@ -174,8 +174,10 @@ private URI toURI(boolean encode) {
174
174
175
175
AsyncHttpProviderUtils .validateSupportedScheme (originalUri );
176
176
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 ());
179
181
if (isNonEmpty (originalUri .getRawPath ())) {
180
182
builder .append (originalUri .getRawPath ());
181
183
} else {
@@ -630,8 +632,7 @@ public T setSignatureCalculator(SignatureCalculator signatureCalculator) {
630
632
return derived .cast (this );
631
633
}
632
634
633
- public Request build () {
634
-
635
+ private void executeSignatureCalculator () {
635
636
/* Let's first calculate and inject signature, before finalizing actual build
636
637
* (order does not matter with current implementation but may in future)
637
638
*/
@@ -644,7 +645,9 @@ public Request build() {
644
645
}
645
646
signatureCalculator .calculateAndAddSignature (url , request , this );
646
647
}
647
-
648
+ }
649
+
650
+ private void computeRequestCharset () {
648
651
try {
649
652
final String contentType = request .headers .getFirstValue ("Content-Type" );
650
653
if (contentType != null ) {
@@ -658,6 +661,9 @@ public Request build() {
658
661
} catch (Throwable e ) {
659
662
// NoOp -- we can't fix the Content-Type or charset from here
660
663
}
664
+ }
665
+
666
+ private void computeRequestLength () {
661
667
if (request .length < 0 && request .streamData == null ) {
662
668
// can't concatenate content-length
663
669
final String contentLength = request .headers .getFirstValue ("Content-Length" );
@@ -670,6 +676,12 @@ public Request build() {
670
676
}
671
677
}
672
678
}
679
+ }
680
+
681
+ public Request build () {
682
+ executeSignatureCalculator ();
683
+ computeRequestCharset ();
684
+ computeRequestLength ();
673
685
return request ;
674
686
}
675
687
0 commit comments