Permalink
Browse files

#271 improving the support for Content-Type headers for different ty…

…pes of body
  • Loading branch information...
1 parent 990e841 commit e0dae63d662c8cbce8d9417f7387649ab5ad329c @jamesdbloom committed Oct 17, 2016
Showing with 1,631 additions and 662 deletions.
  1. +3 −8 mockserver-core/src/main/java/org/mockserver/client/netty/codec/MockServerRequestEncoder.java
  2. +3 −2 mockserver-core/src/main/java/org/mockserver/client/netty/codec/MockServerResponseDecoder.java
  3. +2 −0 mockserver-core/src/main/java/org/mockserver/client/serialization/ObjectMapperFactory.java
  4. +39 −4 ...ore/src/main/java/org/mockserver/client/serialization/deserializers/body/BodyDTODeserializer.java
  5. +3 −2 mockserver-core/src/main/java/org/mockserver/client/serialization/model/BinaryBodyDTO.java
  6. +7 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/BodyDTO.java
  7. +3 −8 mockserver-core/src/main/java/org/mockserver/client/serialization/model/JsonBodyDTO.java
  8. +1 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/JsonSchemaBodyDTO.java
  9. +1 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/ParameterBodyDTO.java
  10. +1 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/RegexBodyDTO.java
  11. +3 −8 mockserver-core/src/main/java/org/mockserver/client/serialization/model/StringBodyDTO.java
  12. +1 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/XPathBodyDTO.java
  13. +1 −1 mockserver-core/src/main/java/org/mockserver/client/serialization/model/XmlBodyDTO.java
  14. +29 −0 ...e/src/main/java/org/mockserver/client/serialization/serializers/body/BinaryBodyDTOSerializer.java
  15. +30 −0 ...core/src/main/java/org/mockserver/client/serialization/serializers/body/BinaryBodySerializer.java
  16. +2 −2 ...ore/src/main/java/org/mockserver/client/serialization/serializers/body/JsonBodyDTOSerializer.java
  17. +2 −2 ...r-core/src/main/java/org/mockserver/client/serialization/serializers/body/JsonBodySerializer.java
  18. +4 −4 ...e/src/main/java/org/mockserver/client/serialization/serializers/body/StringBodyDTOSerializer.java
  19. +4 −4 ...core/src/main/java/org/mockserver/client/serialization/serializers/body/StringBodySerializer.java
  20. +5 −1 ...core/src/main/java/org/mockserver/client/serialization/serializers/body/XmlBodyDTOSerializer.java
  21. +3 −0 ...er-core/src/main/java/org/mockserver/client/serialization/serializers/body/XmlBodySerializer.java
  22. +6 −4 mockserver-core/src/main/java/org/mockserver/mappers/ContentTypeMapper.java
  23. +8 −12 ...ver-core/src/main/java/org/mockserver/mappers/MockServerResponseToHttpServletResponseEncoder.java
  24. +10 −1 mockserver-core/src/main/java/org/mockserver/model/BinaryBody.java
  25. +14 −4 mockserver-core/src/main/java/org/mockserver/model/Body.java
  26. +21 −18 mockserver-core/src/main/java/org/mockserver/model/JsonBody.java
  27. +3 −6 mockserver-core/src/main/java/org/mockserver/model/JsonSchemaBody.java
  28. +2 −7 mockserver-core/src/main/java/org/mockserver/model/ParameterBody.java
  29. +1 −1 mockserver-core/src/main/java/org/mockserver/model/RegexBody.java
  30. +11 −19 mockserver-core/src/main/java/org/mockserver/model/StringBody.java
  31. +1 −1 mockserver-core/src/main/java/org/mockserver/model/XPathBody.java
  32. +40 −2 mockserver-core/src/main/java/org/mockserver/model/XmlBody.java
  33. +0 −1 mockserver-core/src/test/java/org/mockserver/client/netty/NettyHttpClientErrorHandlingTest.java
  34. +0 −1 mockserver-core/src/test/java/org/mockserver/client/netty/NettyHttpClientTest.java
  35. +30 −1 ...ore/src/test/java/org/mockserver/client/netty/codec/MockServerRequestEncoderBasicMappingTest.java
  36. +206 −11 ...core/src/test/java/org/mockserver/client/netty/codec/MockServerRequestEncoderContentTypeTest.java
  37. +3 −2 ...-core/src/test/java/org/mockserver/client/serialization/HttpRequestSerializerIntegrationTest.java
  38. +254 −19 ...src/test/java/org/mockserver/client/serialization/deserializers/body/BodyDTODeserializerTest.java
  39. +19 −6 mockserver-core/src/test/java/org/mockserver/client/serialization/model/JsonBodyDTOTest.java
  40. +17 −5 mockserver-core/src/test/java/org/mockserver/client/serialization/model/StringBodyDTOTest.java
  41. +39 −0 ...c/test/java/org/mockserver/client/serialization/serializers/body/BinaryBodyDTOSerializerTest.java
  42. +27 −0 .../src/test/java/org/mockserver/client/serialization/serializers/body/BinaryBodySerializerTest.java
  43. +8 −1 ...src/test/java/org/mockserver/client/serialization/serializers/body/JsonBodyDTOSerializerTest.java
  44. +8 −1 ...re/src/test/java/org/mockserver/client/serialization/serializers/body/JsonBodySerializerTest.java
  45. +5 −4 ...c/test/java/org/mockserver/client/serialization/serializers/body/StringBodyDTOSerializerTest.java
  46. +15 −2 .../src/test/java/org/mockserver/client/serialization/serializers/body/StringBodySerializerTest.java
  47. +13 −0 .../src/test/java/org/mockserver/client/serialization/serializers/body/XmlBodyDTOSerializerTest.java
  48. +21 −0 ...ore/src/test/java/org/mockserver/client/serialization/serializers/body/XmlBodySerializerTest.java
  49. +36 −3 ...st/java/org/mockserver/mappers/MockServerResponseToHttpServletResponseEncoderContentTypeTest.java
  50. +61 −4 mockserver-core/src/test/java/org/mockserver/model/BinaryBodyTest.java
  51. +31 −13 mockserver-core/src/test/java/org/mockserver/model/JsonBodyTest.java
  52. +54 −8 mockserver-core/src/test/java/org/mockserver/model/StringBodyTest.java
  53. +80 −2 mockserver-core/src/test/java/org/mockserver/model/XmlBodyTest.java
  54. +37 −148 ...-testing/src/main/java/org/mockserver/integration/server/AbstractClientServerIntegrationTest.java
  55. +2 −4 ...g/src/main/java/org/mockserver/integration/server/SameJVMAbstractClientServerIntegrationTest.java
  56. +33 −13 mockserver-netty/src/main/java/org/mockserver/codec/MockServerResponseEncoder.java
  57. +1 −2 mockserver-netty/src/main/java/org/mockserver/mockserver/MockServer.java
  58. +2 −41 mockserver-netty/src/main/java/org/mockserver/mockserver/MockServerHandler.java
  59. +2 −1 mockserver-netty/src/main/java/org/mockserver/mockserver/callback/server/WebSocketServerHandler.java
  60. +2 −19 mockserver-netty/src/main/java/org/mockserver/proxy/http/HttpProxyHandler.java
  61. +11 −5 mockserver-netty/src/test/java/org/mockserver/codec/MockServerResponseEncoderBasicMappingTest.java
  62. +141 −0 mockserver-netty/src/test/java/org/mockserver/codec/MockServerResponseEncoderContentLengthTest.java
  63. +192 −2 mockserver-netty/src/test/java/org/mockserver/codec/MockServerResponseEncoderContentTypeTest.java
  64. +1 −1 mockserver-netty/src/test/java/org/mockserver/codec/MockServerResponseEncoderCookieHeaderTest.java
  65. +2 −6 ...y/src/test/java/org/mockserver/integration/mockserver/AbstractMockServerNettyIntegrationTest.java
  66. +0 −8 mockserver-netty/src/test/java/org/mockserver/mockserver/MockServerHandlerConnectionOptionsTest.java
  67. +0 −187 mockserver-netty/src/test/java/org/mockserver/mockserver/MockServerHandlerContentTypeTest.java
  68. +0 −1 mockserver-netty/src/test/java/org/mockserver/mockserver/MockServerHandlerGeneralOperationsTest.java
  69. +4 −3 mockserver-proxy-war/src/main/java/org/mockserver/proxy/ProxyServlet.java
  70. +8 −7 mockserver-war/src/main/java/org/mockserver/server/MockServerServlet.java
  71. +2 −4 ...ver-war/src/test/java/org/mockserver/server/DeployableWARAbstractClientServerIntegrationTest.java
@@ -127,14 +127,9 @@ private void setHeader(OutboundHttpRequest httpRequest, FullHttpRequest request)
}
if (!request.headers().contains(CONTENT_TYPE)) {
- if (httpRequest.getBody() != null) {
- Charset bodyCharset = httpRequest.getBody().getCharset(null);
- String bodyContentType = httpRequest.getBody().getContentType();
- if (bodyCharset != null) {
- request.headers().set(CONTENT_TYPE, bodyContentType + "; charset=" + bodyCharset.name().toLowerCase());
- } else if (bodyContentType != null) {
- request.headers().set(CONTENT_TYPE, bodyContentType);
- }
+ if (httpRequest.getBody() != null
+ && httpRequest.getBody().getContentType() != null) {
+ request.headers().set(CONTENT_TYPE, httpRequest.getBody().getContentType());
}
}
}
@@ -3,7 +3,6 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.FullHttpResponse;
-import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.cookie.ClientCookieDecoder;
import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
import org.mockserver.mappers.ContentTypeMapper;
@@ -15,6 +14,8 @@
import java.util.List;
import java.util.Map;
+import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
+
/**
* @author jamesdbloom
*/
@@ -74,7 +75,7 @@ private void setBody(HttpResponse httpResponse, FullHttpResponse fullHttpRespons
byte[] bodyBytes = new byte[fullHttpResponse.content().readableBytes()];
fullHttpResponse.content().readBytes(bodyBytes);
if (bodyBytes.length > 0) {
- if (ContentTypeMapper.isBinary(fullHttpResponse.headers().get(HttpHeaders.Names.CONTENT_TYPE))) {
+ if (ContentTypeMapper.isBinary(fullHttpResponse.headers().get(CONTENT_TYPE))) {
httpResponse.withBody(new BinaryBody(bodyBytes));
} else {
Charset requestCharset = ContentTypeMapper.determineCharsetForMessage(fullHttpResponse);
@@ -68,6 +68,8 @@ private static ObjectMapper buildObjectMapper() {
addDeserializer(BodyDTO.class, new BodyDTODeserializer());
addSerializer(StringBodyDTO.class, new StringBodyDTOSerializer());
addSerializer(StringBody.class, new StringBodySerializer());
+ addSerializer(BinaryBodyDTO.class, new BinaryBodyDTOSerializer());
+ addSerializer(BinaryBody.class, new BinaryBodySerializer());
addSerializer(RegexBodyDTO.class, new RegexBodyDTOSerializer());
addSerializer(RegexBody.class, new RegexBodySerializer());
addSerializer(JsonBodyDTO.class, new JsonBodyDTOSerializer());
@@ -4,6 +4,7 @@
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.google.common.net.MediaType;
import org.mockserver.client.serialization.Base64Converter;
import org.mockserver.client.serialization.ObjectMapperFactory;
import org.mockserver.client.serialization.model.*;
@@ -14,6 +15,7 @@
import java.io.IOException;
import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -52,6 +54,7 @@ public BodyDTO deserialize(JsonParser jsonParser, DeserializationContext ctxt) t
String valueJsonValue = "";
Body.Type type = null;
boolean not = false;
+ MediaType contentType = null;
Charset charset = null;
MatchType matchType = JsonBody.DEFAULT_MATCH_TYPE;
List<Parameter> parameters = new ArrayList<Parameter>();
@@ -88,12 +91,22 @@ public BodyDTO deserialize(JsonParser jsonParser, DeserializationContext ctxt) t
logger.warn("Ignoring incorrect JsonBodyMatchType with value \"" + jsonParser.getText() + "\"");
}
}
+ if (jsonParser.getCurrentToken() == JsonToken.FIELD_NAME && jsonParser.getText().equalsIgnoreCase("contentType")) {
+ jsonParser.nextToken();
+ try {
+ contentType = MediaType.parse(jsonParser.getText());
+ } catch (IllegalArgumentException uce) {
+ logger.warn("Ignoring unsupported MediaType with value \"" + jsonParser.getText() + "\"");
+ }
+ }
if (jsonParser.getCurrentToken() == JsonToken.FIELD_NAME && jsonParser.getText().equalsIgnoreCase("charset")) {
jsonParser.nextToken();
try {
charset = Charset.forName(jsonParser.getText());
} catch (UnsupportedCharsetException uce) {
logger.warn("Ignoring unsupported Charset with value \"" + jsonParser.getText() + "\"");
+ } catch (IllegalCharsetNameException icne) {
+ logger.warn("Ignoring invalid Charset with value \"" + jsonParser.getText() + "\"");
}
}
if (jsonParser.getCurrentToken() == JsonToken.FIELD_NAME && containsIgnoreCase(jsonParser.getText(), "parameters", "value")) {
@@ -145,19 +158,41 @@ public BodyDTO deserialize(JsonParser jsonParser, DeserializationContext ctxt) t
if (type != null) {
switch (type) {
case STRING:
- return new StringBodyDTO(new StringBody(valueJsonValue, charset), not);
+ if (contentType != null) {
+ return new StringBodyDTO(new StringBody(valueJsonValue, contentType), not);
+ } else if (charset != null) {
+ return new StringBodyDTO(new StringBody(valueJsonValue, charset), not);
+ } else {
+ return new StringBodyDTO(new StringBody(valueJsonValue), not);
+ }
case REGEX:
return new RegexBodyDTO(new RegexBody(valueJsonValue), not);
case JSON:
- return new JsonBodyDTO(new JsonBody(valueJsonValue, charset, matchType), not);
+ if (contentType != null) {
+ return new JsonBodyDTO(new JsonBody(valueJsonValue, contentType, matchType), not);
+ } else if (charset != null) {
+ return new JsonBodyDTO(new JsonBody(valueJsonValue, charset, matchType), not);
+ } else {
+ return new JsonBodyDTO(new JsonBody(valueJsonValue, matchType), not);
+ }
case JSON_SCHEMA:
return new JsonSchemaBodyDTO(new JsonSchemaBody(valueJsonValue), not);
case XPATH:
return new XPathBodyDTO(new XPathBody(valueJsonValue), not);
case XML:
- return new XmlBodyDTO(new XmlBody(valueJsonValue), not);
+ if (contentType != null) {
+ return new XmlBodyDTO(new XmlBody(valueJsonValue, contentType), not);
+ } else if (charset != null) {
+ return new XmlBodyDTO(new XmlBody(valueJsonValue, charset), not);
+ } else {
+ return new XmlBodyDTO(new XmlBody(valueJsonValue), not);
+ }
case BINARY:
- return new BinaryBodyDTO(new BinaryBody(Base64Converter.base64StringToBytes(valueJsonValue)), not);
+ if (contentType != null) {
+ return new BinaryBodyDTO(new BinaryBody(Base64Converter.base64StringToBytes(valueJsonValue), contentType), not);
+ } else {
+ return new BinaryBodyDTO(new BinaryBody(Base64Converter.base64StringToBytes(valueJsonValue)), not);
+ }
case PARAMETERS:
return new ParameterBodyDTO(new ParameterBody(parameters), not);
}
@@ -1,5 +1,6 @@
package org.mockserver.client.serialization.model;
+import com.google.common.net.MediaType;
import org.mockserver.model.BinaryBody;
import javax.xml.bind.DatatypeConverter;
@@ -16,7 +17,7 @@ public BinaryBodyDTO(BinaryBody binaryBody) {
}
public BinaryBodyDTO(BinaryBody binaryBody, Boolean not) {
- super(binaryBody.getType(), not);
+ super(binaryBody.getType(), not, binaryBody.getContentType());
if (binaryBody.getValue() != null && binaryBody.getValue().length > 0) {
value = DatatypeConverter.printBase64Binary(binaryBody.getValue());
}
@@ -30,6 +31,6 @@ public String getValue() {
}
public BinaryBody buildObject() {
- return new BinaryBody(DatatypeConverter.parseBase64Binary(value));
+ return new BinaryBody(DatatypeConverter.parseBase64Binary(value), (contentType != null ? MediaType.parse(contentType) : null));
}
}
@@ -8,10 +8,12 @@
public abstract class BodyDTO extends NotDTO {
private Body.Type type;
+ protected String contentType;
- public BodyDTO(Body.Type type, Boolean not) {
+ public BodyDTO(Body.Type type, Boolean not, String contentType) {
super(not);
this.type = type;
+ this.contentType = contentType;
}
public BodyDTO() {
@@ -53,6 +55,10 @@ public static BodyDTO createDTO(Body body) {
return type;
}
+ public String getContentType() {
+ return contentType;
+ }
+
public abstract Body buildObject();
}
@@ -1,5 +1,6 @@
package org.mockserver.client.serialization.model;
+import com.google.common.net.MediaType;
import org.mockserver.matchers.MatchType;
import org.mockserver.model.Body;
import org.mockserver.model.JsonBody;
@@ -13,17 +14,15 @@
private String json;
private MatchType matchType;
- private Charset charset;
public JsonBodyDTO(JsonBody jsonBody) {
this(jsonBody, false);
}
public JsonBodyDTO(JsonBody jsonBody, Boolean not) {
- super(Body.Type.JSON, not);
+ super(Body.Type.JSON, not, jsonBody.getContentType());
this.json = jsonBody.getValue();
this.matchType = jsonBody.getMatchType();
- this.charset = jsonBody.getCharset();
}
protected JsonBodyDTO() {
@@ -37,11 +36,7 @@ public MatchType getMatchType() {
return matchType;
}
- public Charset getCharset() {
- return charset;
- }
-
public JsonBody buildObject() {
- return new JsonBody(getJson(), charset, matchType);
+ return new JsonBody(getJson(), (contentType != null ? MediaType.parse(contentType) : null), matchType);
}
}
@@ -15,7 +15,7 @@ public JsonSchemaBodyDTO(JsonSchemaBody jsonSchemaBody) {
}
public JsonSchemaBodyDTO(JsonSchemaBody jsonSchemaBody, Boolean not) {
- super(Body.Type.JSON_SCHEMA, not);
+ super(Body.Type.JSON_SCHEMA, not, jsonSchemaBody.getContentType());
this.jsonSchema = jsonSchemaBody.getValue();
}
@@ -19,7 +19,7 @@ public ParameterBodyDTO(ParameterBody parameterBody) {
}
public ParameterBodyDTO(ParameterBody parameterBody, Boolean not) {
- super(parameterBody.getType(), not);
+ super(parameterBody.getType(), not, parameterBody.getContentType());
parameters = Lists.transform(parameterBody.getValue(), new Function<Parameter, ParameterDTO>() {
public ParameterDTO apply(Parameter parameter) {
return new ParameterDTO(parameter);
@@ -15,7 +15,7 @@ public RegexBodyDTO(RegexBody regexBody) {
}
public RegexBodyDTO(RegexBody regexBody, Boolean not) {
- super(Body.Type.REGEX, not);
+ super(Body.Type.REGEX, not, regexBody.getContentType());
this.regex = regexBody.getValue();
}
@@ -1,5 +1,6 @@
package org.mockserver.client.serialization.model;
+import com.google.common.net.MediaType;
import org.mockserver.model.StringBody;
import java.nio.charset.Charset;
@@ -10,16 +11,14 @@
public class StringBodyDTO extends BodyDTO {
private String string;
- private Charset charset;
public StringBodyDTO(StringBody stringBody) {
this(stringBody, stringBody.getNot());
}
public StringBodyDTO(StringBody stringBody, Boolean not) {
- super(stringBody.getType(), not);
+ super(stringBody.getType(), not, stringBody.getContentType());
string = stringBody.getValue();
- charset = stringBody.getCharset();
}
protected StringBodyDTO() {
@@ -29,11 +28,7 @@ public String getString() {
return string;
}
- public Charset getCharset() {
- return charset;
- }
-
public StringBody buildObject() {
- return new StringBody(string, charset);
+ return new StringBody(string, (contentType != null ? MediaType.parse(contentType) : null));
}
}
@@ -15,7 +15,7 @@ public XPathBodyDTO(XPathBody xPathBody) {
}
public XPathBodyDTO(XPathBody xPathBody, Boolean not) {
- super(Body.Type.XPATH, not);
+ super(Body.Type.XPATH, not, xPathBody.getContentType());
this.xpath = xPathBody.getValue();
}
@@ -15,7 +15,7 @@ public XmlBodyDTO(XmlBody xmlBody) {
}
public XmlBodyDTO(XmlBody xmlBody, Boolean not) {
- super(Body.Type.XML, not);
+ super(Body.Type.XML, not, xmlBody.getContentType());
this.xml = xmlBody.getValue();
}
@@ -0,0 +1,29 @@
+package org.mockserver.client.serialization.serializers.body;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import org.mockserver.client.serialization.model.BinaryBodyDTO;
+
+import java.io.IOException;
+
+/**
+ * @author jamesdbloom
+ */
+public class BinaryBodyDTOSerializer extends StdSerializer<BinaryBodyDTO> {
+
+ public BinaryBodyDTOSerializer() {
+ super(BinaryBodyDTO.class);
+ }
+
+ @Override
+ public void serialize(BinaryBodyDTO binaryBodyDTO, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+ jgen.writeStartObject();
+ if (binaryBodyDTO.getContentType() != null) {
+ jgen.writeStringField("contentType", binaryBodyDTO.getContentType());
+ }
+ jgen.writeStringField("type", binaryBodyDTO.getType().name());
+ jgen.writeStringField("value", binaryBodyDTO.getValue());
+ jgen.writeEndObject();
+ }
+}
@@ -0,0 +1,30 @@
+package org.mockserver.client.serialization.serializers.body;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import org.mockserver.model.BinaryBody;
+import org.mockserver.model.XmlBody;
+
+import java.io.IOException;
+
+/**
+ * @author jamesdbloom
+ */
+public class BinaryBodySerializer extends StdSerializer<BinaryBody> {
+
+ public BinaryBodySerializer() {
+ super(BinaryBody.class);
+ }
+
+ @Override
+ public void serialize(BinaryBody binaryBody, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+ jgen.writeStartObject();
+ if (binaryBody.getContentType() != null) {
+ jgen.writeStringField("contentType", binaryBody.getContentType());
+ }
+ jgen.writeStringField("type", binaryBody.getType().name());
+ jgen.writeStringField("value", binaryBody.toString());
+ jgen.writeEndObject();
+ }
+}
@@ -24,8 +24,8 @@ public void serialize(JsonBodyDTO jsonBodyDTO, JsonGenerator jgen, SerializerPro
if (jsonBodyDTO.getNot() != null && jsonBodyDTO.getNot()) {
jgen.writeBooleanField("not", jsonBodyDTO.getNot());
}
- if (jsonBodyDTO.getCharset() != null && !jsonBodyDTO.getCharset().equals(ContentTypeMapper.DEFAULT_HTTP_CHARACTER_SET)) {
- jgen.writeStringField("charset", jsonBodyDTO.getCharset().name());
+ if (jsonBodyDTO.getContentType() != null && !jsonBodyDTO.getContentType().equals(JsonBody.DEFAULT_CONTENT_TYPE.toString())) {
+ jgen.writeStringField("contentType", jsonBodyDTO.getContentType());
}
jgen.writeStringField("type", jsonBodyDTO.getType().name());
jgen.writeStringField("json", jsonBodyDTO.getJson());
@@ -23,8 +23,8 @@ public void serialize(JsonBody jsonBody, JsonGenerator jgen, SerializerProvider
if (jsonBody.getNot() != null && jsonBody.getNot()) {
jgen.writeBooleanField("not", jsonBody.getNot());
}
- if (jsonBody.getCharset() != null && !jsonBody.getCharset().equals(ContentTypeMapper.DEFAULT_HTTP_CHARACTER_SET)) {
- jgen.writeStringField("charset", jsonBody.getCharset().name());
+ if (jsonBody.getContentType() != null && !jsonBody.getContentType().equals(JsonBody.DEFAULT_CONTENT_TYPE.toString())) {
+ jgen.writeStringField("contentType", jsonBody.getContentType());
}
jgen.writeStringField("type", jsonBody.getType().name());
jgen.writeStringField("json", jsonBody.getValue());
Oops, something went wrong.

0 comments on commit e0dae63

Please sign in to comment.