Skip to content

Instantly share code, notes, and snippets.

@jrudolph
Created June 26, 2017 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrudolph/a4f3adc3a1bbe57e6ebffd4c2fe8c649 to your computer and use it in GitHub Desktop.
Save jrudolph/a4f3adc3a1bbe57e6ebffd4c2fe8c649 to your computer and use it in GitHub Desktop.
package akka.http
import akka.actor.ActorSystem
import akka.http.impl.util.ExampleHttpContexts
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Flow
import com.typesafe.config.ConfigFactory
object HttpsWithLargeResponseEntity1219 extends App {
val config =
ConfigFactory
.parseString(
"""
akka.loglevel = DEBUG
akka.http.server {
log-unencrypted-network-bytes = 100
}
""".stripMargin)
.withFallback(ConfigFactory.load())
implicit val system = ActorSystem("system", config)
implicit val mat = ActorMaterializer()
implicit val dispatcher = system.dispatcher
val https: HttpsConnectionContext = ExampleHttpContexts.exampleServerContext
val routes: Flow[HttpRequest, HttpResponse, Any] =
Flow[HttpRequest]
.map { req
HttpResponse(entity = Array.fill[Char](999999)('0').mkString + "x")
}
Http().bindAndHandle(routes, "127.0.0.1", 8443, connectionContext = https)
Http().bindAndHandle(routes, "127.0.0.1", 8080)
}
[info] [DEBUG] [06/26/2017 16:39:23.333] [main] [EventStream(akka://system)] logger log1-TestEventListener started
[info] [DEBUG] [06/26/2017 16:39:23.333] [main] [EventStream(akka://system)] Default Loggers started
[info] [DEBUG] [06/26/2017 16:39:23.353] [system-akka.actor.default-dispatcher-3] [akka.serialization.Serialization(akka://system)] Using serializer [akka.serialization.JavaSerializer] for message [akka.event.EventStreamUnsubscriber$Register]
[info] [DEBUG] [06/26/2017 16:39:23.713] [main] [AkkaSSLConfig(akka://system)] Initializing AkkaSSLConfig extension...
[info] [DEBUG] [06/26/2017 16:39:23.715] [main] [AkkaSSLConfig(akka://system)] buildHostnameVerifier: created hostname verifier: com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@1a5b6f42
[info] [DEBUG] [06/26/2017 16:39:24.082] [system-akka.actor.default-dispatcher-2] [akka://system/system/IO-TCP/selectors/$a/0] Successfully bound to /127.0.0.1:8443
[info] [DEBUG] [06/26/2017 16:39:24.086] [system-akka.actor.default-dispatcher-6] [akka://system/system/IO-TCP/selectors/$a/1] Successfully bound to /127.0.0.1:8080
[info] [DEBUG] [06/26/2017 16:39:25.494] [system-akka.io.pinned-dispatcher-5] [akka.serialization.Serialization(akka://system)] Using serializer [akka.serialization.JavaSerializer] for message [akka.io.SelectionHandler$ChannelAcceptable$]
[info] [DEBUG] [06/26/2017 16:39:25.497] [system-akka.actor.default-dispatcher-2] [akka://system/system/IO-TCP/selectors/$a/0] New connection accepted
[info] [DEBUG] [06/26/2017 16:39:25.562] [system-akka.io.pinned-dispatcher-5] [akka.serialization.Serialization(akka://system)] Using serializer [akka.serialization.JavaSerializer] for message [akka.io.SelectionHandler$ChannelReadable$]
[info] [DEBUG] [06/26/2017 16:39:25.686] [system-akka.actor.default-dispatcher-2] [akka.stream.Log(akka://system/user/StreamSupervisor-0)] [server-plain-text UP ] Element: SessionBytes ByteString(97 bytes)
[info] 47 45 54 20 2F 20 48 54 54 50 2F 31 2E 31 0D 0A | GET / HTTP/1.1..
[info] 55 73 65 72 2D 41 67 65 6E 74 3A 20 63 75 72 6C | User-Agent: curl
[info] 2F 37 2E 33 35 2E 30 0D 0A 48 6F 73 74 3A 20 6C | /7.35.0..Host: l
[info] 6F 63 61 6C 68 6F 73 74 3A 38 34 34 33 0D 0A 41 | ocalhost:8443..A
[info] 63 63 65 70 74 3A 20 2A 2F 2A 0D 0A 43 6F 6E 6E | ccept: */*..Conn
[info] 65 63 74 69 6F 6E 3A 20 63 6C 6F 73 65 0D 0A 0D | ection: close...
[info] 0A | .
[info] [DEBUG] [06/26/2017 16:39:25.781] [system-akka.actor.default-dispatcher-2] [akka.stream.Log(akka://system/user/StreamSupervisor-0)] [server-plain-text DOWN] Element: SendBytes ByteString(1000192 bytes) first + last 100:
[info] 48 54 54 50 2F 31 2E 31 20 32 30 30 20 4F 4B 0D | HTTP/1.1 200 OK.
[info] 0A 53 65 72 76 65 72 3A 20 61 6B 6B 61 2D 68 74 | .Server: akka-ht
[info] 74 70 2F 31 30 2E 30 2E 38 2B 36 2D 61 34 36 39 | tp/10.0.8+6-a469
[info] 35 38 62 35 2B 32 30 31 37 30 36 32 36 2D 31 36 | 58b5+20170626-16
[info] 32 36 0D 0A 44 61 74 65 3A 20 4D 6F 6E 2C 20 32 | 26..Date: Mon, 2
[info] 36 20 4A 75 6E 20 32 30 31 37 20 31 34 3A 33 39 | 6 Jun 2017 14:39
[info] 3A 32 35 20 | :25
[info] ... [999992 bytes omitted] ...
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 | 0000000000000000
[info] 30 30 30 78 | 000x
[info] [DEBUG] [06/26/2017 16:39:25.782] [system-akka.actor.default-dispatcher-2] [akka.stream.Log(akka://system/user/StreamSupervisor-0)] [server-plain-text DOWN] Upstream finished.
[info] [DEBUG] [06/26/2017 16:39:25.784] [system-akka.actor.default-dispatcher-2] [akka.stream.Log(akka://system/user/StreamSupervisor-0)] [server-plain-text UP ] Downstream finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment