test: add https tls session reuse test

Check that TLS session resumptions work with HTTPS servers.

Regression test for #3901.
net: Do not destroy socket mid-write

The fix in e0519ace315c7ce14278d5eaab8d1d72a0a0a054 is overly zealous,
and can destroy a socket while there are still outstanding writes in
progress.

Closes GH-5688