Skip to content

Instantly share code, notes, and snippets.

@luciferous
Created March 8, 2016 08:13
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 luciferous/8f98fd3367af7d2aa7ef to your computer and use it in GitHub Desktop.
Save luciferous/8f98fd3367af7d2aa7ef to your computer and use it in GitHub Desktop.
Test socket closed by remote
while true; do printf 'HTTP/1.1 200 OK\r\nServer: test\r\n'|nc -l 3000; done
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)
while true; do printf 'HTTP/1.1 200 OK\r\nServer: test\r\n'|openssl s_server; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment