@@ -96,16 +96,16 @@ public abstract class AbstractBceClient {
96
96
* The constructor will extract serviceId from the class name automatically.
97
97
* And if there is no endpoint specified in the client configuration, the constructor will create a default one.
98
98
*
99
- * @param config the client configuration. The constructor makes a copy of this parameter so that it is
100
- * safe to change the configuration after then.
101
- * @param responseHandlers a list of handlers for processing HTTP responses from services. See
102
- * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])}
99
+ * @param config the client configuration. The constructor makes a copy of this parameter so that it is
100
+ * safe to change the configuration after then.
101
+ * @param responseHandlers a list of handlers for processing HTTP responses from services. See
102
+ * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])}
103
103
* @param isHttpAsyncPutEnabled whether or not PUT method use Async manner.
104
- * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients.
104
+ * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients.
105
105
* @throws IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI.
106
106
*/
107
107
public AbstractBceClient (BceClientConfiguration config , HttpResponseHandler [] responseHandlers ,
108
- boolean isHttpAsyncPutEnabled ) {
108
+ boolean isHttpAsyncPutEnabled ) {
109
109
this .serviceId = this .computeServiceId ();
110
110
this .config = config ;
111
111
this .endpoint = this .computeEndpoint ();
@@ -116,11 +116,11 @@ public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] re
116
116
/**
117
117
* Equivalent to AbstractBceClient(config, responseHandlers, false)
118
118
*
119
- * @param config the client configuration. The constructor makes a copy of this parameter so that it is
120
- * safe to change the configuration after then.
119
+ * @param config the client configuration. The constructor makes a copy of this parameter so that it is
120
+ * safe to change the configuration after then.
121
121
* @param responseHandlers a list of handlers for processing HTTP responses from services. See
122
- * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])}
123
- * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients.
122
+ * {@link com.baidubce.http.BceHttpClient#execute(InternalRequest, Class, HttpResponseHandler[])}
123
+ * @throws IllegalStateException if the class name does not follow the naming convention for BCE clients.
124
124
* @throws IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI.
125
125
*/
126
126
public AbstractBceClient (BceClientConfiguration config , HttpResponseHandler [] responseHandlers ) {
@@ -178,9 +178,9 @@ public void shutdown() {
178
178
* <p>
179
179
* This method will add "Content-Type" and "Date" to headers with default values if not present.
180
180
*
181
- * @param request the request to build up the HTTP request.
181
+ * @param request the request to build up the HTTP request.
182
182
* @param responseClass the response class.
183
- * @param <T> the type of response
183
+ * @param <T> the type of response
184
184
* @return the final response object.
185
185
*/
186
186
protected <T extends AbstractBceResponse > T invokeHttpClient (InternalRequest request , Class <T > responseClass ) {
@@ -276,7 +276,7 @@ public URI getBktVirEndpoint(String bucketName) {
276
276
277
277
/**
278
278
* BOS
279
- *
279
+ * <p>
280
280
* Returns the bucket virtual hosting service endpoint.
281
281
* <p>
282
282
* The endpoint will be in the form of "http(s)://<bucket>[.<Region>].bcebos.com".
@@ -289,15 +289,17 @@ public void computeBktVirEndpoint(String bucketName) {
289
289
return ;
290
290
}
291
291
String host = this .endpoint .getHost ();
292
+ String protocol = this .endpoint .getScheme ();
293
+
292
294
String uri = null ;
293
- if (!host .contains ("bcebos.com" )) {
295
+ if (!host .contains ("bcebos.com" ) && ! host . contains ( "baidu-int.com" )) {
294
296
// this means host is diy, and should not compute virtual host
295
297
return ;
296
298
}
297
299
if (host .startsWith (bucketName ) && host .split ("\\ ." ).length >= 4 ) {
298
- uri = this . config . getProtocol (). toString (). toLowerCase () + "://" + host ;
300
+ uri = protocol + "://" + host ;
299
301
} else {
300
- uri = this . config . getProtocol (). toString (). toLowerCase () + "://" + bucketName + '.' + host ;
302
+ uri = protocol + "://" + bucketName + '.' + host ;
301
303
}
302
304
try {
303
305
if (uri != null ) {
0 commit comments