Fixed bug in HTTPS middleware

A slight errata was causing 500 on users without `User-Agent` header.