Permalink
Browse files

Moving to https & small cleanup

  • Loading branch information...
1 parent e31e97d commit 54df599a91ddb7fe3f313a411e6951883474e906 Andrew Kirilenko committed Jan 28, 2012
Showing with 12 additions and 6 deletions.
  1. +1 −1 README.md
  2. +1 −1 buildfile
  3. +10 −4 src/main/java/io/iron/ironmq/Client.java
View
@@ -18,7 +18,7 @@ The Basics
**Initialize** a client and get a queue object:
Client client = new Client("my project", "my token");
- Queue queue := client.queue("my_queue");
+ Queue queue = client.queue("my_queue");
**Push** a message on the queue:
View
@@ -1,7 +1,7 @@
repositories.remote << 'http://repo1.maven.org/maven2'
define 'ironmq' do
- project.version = "0.0.1"
+ project.version = "0.0.2"
test.with 'junit:junit:jar:4.10'
compile.with transitive('net.sf.json-lib:json-lib:jar:jdk15:2.4')
package :jar
@@ -14,8 +14,9 @@
* The Client class provides access to the IronMQ service.
*/
public class Client {
- static final private String proto = "http";
+ static final private String proto = "https";
static final private String host = "mq-aws-us-east-1.iron.io";
+ static final private int port = 443;
static final private String apiVersion = "1";
private String projectId;
@@ -57,14 +58,19 @@ JSONObject post(String endpoint, String body) throws IOException {
}
private JSONObject request(String method, String endpoint, String body) throws IOException {
- String path = "/" + apiVersion + "/projects/" + projectId + "/" + endpoint + "?oauth=" + token;
- URL url = new URL(proto, host, path);
+ String path = "/" + apiVersion + "/projects/" + projectId + "/" + endpoint;
+ URL url = new URL(proto, host, port, path);
+
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(method);
+ conn.setRequestProperty("Content-Type", "application/json");
+ conn.setRequestProperty("Authorization", "OAuth " + token);
+ conn.setRequestProperty("User-Agent", "IronMQ Java Client");
+
if (body != null) {
- conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
}
+
conn.connect();
if (body != null) {

0 comments on commit 54df599

Please sign in to comment.