fix wsgi hostname reconstruction
refactor ctx.in_document to wsgi_env