imbajin commented on code in PR #113:
URL: 
https://github.com/apache/incubator-hugegraph-commons/pull/113#discussion_r1013976056


##########
hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java:
##########
@@ -396,17 +398,37 @@ private Pair<Builder, Entity<?>> buildRequest(
          * because Entity.json() method will reset "content encoding =
          * null" that has been set up by headers before.
          */
+        MediaType customContentType = parseCustomContentType(headers);
         Entity<?> entity;
         if (encoding == null) {
-            entity = Entity.json(object);
+            entity = Entity.entity(object, customContentType);
         } else {
-            Variant variant = new Variant(MediaType.APPLICATION_JSON_TYPE,
+            Variant variant = new Variant(customContentType,
                                           (String) null, encoding);
             entity = Entity.entity(object, variant);
         }
         return Pair.of(builder, entity);
     }
 
+    /**
+     * parse user custom content-type, returns MediaType.APPLICATION_JSON_TYPE 
default.
+     * @param headers
+     * @return
+     */
+    private MediaType parseCustomContentType(MultivaluedMap<String, Object> 
headers) {
+        String customContentType = null;
+        if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != 
null) {
+            Object contentTypeObj = headers.get("Content-Type");
+            if (contentTypeObj instanceof List) {
+                customContentType = ((List) contentTypeObj).get(0).toString();

Review Comment:
   After check the code, I found the `MultivaluedMap` will always return 
`List<V>`, so we should change the code logic early
   
   
![image](https://user-images.githubusercontent.com/17706099/199974642-f76509ce-6139-4cc3-b1e6-24756c0c6fb8.png)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to