fix code contract issue
fix header parsing logic
handling response exceptions
update error handling