diff --git a/fetch.bs b/fetch.bs index 0399ac19c..409ae80b9 100644 --- a/fetch.bs +++ b/fetch.bs @@ -7879,6 +7879,63 @@ resource — for non-CORS requests as well as CORS requests — and do not use `Vary`. +

Using fetch in other standards

+ +

In its essence fetching is an exchange of a request for a +response. In reality it is rather complex mechanism for standards to adopt and use +correctly. This section aims to give some advice. + +

Always ask domain experts for review. + +

This is a work in progress. + + +

Invoking fetch

+ +

Aside from a request the fetch operation takes several optional +arguments. For those arguments that take an algorithm: the algorithm will be called from a task (or +in a parallel queue if useParallelQueue is true). + +

+
processRequestBody +

Takes an algorithm that will be passed the number of bytes that have been transmitted from + the request's body. The algorithm will be invoked for each + transmitted chunk. Most standards will not need this. + +

processRequestEndOfBody +

Takes an algorithm that will be passed nothing. Indicates request's + body has been transmitted. Most standards will not need this. + +

processResponse +

Takes an algorithm that will be passed a response. Indicates + response's header list has been received and initialized. This + is primarily useful for standards that want to operate on response's + body's stream directly. + +

processResponseEndOfBody +
+

Takes an algorithm that will be passed a response and null, failure, or a + byte sequence. This is useful for standards that wish to operate on the entire + response's body, of which the result of reading it is supplied as + second argument. + +

It might be surprising that a network error will have null as second argument. + +

A standard that uses this argument cannot operate on response's + body itself as providing this argument will cause it to be read and it can be + read only once. + +

processResponseDone +

Takes an algorithm that will be passed a response. Indicates the network is + done transmitting the response. This does not read response's + body. + +

useParallelQueue +

Takes a boolean that defaults to false. Indicates where the algorithms passed + as arguments will be invoked. Hopefully most standards will not need this. +

+ +

Acknowledgments

Thanks to