Skip to content

Commit

Permalink
JCURL-27 Response processed as JSON even if the user overrides the co…
Browse files Browse the repository at this point in the history
…ntent type
  • Loading branch information
ldrozdz committed Nov 29, 2018
1 parent 2722196 commit d6f6e7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<connection>scm:git:git://github.com/symphonyoss/jcurl.git</connection>
<developerConnection>scm:git:[email protected]:symphonyoss/jcurl.git</developerConnection>
<url>https://github.com/symphonyoss/jcurl</url>
<tag>jcurl-0.9.6</tag>
<tag>jcurl-0.9.12</tag>
</scm>

<developers>
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/org/symphonyoss/symphony/jcurl/JCurl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ public class Response {
private long timeTaken;
private String cipherSuite;
private String output;
private String contentType;
private String responseContentType;
private Certificate[] serverCertificates;
private Certificate[] clientCertificates;
private Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public void print() throws CertificateParsingException, IOException {
}

if (output != null) {
if ("application/json".equalsIgnoreCase(contentType)) {
if ("application/json".equalsIgnoreCase(contentType) && "application/json".equalsIgnoreCase(responseContentType)) {
printResponseJson();
} else {
System.err.println(output);
Expand Down Expand Up @@ -1317,8 +1317,8 @@ public String getTag(int index) {
*
* @return The MIME type of the response.
*/
public String getContentType() {
return contentType;
public String getResponseContentType() {
return responseContentType;
}

/**
Expand Down Expand Up @@ -1630,7 +1630,7 @@ private void processResponseHeaders(HttpURLConnection con, Response response) th
if ("Content-Type".equalsIgnoreCase(headerName)) {
String contentType = headerValue.get(0);
if (contentType != null) {
response.contentType = contentType.split(";")[0];
response.responseContentType = contentType.split(";")[0];
}
} else if ("Set-Cookie".equalsIgnoreCase(headerName)) {
for (String cookie : headerValue) {
Expand Down Expand Up @@ -1694,7 +1694,9 @@ private void processResponseOutput(HttpURLConnection con, Response response) thr
}

private void processResponseTags(Response response) throws IOException {
if (response.output != null && "application/json".equals(response.contentType)) {
if (response.output != null
&& "application/json".equalsIgnoreCase(this.contentType)
&& "application/json".equalsIgnoreCase(response.responseContentType)) {

for (Map.Entry<String, String> entry : tagMap.entrySet()) {
String name = entry.getKey();
Expand Down

0 comments on commit d6f6e7d

Please sign in to comment.