Skip to content

Commit

Permalink
Moving to https & small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iced committed Jan 28, 2012
1 parent e31e97d commit 54df599
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -18,7 +18,7 @@ The Basics
**Initialize** a client and get a queue object: **Initialize** a client and get a queue object:


Client client = new Client("my project", "my token"); 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: **Push** a message on the queue:


Expand Down
2 changes: 1 addition & 1 deletion buildfile
@@ -1,7 +1,7 @@
repositories.remote << 'http://repo1.maven.org/maven2' repositories.remote << 'http://repo1.maven.org/maven2'


define 'ironmq' do define 'ironmq' do
project.version = "0.0.1" project.version = "0.0.2"
test.with 'junit:junit:jar:4.10' test.with 'junit:junit:jar:4.10'
compile.with transitive('net.sf.json-lib:json-lib:jar:jdk15:2.4') compile.with transitive('net.sf.json-lib:json-lib:jar:jdk15:2.4')
package :jar package :jar
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/io/iron/ironmq/Client.java
Expand Up @@ -14,8 +14,9 @@
* The Client class provides access to the IronMQ service. * The Client class provides access to the IronMQ service.
*/ */
public class Client { 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 String host = "mq-aws-us-east-1.iron.io";
static final private int port = 443;
static final private String apiVersion = "1"; static final private String apiVersion = "1";


private String projectId; private String projectId;
Expand Down Expand Up @@ -57,14 +58,19 @@ JSONObject post(String endpoint, String body) throws IOException {
} }


private JSONObject request(String method, 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; String path = "/" + apiVersion + "/projects/" + projectId + "/" + endpoint;
URL url = new URL(proto, host, path); URL url = new URL(proto, host, port, path);

HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(method); conn.setRequestMethod(method);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "OAuth " + token);
conn.setRequestProperty("User-Agent", "IronMQ Java Client");

if (body != null) { if (body != null) {
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true); conn.setDoOutput(true);
} }

conn.connect(); conn.connect();


if (body != null) { if (body != null) {
Expand Down

0 comments on commit 54df599

Please sign in to comment.