I have edited the part about using HTTPS-only URL-s.
The code where the HTTP 200 header is returned seemed to work for me in that exact form.*
(Note, I was using HTTP::Server::Simple, where your program has to print the HTTP status line and all headers.)
* Actually I'm not sure about that. I will check it sometime soon and update this post if I can verify that.