Skip to content

Commit

Permalink
[BUG][Connector-V2][http] fix httpheader cover (apache#5446)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyyyyyssss authored and Zhouwen-CN committed Sep 11, 2023
1 parent 1c2b34b commit 895e6bb
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,17 @@ private void addHeaders(HttpRequestBase request, Map<String, String> headers) {
headers.forEach(request::addHeader);
}

private boolean checkAlreadyHaveContentType(HttpEntityEnclosingRequestBase request) {
if (request.getEntity() != null && request.getEntity().getContentType() != null) {
return HTTP.CONTENT_TYPE.equals(request.getEntity().getContentType().getName());
}
return false;
}

private void addBody(HttpEntityEnclosingRequestBase request, String body) {
if (checkAlreadyHaveContentType(request)) {
return;
}
request.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);

if (StringUtils.isBlank(body)) {
Expand Down

0 comments on commit 895e6bb

Please sign in to comment.