diff --git a/xhr.bs b/xhr.bs index 0849986..4f7cdd7 100644 --- a/xhr.bs +++ b/xhr.bs @@ -791,45 +791,45 @@ return this's cross-origin credentials.
If this's state is not opened or this's
send()
flag is unset, then return.
+
Let uploadedBytesLength be 0. +
Let processRequestBody, given a request, be these steps: +
Let processRequestBody, given a bytesLength, be these steps:
Increase uploadedBytesLength by bytesLength. +
If not roughly 50ms have passed since these steps were last invoked, then return.
If this's upload listener flag is set, then fire a progress event
named progress
at this's upload object with
- request's body's transmitted bytes and
- request's body's total bytes.
+ uploadedBytesLength and req's body's
+ total bytes.
These steps are only invoked when new bytes are transmitted.
Let processRequestEndOfBody, given a request, be these steps: +
Let processRequestEndOfBody be these steps:
Set this's upload complete flag.
If this's upload listener flag is unset, then return. -
Let transmitted be request's - body's - transmitted bytes. - -
Let length be request's +
Let length be req's body's total bytes.
Fire a progress event named progress
at this's
- upload object with transmitted and length.
+ upload object with uploadedBytesLength and length.
Fire a progress event named load
at this's
- upload object with transmitted and length.
+ upload object with uploadedBytesLength and length.
Fire a progress event named loadend
at this's
- upload object with transmitted and length.
+ upload object with uploadedBytesLength and length.
Let reader be the result of getting a reader for - this's response's body's - stream. - -
This operation will not throw an exception. +
Let processBodyChunk given bytes be these steps: -
Let readRequest be the following read request: - -
Append chunk to this's received bytes. +
Append bytes to this's received bytes. -
If not roughly 50ms have passed since these steps were last invoked, then return. +
If not roughly 50ms have passed since these steps were last invoked, then return. -
If this's state is headers received, then set this's - state to loading. +
If this's state is headers received, then set this's + state to loading. -
Fire an event named readystatechange
at this.
+
Fire an event named readystatechange
at this.
-
Web compatibility is the reason
- readystatechange
fires more often than this's
- state changes.
+
Web compatibility is the reason readystatechange
+ fires more often than this's state changes.
-
Fire a progress event named progress
at this
- with this's response's body's
- transmitted bytes and this's response's
- body's total bytes.
-
Fire a progress event named progress
at this
+ with this's received bytes's length and
+ this's response's body's
+ total bytes.
+
Run handle response end-of-body for this and this's - response.
Let processEndOfBody be this step: run handle response end-of-body for + this and this's response. -
Run handle errors for this and this's - response.
Let processBodyError be this step: run handle errors for this + and this's response. -
Read a chunk from reader given - readRequest. +
Incrementally read this's response's + body, given processBodyChunk, processEndOfBody, + processBodyError, and this's relevant global object.
Fetch req with processRequestBody set to @@ -938,16 +923,21 @@ return this's cross-origin credentials.
Let processedResponse be false.
Let processResponse, given a fetchResponse, be these steps: +
Let processResponseEndOfBody, given a fetchResponse and + nullOrFailureOrBytes, be these steps:
Set response to fetchResponse. +
If nullOrFailureOrBytes is a byte sequence, then append + nullOrFailureOrBytes to this's received bytes. +
Set processedResponse to true.
Fetch req with processResponse - set to processResponse and useParallelQueue set to true. +
Fetch req with processResponseEndOfBody + set to processResponseEndOfBody and useParallelQueue set to + true.
Let now be the present time. @@ -959,23 +949,6 @@ return this's cross-origin credentials.
If processedResponse is false, then set this's timed out flag and terminate fetching. -
If response's body is null, then run - handle response end-of-body for this and response, and then return. - -
Let reader be the result of getting a reader for - response's body's stream. - -
This operation will not throw an exception. - -
Let promise be the result of - reading all bytes from reader. - -
Pause until promise is fulfilled or rejected. - -
If promise is fulfilled with bytes, then append bytes - to this's received bytes. -
Run handle response end-of-body for this and response. @@ -996,8 +969,8 @@ steps:
If xhr's synchronous flag is unset, then update xhr's response's body using response. -
Let transmitted be response's body's - transmitted bytes. +
Let transmitted be xhr's received bytes's + length.
Let length be response's body's total bytes.