Class: AWS.HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/http.js

Overview

The low level HTTP response object, encapsulating all HTTP header and body data returned from the request.

Property Summary

Method Summary

Property Details

bodyString (readwrite)

Returns the response body payload

Returns:

  • (String)

    the response body payload

headersmap<String,String> (readwrite)

Returns a map of response header keys and their respective values

Returns:

  • (map<String,String>)

    a map of response header keys and their respective values

statusCodeInteger (readwrite)

Returns the HTTP status code of the response (e.g., 200, 404)

Returns:

  • (Integer)

    the HTTP status code of the response (e.g., 200, 404)

streamingBoolean (readwrite)

Returns whether this response is being streamed at a low-level. Defaults to false (buffered reads). Do not modify this manually, use createUnbufferedStream() to convert the stream to unbuffered mode instead.

Returns:

  • (Boolean)

    whether this response is being streamed at a low-level. Defaults to false (buffered reads). Do not modify this manually, use createUnbufferedStream() to convert the stream to unbuffered mode instead.

Method Details

createUnbufferedStream() ⇒ Stream, ...

Note:

This object is only available after the AWS.Request~httpHeaders event has fired. This method must be called prior to AWS.Request~httpData.

Disables buffering on the HTTP response and returns the stream for reading.

Examples:

Taking control of a stream

request.on('httpHeaders', function(statusCode, headers) {
  if (statusCode < 300) {
    if (headers.etag === 'xyz') {
      // pipe the stream, disabling buffering
      var stream = this.response.httpResponse.createUnbufferedStream();
      stream.pipe(process.stdout);
    } else { // abort this request and set a better error message
      this.abort();
      this.response.error = new Error('Invalid ETag');
    }
  }
}).send(console.log);

Returns:

  • (Stream, XMLHttpRequest, null)

    the underlying stream object. Use this object to directly read data off of the stream.