handle HTTPS

Not tested much, but seems to work - before this commit I was not able to use `readFromDocument` for https sites.