   #   new Request(options)
 
   constructor: (options={}) ->
+    @response = null
+
     @_emitter = new Emitter
     @xhr = new XMLHttpRequest
 

  _stateChange: ->
    return unless @xhr.readyState is XMLHttpRequest.DONE

    if @xhr.status in [200..299]
      @_emitter.emit "success", @response(), @xhr.status, @xhr
    else
      @_emitter.emit "error", @xhr, @xhr.status

    @_emitter.emit "complete", @xhr, @xhr.status

  _dataIsObject: ->
    @data && @data.constructor is Object

  send: ->
    @xhr.addEventListener "progress", @_progressChange.bind(this)
    @xhr.addEventListener "readystatechange", @_stateChange.bind(this)

    @xhr.open(@method, @url, @async, @username, @password)
    @_setRequestHeaders()

    @_emitter.emit "before", @xhr
    @xhr.send @_requestData()

  on: (args...) -> @_emitter.on args...

