{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Sttp\n", "A minimal setup of sttp" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", "\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36msttp.client.quick.{quickRequest, UriContext, backend}\n", "\u001b[39m\n", "\u001b[36mres0_2\u001b[39m: \u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32mpackage\u001b[39m.\u001b[32mIdentity\u001b[39m[\u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32mResponse\u001b[39m[\u001b[32mString\u001b[39m]] = \u001b[33mResponse\u001b[39m(\n", " \u001b[32m\"\"\"{\n", " \"origin\": \"34.68.237.200, 34.68.237.200\"\n", "}\n", "\"\"\"\u001b[39m,\n", " 200,\n", " \u001b[32m\"OK\"\u001b[39m,\n", " \u001b[33mVector\u001b[39m(\n", " Server: nginx,\n", " Access-Control-Allow-Origin: *,\n", " X-Content-Type-Options: nosniff,\n", " Connection: keep-alive,\n", " Date: Sat, 23 Nov 2019 13:44:50 GMT,\n", " X-Frame-Options: DENY,\n", " Referrer-Policy: no-referrer-when-downgrade,\n", " Access-Control-Allow-Credentials: true,\n", " Content-Encoding: gzip,\n", " Content-Length: 56,\n", " X-XSS-Protection: 1; mode=block,\n", " Content-Type: application/json\n", " ),\n", " \u001b[33mList\u001b[39m()\n", ")" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import $ivy.`com.softwaremill.sttp.client::core:2.0.0-RC2`\n", "import sttp.client.quick.{quickRequest, UriContext, backend}\n", "quickRequest.get(uri\"http://httpbin.org/ip\").send()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Async sttp\n", "Use the async http client backend of sttp, which uses the netty behind the scenes." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", "\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36msttp.client.asynchttpclient.monix._\n", "\n", "\u001b[39m\n", "\u001b[36msttpBackend\u001b[39m: \u001b[32mmonix\u001b[39m.\u001b[32meval\u001b[39m.\u001b[32mTask\u001b[39m[\u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32mSttpBackend\u001b[39m[\u001b[32mmonix\u001b[39m.\u001b[32meval\u001b[39m.\u001b[32mTask\u001b[39m, \u001b[32mmonix\u001b[39m.\u001b[32mreactive\u001b[39m.\u001b[32mObservable\u001b[39m[\u001b[32mjava\u001b[39m.\u001b[32mnio\u001b[39m.\u001b[32mByteBuffer\u001b[39m], \u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32masynchttpclient\u001b[39m.\u001b[32mWebSocketHandler\u001b[39m]] = \u001b[33mEval\u001b[39m(\n", " sttp.client.asynchttpclient.monix.AsyncHttpClientMonixBackend$$$Lambda$3137/25163081@756ca83b\n", ")\n", "\u001b[32mimport \u001b[39m\u001b[36msttp.client.basicRequest\n", "\n", "\u001b[39m\n", "\u001b[36mr\u001b[39m: \u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32mpackage\u001b[39m.\u001b[32mRequest\u001b[39m[\u001b[32mEither\u001b[39m[\u001b[32mString\u001b[39m, \u001b[32mString\u001b[39m], \u001b[32mNothing\u001b[39m] = \u001b[33mRequestT\u001b[39m(\n", " \u001b[33mMethod\u001b[39m(\u001b[32m\"GET\"\u001b[39m),\n", " \u001b[33mUri\u001b[39m(\n", " \u001b[32m\"http\"\u001b[39m,\n", " \u001b[32mNone\u001b[39m,\n", " \u001b[33mSegment\u001b[39m(\n", " \u001b[32m\"httpbin.org\"\u001b[39m,\n", " sttp.model.Uri$HostEncoding$$$Lambda$2773/926400242@3fc232d2\n", " ),\n", " \u001b[32mNone\u001b[39m,\n", " \u001b[33mList\u001b[39m(\n", " \u001b[33mSegment\u001b[39m(\n", " \u001b[32m\"ip\"\u001b[39m,\n", " sttp.model.Uri$PathSegmentEncoding$$$Lambda$2788/455310151@4e33d01a\n", " )\n", " ),\n", " \u001b[33mVector\u001b[39m(),\n", " \u001b[32mNone\u001b[39m\n", " ),\n", " NoBody,\n", " \u001b[33mVector\u001b[39m(Accept-Encoding: gzip, deflate),\n", " \u001b[33mMappedResponseAs\u001b[39m(\n", " ResponseAsByteArray,\n", " sttp.client.MappedResponseAs$$Lambda$2766/571660107@3981f21\n", " ),\n", " \u001b[33mRequestOptions\u001b[39m(true, 1 minute, \u001b[32m32\u001b[39m, false),\n", " \u001b[33mMap\u001b[39m()\n", ")" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import $ivy.`com.softwaremill.sttp.client::async-http-client-backend-monix:2.0.0-RC2`\n", "import sttp.client.asynchttpclient.monix._\n", "\n", "implicit val sttpBackend = AsyncHttpClientMonixBackend()\n", "import sttp.client.basicRequest\n", "\n", "val r = basicRequest.get(uri\"http://httpbin.org/ip\")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Response(Right({\n", " \"origin\": \"34.68.237.200, 34.68.237.200\"\n", "}\n", "),200,OK,List(Access-Control-Allow-Credentials: true, Access-Control-Allow-Origin: *, Content-Type: application/json, Date: Sat, 23 Nov 2019 14:02:16 GMT, Referrer-Policy: no-referrer-when-downgrade, Server: nginx, X-Content-Type-Options: nosniff, X-Frame-Options: DENY, X-XSS-Protection: 1; mode=block, Connection: keep-alive, transfer-encoding: chunked),List())\n", "Response(Right({\n", " \"origin\": \"34.68.237.200, 34.68.237.200\"\n", "}\n", "),200,OK,List(Access-Control-Allow-Credentials: true, Access-Control-Allow-Origin: *, Content-Type: application/json, Date: Sat, 23 Nov 2019 14:02:16 GMT, Referrer-Policy: no-referrer-when-downgrade, Server: nginx, X-Content-Type-Options: nosniff, X-Frame-Options: DENY, X-XSS-Protection: 1; mode=block, Connection: keep-alive, transfer-encoding: chunked),List())\n" ] }, { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36mmonix.execution.Scheduler.Implicits.global\n", "\u001b[39m\n", "\u001b[36mtask\u001b[39m: \u001b[32mmonix\u001b[39m.\u001b[32meval\u001b[39m.\u001b[32mTask\u001b[39m[\u001b[32msttp\u001b[39m.\u001b[32mclient\u001b[39m.\u001b[32mResponse\u001b[39m[\u001b[32mEither\u001b[39m[\u001b[32mString\u001b[39m, \u001b[32mString\u001b[39m]]] = \u001b[33mFlatMap\u001b[39m(\n", " \u001b[33mEval\u001b[39m(\n", " sttp.client.asynchttpclient.monix.AsyncHttpClientMonixBackend$$$Lambda$3137/25163081@756ca83b\n", " ),\n", " ammonite.$sess.cmd10$Helper$$Lambda$3378/676411879@78fb45b2\n", ")" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import monix.execution.Scheduler.Implicits.global\n", "val task = for {\n", " backend <- sttpBackend\n", " res <- r.send()(backend, implicitly)\n", "} yield res\n", "task.foreach(println)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Armeria" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Downloading https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0.pom\n", "Downloaded https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final.pom\n", "Downloading https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.pom\n", "Downloading https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1.pom\n", "Downloading https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.pom\n", "Downloaded https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-parent/4.1.43.Final/netty-parent-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-base/2.10.1/jackson-base-2.10.1.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-tcnative-parent/2.0.27.Final/netty-tcnative-parent-2.0.27.Final.pom\n", "Downloading https://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.7.29/slf4j-parent-1.7.29.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-parent/2.10/jackson-parent-2.10.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-parent/2.10/jackson-parent-2.10.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-tcnative-parent/2.0.27.Final/netty-tcnative-parent-2.0.27.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.7.29/slf4j-parent-1.7.29.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-base/2.10.1/jackson-base-2.10.1.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-parent/4.1.43.Final/netty-parent-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-parent/4.0.29.Final/netty-parent-4.0.29.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-bom/2.10.1/jackson-bom-2.10.1.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/oss-parent/38/oss-parent-38.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/oss-parent/38/oss-parent-38.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-parent/4.0.29.Final/netty-parent-4.0.29.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/jackson-bom/2.10.1/jackson-bom-2.10.1.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final.pom\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final.pom\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar\n", "Downloaded https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11.jar\n", "Downloading https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1.jar\n", "Downloaded https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.jar\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar\n", "Downloading https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final-linux-x86_64.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar\n", "Downloading https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final-linux-x86_64.jar\n", "Downloading https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3-sources.jar\n", "Downloading https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/org/hdrhistogram/HdrHistogram/2.1.11/HdrHistogram-2.1.11-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.43.Final/netty-resolver-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/micrometer/micrometer-core/1.3.1/micrometer-core-1.3.1-sources.jar\n", "Downloading https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-haproxy/4.1.43.Final/netty-codec-haproxy-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-resolver-dns/4.1.43.Final/netty-resolver-dns-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.43.Final/netty-codec-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.43.Final/netty-transport-native-unix-common-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-common/4.1.43.Final/netty-common-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport-native-epoll/4.1.43.Final/netty-transport-native-epoll-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http/4.1.43.Final/netty-codec-http-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static/2.0.27.Final/netty-tcnative-boringssl-static-2.0.27.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.43.Final/netty-handler-4.1.43.Final-sources.jar\n", "Downloading https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-dns/4.1.43.Final/netty-codec-dns-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.43.Final/netty-buffer-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-codec-http2/4.1.43.Final/netty-codec-http2-4.1.43.Final-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.43.Final/netty-transport-4.1.43.Final.jar\n", "Downloaded https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0-sources.jar\n", "Downloaded https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/0.96.0/armeria-0.96.0.jar\n", "SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".\n", "SLF4J: Defaulting to no-operation (NOP) logger implementation\n", "SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n" ] }, { "data": { "text/plain": [ "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", "\n", "\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36mcom.linecorp.armeria.client.WebClient\n", "\n", "\u001b[39m\n", "\u001b[36mclient\u001b[39m: \u001b[32mWebClient\u001b[39m = DefaultWebClient(com.linecorp.armeria.client.HttpClientDelegate@14054bd1)\n", "\u001b[36mfuture\u001b[39m: \u001b[32mjava\u001b[39m.\u001b[32mutil\u001b[39m.\u001b[32mconcurrent\u001b[39m.\u001b[32mCompletableFuture\u001b[39m[\u001b[32mcom\u001b[39m.\u001b[32mlinecorp\u001b[39m.\u001b[32marmeria\u001b[39m.\u001b[32mcommon\u001b[39m.\u001b[32mAggregatedHttpResponse\u001b[39m] = java.util.concurrent.CompletableFuture@67d77643[Completed normally]\n", "\u001b[36mres\u001b[39m: \u001b[32mcom\u001b[39m.\u001b[32mlinecorp\u001b[39m.\u001b[32marmeria\u001b[39m.\u001b[32mcommon\u001b[39m.\u001b[32mAggregatedHttpResponse\u001b[39m = DefaultAggregatedHttpResponse{headers=[:status=200, access-control-allow-credentials=true, access-control-allow-origin=*, content-type=application/json, date=Sat, 23 Nov 2019 13:19:04 GMT, referrer-policy=no-referrer-when-downgrade, server=nginx, x-content-type-options=nosniff, x-frame-options=DENY, x-xss-protection=1; mode=block, content-length=47], content=DefaultHttpData{length=47}}" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import $ivy.`com.linecorp.armeria:armeria:0.96.0` \n", "\n", "import com.linecorp.armeria.client.WebClient\n", "\n", "val client = WebClient.of(\"http://httpbin.org/\")\n", "val future = client.get(\"/ip\").aggregate()\n", "val res = future.join()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[36mbody\u001b[39m: \u001b[32mString\u001b[39m = \u001b[32m\"\"\"{\n", " \"origin\": \"34.68.237.200, 34.68.237.200\"\n", "}\n", "\"\"\"\u001b[39m" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val body = res.contentUtf8" ] } ], "metadata": { "kernelspec": { "display_name": "Scala (2.12)", "language": "scala", "name": "scala212" }, "language_info": { "codemirror_mode": "text/x-scala", "file_extension": ".scala", "mimetype": "text/x-scala", "name": "scala", "nbconvert_exporter": "script", "version": "2.12.10" } }, "nbformat": 4, "nbformat_minor": 2 }