Skip to content

Commit

Permalink
Version Bump v2.3.0: Automatically add Content-Type: application/json…
Browse files Browse the repository at this point in the history
… when there is a request body
  • Loading branch information
thinkingserious committed Jun 11, 2016
1 parent 838da76 commit 01abf47
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

## [2.3.0] - 2016-06-10
### Added
- Automatically add Content-Type: application/json when there is a request body

## [2.2.1] - 2016-06-08
### Fixed
- Set client properly when testing
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ source ./sendgrid.env
```bash
./gradlew build
cd examples
javac -classpath ./commons-logging-1.2.jar:./httpcore-4.4.4.jar:./httpclient-4.5.2.jar:./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:../repo/com/sendgrid/2.2.0/sendgrid-java-http-client-2.2.1-jar.jar:. Example.java && java -classpath ./commons-logging-1.2.jar:./httpcore-4.4.4.jar:./httpclient-4.5.2.jar:./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:../repo/com/sendgrid/2.2.0/sendgrid-java-http-client-2.2.1-jar.jar:. Example
javac -classpath ./commons-logging-1.2.jar:./httpcore-4.4.4.jar:./httpclient-4.5.2.jar:./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:../repo/com/sendgrid/2.3.0/sendgrid-java-http-client-2.3.0-jar.jar:. Example.java && java -classpath ./commons-logging-1.2.jar:./httpcore-4.4.4.jar:./httpclient-4.5.2.jar:./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:../repo/com/sendgrid/2.3.0/sendgrid-java-http-client-2.3.0-jar.jar:. Example
```

<a name="understanding_the_codebase"></a>
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All updates to this project is documented in our [CHANGELOG](https://github.com/
...
dependencies {
...
compile 'com.sendgrid:java-http-client:2.2.1'
compile 'com.sendgrid:java-http-client:2.3.0'
}
repositories {
Expand All @@ -31,15 +31,15 @@ repositories {
<dependency>
<groupId>com.sendgrid</groupId>
<artifactId>java-http-client</artifactId>
<version>2.2.1</version>
<version>2.3.0</version>
</dependency>
```

`mvn install`

## Fat Jar

[Download](http://repo1.maven.org/maven2/com/sendgrid/java-http-client/2.2.1/java-http-client-2.2.1-jar.jar)
[Download](http://repo1.maven.org/maven2/com/sendgrid/java-http-client/2.3.0/java-http-client-2.3.0-jar.jar)

## Dependencies

Expand Down Expand Up @@ -74,8 +74,7 @@ try {

```java
Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY"));
requestHeaders.put("Content-Type", "application/json");
requestHeaders.put("Authorization", "Bearer YOUR_API_KEY");
request.headers = requestHeaders;
Map<String,String> queryParams = new HashMap<String, String>();
queryParams.put("limit", "100");
Expand Down Expand Up @@ -113,7 +112,7 @@ source ./sendgrid.env
```bash
mvn package
cd examples
javac -classpath ./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:/{path_to}/java-http-client-2.2.1-jar.jar:. Example.java && java -classpath ./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:/{path_to}/java-http-client-2.2.1-jar.jar:. Example
javac -classpath ./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:/{path_to}/java-http-client-2.3.0-jar.jar:. Example.java && java -classpath ./jackson-databind-2.7.3.jar:./jackson-annotations-2.7.0.jar:./jackson-core-2.7.3.jar:/{path_to}/java-http-client-2.3.0-jar.jar:. Example
```

## Roadmap
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'maven'
apply plugin: 'signing'

group = 'com.sendgrid'
version = '2.2.1'
version = '2.3.0'
ext.packaging = 'jar'

allprojects {
Expand Down
1 change: 0 additions & 1 deletion examples/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public static void main(String[] args) throws IOException {
request.baseUri = "api.sendgrid.com";
Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY"));
requestHeaders.put("Content-Type", "application/json");
request.headers = requestHeaders;

Response response = new Response();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<packaging>jar</packaging>
<name>A simple HTTP client</name>
<description>HTTP REST client, simplified for Java</description>
<version>2.1.0</version>
<version>2.3.0</version>
<url>https://github.com/sendgrid/java-http-client</url>
<licenses>
<license>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/sendgrid/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ public Response post(Request request) throws URISyntaxException, IOException {

try {
httpPost.setEntity(new StringEntity(request.body));
if (request.body != "") {
httpPost.setHeader("Content-Type", "application/json");
}
} catch (IOException ex) {
throw ex;
}
Expand Down Expand Up @@ -251,6 +254,9 @@ public Response patch(Request request) throws URISyntaxException, IOException {

try {
httpPatch.setEntity(new StringEntity(request.body));
if (request.body != "") {
httpPatch.setHeader("Content-Type", "application/json");
}
} catch (IOException ex) {
throw ex;
}
Expand Down Expand Up @@ -295,6 +301,9 @@ public Response put(Request request) throws URISyntaxException, IOException {

try {
httpPut.setEntity(new StringEntity(request.body));
if (request.body != "") {
httpPut.setHeader("Content-Type", "application/json");
}
} catch (IOException ex) {
throw ex;
}
Expand Down Expand Up @@ -338,6 +347,9 @@ public Response delete(Request request) throws URISyntaxException, IOException {

try {
httpDelete.setEntity(new StringEntity(request.body));
if (request.body != "") {
httpDelete.setHeader("Content-Type", "application/json");
}
} catch (IOException ex) {
throw ex;
}
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/sendgrid/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public void testMethod(Method method, int statusCode) {
request.endpoint = "/test";
Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer XXXX");
requestHeaders.put("Content-Type", "application/json");
request.headers = requestHeaders;
Client client = new Client(httpClient);
testResponse = client.get(request);
Expand Down

0 comments on commit 01abf47

Please sign in to comment.