@@ -259,30 +259,26 @@ type LookupOptions struct {
259
259
// value of 0 means to read to the end of the object.
260
260
To uint64
261
261
262
- // AlwaysUseRequestedRange forces the provided range to be used during streaming .
262
+ // LegacyReturnWholeBody restores a legacy behavior around range requests .
263
263
//
264
- // If false, under certain circumstances the entire body will be returned
265
- // instead of just the requested range.
266
- //
267
- // If:
268
- //
269
- // - AlwaysUseRequestedRange is false
264
+ // In SDK v1.4.2 and earlier, under certain circumstances the requested range
265
+ // (From/To) would be ignored. Specifically, if:
266
+ // - The lookup (reader) is concurrent with the writer of the body
270
267
// - The size of the cached item's body was not provided by the writer
271
268
// - The reader requests a specific range of the cached item's body
272
269
// (`From` and `To` are provided in LookupOptions or GetBodyOptions)
273
- // - The writer and reader are concurrent, i.e. the body is streamed from
274
- // the writer to the reader
275
- //
276
- // then the core cache API will ignore the requested range, and provide
277
- // the entire body.
270
+ // then the core cache API would ignore the requested range and provide
271
+ // the entire body, instead of providing just the requested range.
278
272
//
279
- // Setting AlwaysUseRequestedRange to true changes this behavior:
280
- // - The reader will block until the start of the requested range has been
281
- // written by the writer. This blocking happens within the
282
- // TransactionLookup or Lookup call (if the range is provided in
283
- // LookupOptions) or in GetBody (if the range is provided to GetBody).
273
+ // In SDK v1.4.3, the default behavior changed. In a concurrent read/write:
274
+ // - If From and To are nonzero, the reader will block until the start of
275
+ // the requested range has been provided by the writer.
284
276
// - Only the requested range will be returned to the reader.
285
- AlwaysUseRequestedRange bool
277
+ //
278
+ // Note that the full body is still provided if the range is invalid.
279
+ //
280
+ // LegacyReturnWholeBody restores the v1.4.2 behavior.
281
+ LegacyReturnWholeBody bool
286
282
}
287
283
288
284
func abiLookupOptions (opts LookupOptions ) (fastly.CacheLookupOptions , error ) {
@@ -297,7 +293,7 @@ func abiLookupOptions(opts LookupOptions) (fastly.CacheLookupOptions, error) {
297
293
abiOpts .SetRequest (req )
298
294
}
299
295
300
- abiOpts .SetAlwaysUseRequestedRange (opts .AlwaysUseRequestedRange )
296
+ abiOpts .SetAlwaysUseRequestedRange (! opts .LegacyReturnWholeBody )
301
297
302
298
return abiOpts , nil
303
299
}
0 commit comments