This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22387 - Fix task model
Summary: Fix task model
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: Fetch (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+fetchspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-16 21:30 UTC by Marcos Caceres
Modified: 2013-10-23 17:23 UTC (History)
1 user (show)

See Also:


Attachments

Description Marcos Caceres 2013-06-16 21:30:58 UTC
http://fetch.spec.whatwg.org/#fetching

[[
If no transmission is taking place, queue at least one task. 
]]

It would be nice if the spec explained why. It's not clear (to me) what the above actually means.
Comment 1 Anne 2013-06-20 06:07:46 UTC
This is a part of Fetch that still needs cleaning up and I'm not entirely sure how to best do it.

Basically when you do an async fetch we need to report on updates via network tasks.

Once for all HTTP headers. Once or more for at least one byte or no byte at all and then transmission as it occurs (and not if not). And once for fully transmitted.

That will then correspond to readystatechange events in a rewritten XMLHttpRequest that takes advantage of Fetch.
Comment 2 Anne 2013-09-03 12:38:50 UTC
This is the way to do this: http://krijnhoetmer.nl/irc-logs/whatwg/20130723#l-734
Comment 3 Anne 2013-10-15 18:27:40 UTC
From that log, "Immediately after receiving the last header for the resource, or immediately before sending the first task to process the resource's data, if there are no headers, queue a task to <dfn>process the headers</dfn> of the resource, passing it all the metadata received." is the critical bit.

Trying to think through the model below. 

In response to a request you get a response in three stages:

  * response headers
  * response data
  * response complete

or you get:

  * network error

or you get:

  * termination

This last one you can also get while getting a response as it's delivered when the end-user terminated the request or a timeout happened.

So an API using Fetch at a minimum has to deal with "response complete", "network error", and "termination". However, if you want something like <img> to behave as if all data was passed to the image decoder until the end-user terminated the request you have to use "response data" as well, so more commonly you will have to use all five hooks.