mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Set the MIME type BEFORE the payload
When we set the payload, it is converted to bytes using the response's character set. Changing the MIME type later has no effect on the conversion to bytes, even though it does change the returned MIME type. This results in bytes that were encoded using one character set while the response reports a different character set. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=196258752
This commit is contained in:
parent
c007458e1a
commit
c25f765fc5
2 changed files with 2 additions and 1 deletions
|
@ -52,8 +52,8 @@ public class EppRequestHandler {
|
||||||
EppOutput eppOutput =
|
EppOutput eppOutput =
|
||||||
eppController.handleEppCommand(
|
eppController.handleEppCommand(
|
||||||
sessionMetadata, credentials, eppRequestSource, isDryRun, isSuperuser, inputXmlBytes);
|
sessionMetadata, credentials, eppRequestSource, isDryRun, isSuperuser, inputXmlBytes);
|
||||||
response.setPayload(new String(marshalWithLenientRetry(eppOutput), UTF_8));
|
|
||||||
response.setContentType(APPLICATION_EPP_XML);
|
response.setContentType(APPLICATION_EPP_XML);
|
||||||
|
response.setPayload(new String(marshalWithLenientRetry(eppOutput), UTF_8));
|
||||||
// Note that we always return 200 (OK) even if the EppController returns an error response.
|
// Note that we always return 200 (OK) even if the EppController returns an error response.
|
||||||
// This is because returning a non-OK HTTP status code will cause the proxy server to
|
// This is because returning a non-OK HTTP status code will cause the proxy server to
|
||||||
// silently close the connection without returning any data. The only time we will ever return
|
// silently close the connection without returning any data. The only time we will ever return
|
||||||
|
|
|
@ -60,6 +60,7 @@ public final class FakeResponse implements Response {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContentType(MediaType contentType) {
|
public void setContentType(MediaType contentType) {
|
||||||
|
checkArgument(payload.isEmpty(), "setContentType must be called before setPayload");
|
||||||
this.contentType = checkNotNull(contentType);
|
this.contentType = checkNotNull(contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue