Updates ConfigData to use spring.cloud.config.media-type.

See gh-1715
This commit is contained in:
spencergibb
2020-10-09 21:34:35 -04:00
parent 5b3b51f45e
commit 2e80c9ca9d
3 changed files with 104 additions and 3 deletions

View File

@@ -55,7 +55,6 @@ import org.springframework.web.client.RestTemplate;
import static org.springframework.cloud.config.client.ConfigClientProperties.AUTHORIZATION;
import static org.springframework.cloud.config.client.ConfigClientProperties.STATE_HEADER;
import static org.springframework.cloud.config.client.ConfigClientProperties.TOKEN_HEADER;
import static org.springframework.cloud.config.environment.EnvironmentMediaType.V2_JSON;
public class ConfigServerConfigDataLoader implements ConfigDataLoader<ConfigServerConfigDataLocation>, Ordered {
@@ -226,6 +225,7 @@ public class ConfigServerConfigDataLoader implements ConfigDataLoader<ConfigServ
path = path + "/{label}";
}
ResponseEntity<Environment> response = null;
List<MediaType> acceptHeader = Collections.singletonList(MediaType.parseMediaType(properties.getMediaType()));
for (int i = 0; i < noOfUrls; i++) {
ConfigClientProperties.Credentials credentials = properties.getCredentials(i);
@@ -237,7 +237,7 @@ public class ConfigServerConfigDataLoader implements ConfigDataLoader<ConfigServ
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.parseMediaType(V2_JSON)));
headers.setAccept(acceptHeader);
addAuthorizationToken(properties, headers, username, password);
if (StringUtils.hasText(token)) {
headers.add(TOKEN_HEADER, token);

View File

@@ -228,6 +228,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
path = path + "/{label}";
}
ResponseEntity<Environment> response = null;
List<MediaType> acceptHeader = Collections.singletonList(MediaType.parseMediaType(properties.getMediaType()));
for (int i = 0; i < noOfUrls; i++) {
Credentials credentials = properties.getCredentials(i);
@@ -239,7 +240,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.parseMediaType(properties.getMediaType())));
headers.setAccept(acceptHeader);
addAuthorizationToken(properties, headers, username, password);
if (StringUtils.hasText(token)) {
headers.add(TOKEN_HEADER, token);