Fix Request/Response attributes, add more assertions in tests

This commit is contained in:
Oleg Zhurakousky
2023-03-08 13:54:18 +01:00
parent 2e1741c06e
commit 4e05229f65
4 changed files with 41 additions and 72 deletions

View File

@@ -24,6 +24,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -244,13 +245,13 @@ public class ProxyHttpServletRequest implements HttpServletRequest {
*/
@Nullable
public String getContentAsString() throws IllegalStateException, UnsupportedEncodingException {
Assert.state(this.characterEncoding != null, "Cannot get content as a String for a null character encoding. "
+ "Consider setting the characterEncoding in the request.");
// Assert.state(this.characterEncoding != null, "Cannot get content as a String for a null character encoding. "
// + "Consider setting the characterEncoding in the request.");
if (this.content == null) {
return null;
}
return new String(this.content, this.characterEncoding);
return new String(this.content, StandardCharsets.UTF_8);
}
@Override

View File

@@ -354,22 +354,22 @@ public class ProxyHttpServletResponse implements HttpServletResponse {
@Override
public void setHeader(String name, @Nullable String value) {
this.headers.set(name, name);
this.headers.set(name, value);
}
@Override
public void addHeader(String name, @Nullable String value) {
this.headers.add(name, name);
this.headers.add(name, value);
}
@Override
public void setIntHeader(String name, int value) {
this.headers.set(name, name);
this.headers.set(name, String.valueOf(value));
}
@Override
public void addIntHeader(String name, int value) {
this.headers.add(name, name);
this.headers.add(name, String.valueOf(value));
}
@Override