Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.commons.collections.MapUtils;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.ExecutorUtil;
import jakarta.ws.rs.client.Client;
Expand Down Expand Up @@ -396,17 +398,35 @@ 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
*/
public static MediaType parseCustomContentType(MultivaluedMap<String, Object> headers) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe private static should be better, but it's not a big problem

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will fix this case in next PR

String customContentType = null;
if (MapUtils.isNotEmpty(headers) && headers.get("Content-Type") != null) {
Object contentTypeObj = headers.get("Content-Type");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems we don't need Object here, just use List<?>

if (contentTypeObj instanceof List) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here the judge is redundant, change it to xx != null, I address them in PR #115

customContentType = ((List<?>) contentTypeObj).get(0).toString();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the contentTypeObj possible to be empty

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will happens, but i think no one will write code like this:
headers.put("Content-Type", LIsts.newArrayList());

i will fix this case in next PR

}
return MediaType.valueOf(customContentType);
}
return MediaType.APPLICATION_JSON_TYPE;
}

private static void configConnectionManager(String url, ClientConfig conf) {
/*
* Using httpclient with connection pooling, and configuring the
Expand Down