Implement TLS connection

And refactor HTTP library