Skip to content

Commit

Permalink
Fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MNoeva authored and IvanBorislavovDimitrov committed Nov 4, 2024
1 parent 6ec2096 commit 77e1886
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ private Constants() {
public static final String GOOGLE_CLOUD_STORAGE = "google-cloud-storage";

public static final String RETRY_LIMIT_PROPERTY = "jdk.httpclient.auth.retrylimit";
public static final String AUTHORIZATION_HEADER = "Authorization";
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import static org.cloudfoundry.multiapps.controller.web.Constants.AUTHORIZATION_HEADER;

@Named
public class FilesApiServiceImpl implements FilesApiService {

Expand Down Expand Up @@ -418,11 +416,14 @@ private HttpResponse<InputStream> callRemoteEndpointWithRetry(HttpClient client,
var request = buildFetchFileRequest(decodedUrl);
LOGGER.debug(Messages.CALLING_REMOTE_MTAR_ENDPOINT, request.uri());
var response = client.send(request, BodyHandlers.ofInputStream());
if (response.statusCode() == 401) {
String errorMessage = MessageFormat.format(Messages.DEPLOY_FROM_URL_WRONG_CREDENTIALS, UriUtil.stripUserInfo(decodedUrl));
throw new SLException(errorMessage);
} else if (response.statusCode() / 100 != 2) {
if (response.statusCode() / 100 != 2) {
String error = readErrorBodyFromResponse(response);
LOGGER.error(error);
if (response.statusCode() == HttpStatus.UNAUTHORIZED.value()) {
String errorMessage = MessageFormat.format(Messages.DEPLOY_FROM_URL_WRONG_CREDENTIALS,
UriUtil.stripUserInfo(decodedUrl));
throw new SLException(errorMessage);
}
throw new SLException(MessageFormat.format(Messages.ERROR_FROM_REMOTE_MTAR_ENDPOINT, request.uri(), response.statusCode(),
error));
}
Expand Down Expand Up @@ -452,7 +453,7 @@ private HttpRequest buildFetchFileRequest(String decodedUrl) {
builder.uri(URI.create(decodedUrl.replace(userInfo + "@", "")));
String encodedAuth = Base64.getEncoder()
.encodeToString(userInfo.getBytes());
builder.header(AUTHORIZATION_HEADER, "Basic " + encodedAuth);
builder.header(HttpHeaders.AUTHORIZATION, "Basic " + encodedAuth);
} else {
builder.uri(uri);
}
Expand Down

0 comments on commit 77e1886

Please sign in to comment.