diff --git a/README.md b/README.md index e289fd8..a205911 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/buildfile b/buildfile index 4aac84f..a257e93 100644 --- a/buildfile +++ b/buildfile @@ -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 diff --git a/src/main/java/io/iron/ironmq/Client.java b/src/main/java/io/iron/ironmq/Client.java index b6880e2..9bb7752 100644 --- a/src/main/java/io/iron/ironmq/Client.java +++ b/src/main/java/io/iron/ironmq/Client.java @@ -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) {