Polishing external contribution
This commit makes several changes to PR #24651. - Add byte[] getContentAsByteArray() on Resource. - Remove getContentAsString() from Resource, as it relied on the default charset which is not reliable. - Add getContentAsString() to EncodedResource, as a charset is provided through the constructor. See gh-24651
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -266,6 +267,16 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
|
||||
return this.encoded.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getContentAsByteArray() throws IOException {
|
||||
return this.encoded.getContentAsByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentAsString(Charset charset) throws IOException {
|
||||
return this.encoded.getContentAsString(charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getResponseHeaders() {
|
||||
HttpHeaders headers;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@@ -304,6 +305,16 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
return this.original.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getContentAsByteArray() throws IOException {
|
||||
return this.original.getContentAsByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentAsString(Charset charset) throws IOException {
|
||||
return this.original.getContentAsString(charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return this.original.getInputStream();
|
||||
|
||||
Reference in New Issue
Block a user