better http error handling

related to issue #38