Skip to content

Instantly share code, notes, and snippets.

@luciferous
Created March 8, 2016 08:13
Show Gist options
  • Save luciferous/8f98fd3367af7d2aa7ef to your computer and use it in GitHub Desktop.
Save luciferous/8f98fd3367af7d2aa7ef to your computer and use it in GitHub Desktop.

Revisions

  1. luciferous created this gist Mar 8, 2016.
    15 changes: 15 additions & 0 deletions TestClose.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import com.twitter.finagle.Http
    import com.twitter.finagle.http.{Http => _, _}
    import com.twitter.io.{Buf, Reader}
    import com.twitter.util.Await

    val tls = Http.client.withStreaming(enabled=true).withTlsWithoutValidation.newService("localhost:4433")
    val plain = Http.client.withStreaming(enabled=true).newService("localhost:3000")

    val tlsReq = Request(Version.Http11, Method.Get, "/", Reader.writable())
    val tlsRes = Await.result(tls(tlsReq).liftToTry)
    println("TLS response failed? " + tlsRes.isThrow)

    val plainReq = Request(Version.Http11, Method.Get, "/", Reader.writable())
    val plainRes = Await.result(plain(plainReq).liftToTry)
    println("TLS response failed? " + plainRes.isThrow)
    1 change: 1 addition & 0 deletions plain.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    while true; do printf 'HTTP/1.1 200 OK\r\nServer: test\r\n'|nc -l 3000; done
    1 change: 1 addition & 0 deletions tls.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    while true; do printf 'HTTP/1.1 200 OK\r\nServer: test\r\n'|openssl s_server; done