Skip to content

Commit 8525c44

Browse files
authored
Merge pull request #32 from tigoe/master
Added missing code block on JSON string bodies
2 parents 05348e3 + d8d8d7c commit 8525c44

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

examples/jsonpost/jsonpost.pde

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import http.requests.*;
22

33
public void setup()
44
{
5-
size(400,400);
6-
smooth();
5+
size(400, 400);
6+
smooth();
77

8-
PostRequest post = new PostRequest("http://httprocessing.heroku.com");
9-
post.addData("{\"on\":false}");
10-
post.send();
11-
System.out.println("Reponse Content: " + post.getContent());
12-
System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
8+
PostRequest post = new PostRequest("http://httprocessing.heroku.com");
9+
put.addHeader("Content-Type", "application/json");
10+
post.addData("{\"on\":false}");
11+
post.send();
12+
System.out.println("Reponse Content: " + post.getContent());
13+
System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
1314
}

examples/jsonput/jsonput.pde

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import http.requests.*;
22

33
public void setup()
44
{
5-
size(400,400);
6-
smooth();
7-
8-
PutRequest put = new PutRequest("http://httprocessing.heroku.com");
9-
put.addData("{\"on\":false}");
10-
put.send();
11-
System.out.println("Reponse Content: " + put.getContent());
12-
System.out.println("Reponse Content-Length Header: " + put.getHeader("Content-Length"));
5+
size(400, 400);
6+
smooth();
7+
8+
PutRequest put = new PutRequest("http://httprocessing.heroku.com");
9+
put.addHeader("Content-Type", "application/json");
10+
put.addData("{\"on\":false}");
11+
put.send();
12+
System.out.println("Reponse Content: " + put.getContent());
13+
System.out.println("Reponse Content-Length Header: " + put.getHeader("Content-Length"));
1314
}

src/http/requests/PostRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public void send()
113113
httpPost.setEntity(mentity);
114114
}
115115

116+
if (stringEntity != null) {
117+
httpPut.setEntity(stringEntity);
118+
}
119+
116120
Iterator<BasicNameValuePair> headerIterator = headerPairs.iterator();
117121
while (headerIterator.hasNext()) {
118122
BasicNameValuePair headerPair = headerIterator.next();

0 commit comments

Comments
 (0)