<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24338</bug_id>
          
          <creation_ts>2014-01-20 19:39:10 +0000</creation_ts>
          <short_desc>Spec should have Fetch for Blob URLs</short_desc>
          <delta_ts>2014-11-25 13:51:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>Fetch</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          <dependson>23147</dependson>
    
    <dependson>24998</dependson>
    
    <dependson>25081</dependson>
    
    <dependson>25987</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Arun">arun</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>annevk</cc>
    
    <cc>d</cc>
    
    <cc>glenn</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>sideshowbarker+fetchspec</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98786</commentid>
    <comment_count>0</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-01-20 19:39:10 +0000</bug_when>
    <thetext>The File API should have a &quot;Fetch&quot; for Blob URLs that uses fetch.spec.whatwg.org &quot;fetch a URL&quot; algorithm but applied to Blob URLs, and works alongside the &quot;parse a URL&quot; step described in Bug 17765.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99420</commentid>
    <comment_count>1</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2014-01-29 17:08:44 +0000</bug_when>
    <thetext>We don&apos;t want a special separate &quot;fetch&quot; algorithm that everyone has to use to support blob URLs.  There&apos;s only one Fetch algorithm for all types of URLs, just as there&apos;s only one Parse algorithm for all types of URLs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99422</commentid>
    <comment_count>2</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-01-29 17:33:11 +0000</bug_when>
    <thetext>It won&apos;t be a separate &quot;fetch.&quot;  It&apos;ll be the same fetch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99771</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-05 11:25:48 +0000</bug_when>
    <thetext>I can take care of this in Fetch. What I need for this from File API are synchronous and asynchronous read concepts for blobs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101540</commentid>
    <comment_count>4</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-02-27 22:26:43 +0000</bug_when>
    <thetext>Done. 
http://dev.w3.org/2006/webapi/FileAPI/#reading-data-section

Anne can you review this before I close it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102458</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-17 15:59:09 +0000</bug_when>
    <thetext>I filed bug 25081. Is the idea that Fetch defines the fetching?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102662</commentid>
    <comment_count>6</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-03-19 18:00:48 +0000</bug_when>
    <thetext>(In reply to Anne from comment #5)
&gt; I filed bug 25081. Is the idea that Fetch defines the fetching?

Yes, per Comment 3, assuming that the read operation delivers to Fetch everything it needs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102664</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-03-19 18:33:54 +0000</bug_when>
    <thetext>I will just use this bug for Fetch then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105892</commentid>
    <comment_count>8</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-05-13 18:45:45 +0000</bug_when>
    <thetext>(In reply to Anne from comment #7)
&gt; I will just use this bug for Fetch then.

I think Bug 25081 is mostly resolved pending review from you. I&apos;ve added Bug 24998 as a dependency here too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107156</commentid>
    <comment_count>9</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-06-02 20:16:37 +0000</bug_when>
    <thetext>File API now has the following pieces in place:

1. Asynchronous read operation that only queues tasks, doesn&apos;t &quot;mix&quot; synchronous bits with asynchronous bits (which was a problem/bug in previous editor&apos;s drafts), and ties in with error handling with failure reasons usable by other specifications. That&apos;s http://dev.w3.org/2006/webapi/FileAPI/#readOperationSection

2. Serializing a Blob URL, extracting identifiers, and extracting origins e.g. http://dev.w3.org/2006/webapi/FileAPI/#DefinitionOfScheme

3. Blob URL Store and Revocation List e.g. http://dev.w3.org/2006/webapi/FileAPI/#lifeTime

4. Request/response guidance: http://dev.w3.org/2006/webapi/FileAPI/#requestResponseModel

I&apos;m pretty sure these are the last pieces to add to the Fetch spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108683</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-07-03 10:08:32 +0000</bug_when>
    <thetext>https://github.com/whatwg/fetch/commit/a53a57dfc66911686488111d6cd19297cdb5c354 landed the other day. Still need the actual extracting the body part somehow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114255</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-30 17:50:00 +0000</bug_when>
    <thetext>http://dev.w3.org/2006/webapi/FileAPI/#readOperation looks good enough.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115072</commentid>
    <comment_count>12</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-18 20:50:25 +0000</bug_when>
    <thetext>Resolving per Comment 11</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115114</commentid>
    <comment_count>13</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-19 11:43:42 +0000</bug_when>
    <thetext>Arun, I wonder if the current setup works after all... Sorry for the churn.

https://fetch.spec.whatwg.org/#basic-fetch sets response&apos;s body to a new body and sets the length of that body.

http://dev.w3.org/2006/webapi/FileAPI/#readOperation creates a new body and returns that (while pushing to it in the background).

I could reference #readOperation and then set length on the result and set response&apos;s body to the result, but that seems somewhat ugly, no?


It seems either #readOperation should also set length or #readOperation should take a body as argument to read the blob into.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115169</commentid>
    <comment_count>14</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-19 23:42:53 +0000</bug_when>
    <thetext>(In reply to Anne from comment #13)
&gt; Arun, I wonder if the current setup works after all... Sorry for the churn.
&gt; 
&gt; https://fetch.spec.whatwg.org/#basic-fetch sets response&apos;s body to a new
&gt; body and sets the length of that body.
&gt; 
&gt; http://dev.w3.org/2006/webapi/FileAPI/#readOperation creates a new body and
&gt; returns that (while pushing to it in the background).
&gt; 
&gt; I could reference #readOperation and then set length on the result and set
&gt; response&apos;s body to the result, but that seems somewhat ugly, no?
&gt; 
&gt; 
&gt; It seems either #readOperation should also set length or #readOperation
&gt; should take a body as argument to read the blob into.


OK, I think this read operation from FileAPI should set length, and not transmitted; length is the payload&apos;s available bytes, whereas transmitted is what portions of the payload are actually &quot;transmitted.&quot;

So, the (asynchronous) read operation makes available a body with increasing length for response.

Is this closer right? Change is read operation in File API doesn&apos;t set transmitted; diffs are lines 881 and 891:

http://dev.w3.org/cvsweb/2006/webapi/FileAPI/Overview.html.diff?r1=1.272;r2=1.273;only_with_tag=MAIN;f=h

With the read operation defined here:

http://dev.w3.org/2006/webapi/FileAPI/#readOperationSection</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115199</commentid>
    <comment_count>15</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-20 10:13:55 +0000</bug_when>
    <thetext>No, length needs to match size. We could rename transmitted to something more neutral I suppose that works for local resources as well. Not sure what though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115224</commentid>
    <comment_count>16</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-20 14:45:46 +0000</bug_when>
    <thetext>(In reply to Anne from comment #15)
&gt; No, length needs to match size. We could rename transmitted to something
&gt; more neutral I suppose that works for local resources as well. Not sure what
&gt; though.

OK, setting body&apos;s length to match blob&apos;s size is pretty easy to do.

But, should the read operation in File API touch &apos;transmitted&apos; at all? In fact, is the &apos;read operation&apos; what actually transmits the bytes to the requesting API?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115228</commentid>
    <comment_count>17</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-20 15:18:30 +0000</bug_when>
    <thetext>(In reply to Arun from comment #16)
&gt; OK, setting body&apos;s length to match blob&apos;s size is pretty easy to do.
&gt; 
&gt; But, should the read operation in File API touch &apos;transmitted&apos; at all? In
&gt; fact, is the &apos;read operation&apos; what actually transmits the bytes to the
&gt; requesting API?

/transmitted/ is just an integer used by progress events in XMLHttpRequest. I assume we want progress events even for blob URLs. We could use a different term from /transmitted/ if you want. Perhaps /progress/?

What transmits the bytes is pushing them to body. And handing that body to the requesting API.

There&apos;s various ways of structuring this, I&apos;m not sure what you think is best. My suggestions are in the last paragraph of comment 13.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115237</commentid>
    <comment_count>18</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-20 16:03:27 +0000</bug_when>
    <thetext>(In reply to Anne from comment #13)
&gt; Arun, I wonder if the current setup works after all... Sorry for the churn.
&gt; 
&gt; https://fetch.spec.whatwg.org/#basic-fetch sets response&apos;s body to a new
&gt; body and sets the length of that body.
&gt; 
&gt; http://dev.w3.org/2006/webapi/FileAPI/#readOperation creates a new body and
&gt; returns that (while pushing to it in the background).
&gt; 
&gt; I could reference #readOperation and then set length on the result and set
&gt; response&apos;s body to the result, but that seems somewhat ugly, no?
&gt; 
&gt; 
&gt; It seems either #readOperation should also set length or #readOperation
&gt; should take a body as argument to read the blob into.


We could set /length/ in the read operation to match blob&apos;s size.

But the problem with this is if the (asynchronous) read operation generates an error mid-read. In that case, you will only have a portion of /length/; body is returned asynchronously.

Or I could increment /transmitted/ and /length/ as bytes are pushed to body.

Which is better?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115239</commentid>
    <comment_count>19</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-20 16:23:37 +0000</bug_when>
    <thetext>Setting /length/ still makes sense. But we should signal the error state somehow I suppose. Domenic, any idea how the low-level streams primitive will do that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115240</commentid>
    <comment_count>20</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-20 16:49:17 +0000</bug_when>
    <thetext>(In reply to Anne from comment #19)
&gt; Setting /length/ still makes sense. But we should signal the error state
&gt; somehow I suppose. Domenic, any idea how the low-level streams primitive
&gt; will do that?

The read operation does signal error! I think Fetch should handle it if it does.

(BTW, this plumbing is what the filesystem: URL scheme will use as well.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115242</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-20 16:55:00 +0000</bug_when>
    <thetext>(In reply to Arun from comment #20)
&gt; The read operation does signal error! I think Fetch should handle it if it
&gt; does.

It&apos;s just unclear how that works. You returned the stream you keep pushing bytes to and continue to run some set of steps in parallel. Then you terminate those steps with a failure reason, but how is the caller going to find out? If it&apos;s not indicated on the stream somehow it seems that just goes lost.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115243</commentid>
    <comment_count>22</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-20 17:17:46 +0000</bug_when>
    <thetext>(In reply to Anne from comment #21)
&gt; (In reply to Arun from comment #20)
&gt; &gt; The read operation does signal error! I think Fetch should handle it if it
&gt; &gt; does.
&gt; 
&gt; It&apos;s just unclear how that works. You returned the stream you keep pushing
&gt; bytes to and continue to run some set of steps in parallel. Then you
&gt; terminate those steps with a failure reason, but how is the caller going to
&gt; find out? If it&apos;s not indicated on the stream somehow it seems that just
&gt; goes lost.


OK, I can make this better.

1. In other algorithms or steps on the platform, we use &quot;If x returns failure, then..&quot;. Right now, read operation terminates with a failure reason. I can have it explicitly return the failure reason, or make the return steps better, so that Fetch can say &quot;if read returns failure...&quot;One way to do this is to return body, but if a failure reason occurs, return that.

2. Or, we can have something set on the body itself in addition to /length/ and /transmitted/. I&apos;d propose a property on body that helps determine if operations on body are failures, including a msg that accompanies the failure reason.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115244</commentid>
    <comment_count>23</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-20 17:25:07 +0000</bug_when>
    <thetext>Yeah, something on body itself seems like the only thing that would work. And as body is a stream, I wondered what Domenic had done there, but we could proceed with exposing some kind of &quot;terminate reason&quot; on body, just as we have for responses.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115321</commentid>
    <comment_count>24</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-11-21 22:33:38 +0000</bug_when>
    <thetext>Streams have an errored state, and in the errored state they have an error reason (which should typically be an instanceof Error). That sounds kind of perfect for what you want?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115409</commentid>
    <comment_count>25</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2014-11-24 18:15:59 +0000</bug_when>
    <thetext>Resolving this. Fetch&apos;s body now has an error flag which is set by the read operation:

http://dev.w3.org/2006/webapi/FileAPI/#readOperationSection</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115466</commentid>
    <comment_count>26</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-25 13:51:30 +0000</bug_when>
    <thetext>This was actually my bug :-)

Anyway, fixed in Fetch: https://github.com/whatwg/fetch/commit/ecf06611c36b4beae4a50fd039957dd8f7238a22</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>