Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add helper to set Accept header to application/json

  • Loading branch information...
commit f68fab59dfba85b3ae5c6df71e9f894382f6d65f 1 parent e252208
@kevinsawicki authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/src/main/java/com/github/kevinsawicki/http/HttpRequest.java
View
11 lib/src/main/java/com/github/kevinsawicki/http/HttpRequest.java
@@ -217,6 +217,8 @@
private static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
+ private static final String CONTENT_TYPE_JSON = "application/json";
+
/**
* <p>
* Encodes and decodes to and from Base64 notation.
@@ -1723,6 +1725,15 @@ public HttpRequest accept(final String value) {
}
/**
+ * Set the 'Accept' header to 'application/json'
+ *
+ * @return this request
+ */
+ public HttpRequest acceptJson() {
+ return accept(CONTENT_TYPE_JSON);
+ }
+
+ /**
* Copy from input stream to output stream
*
* @param input
Please sign in to comment.
Something went wrong with that request. Please try again.