Skip to content

Commit

Permalink
Merge pull request #23 from paour/patch-1
Browse files Browse the repository at this point in the history
Avoid duplicate Content-Type header
  • Loading branch information
mrmike committed Sep 20, 2016
2 parents a801879 + 74d4d57 commit c01db24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ok2curl/src/main/java/com/moczul/ok2curl/CurlBuilder.java
Expand Up @@ -22,6 +22,7 @@ public class CurlBuilder {
private static final String FORMAT_HEADER = "-H \"%1$s:%2$s\"";
private static final String FORMAT_METHOD = "-X %1$s";
private static final String FORMAT_BODY = "-d '%1$s'";
private static final String CONTENT_TYPE = "Content-Type";

private final String url;
private String method;
Expand Down Expand Up @@ -96,8 +97,8 @@ public String build() {
parts.add(headerPart);
}

if (contentType != null) {
parts.add(String.format(FORMAT_HEADER, "Content-Type", contentType));
if (contentType != null && !headers.containsKey(CONTENT_TYPE)) {
parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType));
}

if (body != null) {
Expand Down

0 comments on commit c01db24

Please sign in to comment.