[CHEF-4160] Add retries for 502 and 504 error codes.

The Chef server relies on the client retrying in the case of 502 and
504s to ensure reliability. By default, the Chef::REST class handles
these retries; however, they are disabled during cookbook uploading to
work around poor API responses. This reimplements retries for 502s and
504s while leaving the current no-retry behavior for other errors.