Borrow some code from the EC2 plugin for handling response codes.