Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions 6 src/targets/java/asynchttp.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module.exports = function (source, options) {

// var methods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT' ]

code.push('Dsl.asyncHttpClient()')
code.push('AsyncHttpClient client = new DefaultAsyncHttpClient();')

code.push(1, '.prepare%s%s("%s")', source.method.slice(0, 1).toUpperCase(), source.method.slice(1).toLowerCase(), source.fullUrl)
code.push(`client.prepare${source.method[0].toUpperCase()}${source.method.substring(1).toLowerCase()}("${source.fullUrl}")`)

// Add headers, including the cookies
var headers = Object.keys(source.allHeaders)
Expand All @@ -43,6 +43,8 @@ module.exports = function (source, options) {
code.push(1, '.toCompletableFuture()')
code.push(1, '.thenAccept(System.out::println)')
code.push(1, '.join();')
code.blank()
code.push('client.close();')

return code.join()
}
Expand Down
1 change: 1 addition & 0 deletions 1 src/targets/java/okhttp.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = function (source, options) {
.blank()
.push('Response response = client.newCall(request).execute();')

code.push(1, "System.out.println(response.body().string());")
return code.join()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "application/x-www-form-urlencoded")
.setBody("foo=bar&hello=world")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/application-json.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "application/json")
.setBody("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/cookies.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("cookie", "foo=bar; bar=baz")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/custom-method.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Dsl.asyncHttpClient()
.preparePropfind("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePropfind("http://mockbin.com/har")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/full.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
.setHeader("cookie", "foo=bar; bar=baz")
.setHeader("accept", "application/json")
.setHeader("content-type", "application/x-www-form-urlencoded")
Expand All @@ -8,3 +8,5 @@
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/headers.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.prepareGet("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepareGet("http://mockbin.com/har")
.setHeader("accept", "application/json")
.setHeader("x-foo", "Bar")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/https.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Dsl.asyncHttpClient()
.prepareGet("https://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepareGet("https://mockbin.com/har")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/jsonObj-multiline.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "application/json")
.setBody("{\n \"foo\": \"bar\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/jsonObj-null-value.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "application/json")
.setBody("{\"foo\":null}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/multipart-data.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/multipart-file.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/multipart-form-data.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/query.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Dsl.asyncHttpClient()
.prepareGet("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepareGet("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/short.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Dsl.asyncHttpClient()
.prepareGet("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepareGet("http://mockbin.com/har")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
6 changes: 4 additions & 2 deletions 6 test/fixtures/output/java/asynchttp/text-plain.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Dsl.asyncHttpClient()
.preparePost("http://mockbin.com/har")
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.preparePost("http://mockbin.com/har")
.setHeader("content-type", "text/plain")
.setBody("Hello World")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();

client.close();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.