Added handling of HTTP 504 Gateway Timeout.