HTTP Errors

SaltwaterC edited this page Jul 30, 2012 · 3 revisions

The underlying HTTP client is pretty blunt when it comes to unexpected responses. Basically:

  • 200 and 204 - success statuses. The 204 status code is usually returned by the PUT and DELETE methods.
  • 307 - temporary redirect by the S3 API. However, sometimes this API proved to enter in redirect loop. The client backs of with 500ms of delay, than it adds 500ms of delay for each repetition between subsequent requests. If the API loops 10 times, the error argument is returned.
  • any other HTTP status code is considered to be an error. Yes, even the 301 and the 302 redirects. Usually they are returned when you fat finger some path for the S3 client. The temporary endpoints are handled only by 307 redirects.

If the status code is considered to be an error, then the response body is parsed by libxml-to-js as JavaScript object.

The returned error is an Error() instance, but it has some appended properties:

  • code - it indicates the actual HTTP status code
  • headers - the raw headers object as returned by the HTTP client
  • document - the error document returned by the AWS API itself