fix #793, bug in order of operations in http/https