Close the InputStream before replacing the body

This fixes a bug where the InputStream would not always get closed full
logging is enabled.
Add empty Log implementation.
Ensure HTTP input stream is always closed.
Minor formatting clean-up.