add back httpinputstream and correct error handling