(Should probably have been posted in Chit Chat or something like that.)
Your question is a bit strange. Usually this is something that is handled by the webserver. Like my site, for instance. It answers at
http://www.example.com/what/ever/here but instantly redirects the browser to
https://www.example.com/what/ever/here. So, in effect, my code never gets a request over http, only over https.