fsspec/implementations/http.py
async def async_fetch_range(self, start, end):
        """Download a block of data

        The expectation is that the server returns only the requested bytes,
        with HTTP code 206. If this is not the case, we first check the headers,
        and then stream the output - if the data size is bigger than we
        requested, an exception is raised.
        """
        logger.debug(f"Fetch range for {self}: {start}-{end}")
        kwargs = self.kwargs.copy()
        headers = kwargs.pop("headers", {}).copy()
        headers["Range"] = "bytes=%i-%i" % (start, end - 1)
        logger.debug(self.url + " : " + headers["Range"])
        r = await self.session.get(self.url, headers=headers, **kwargs)
        async with r:
            if r.status == 416:
                # range request outside file
                return b""
            r.raise_for_status()
            if r.status == 206:
                # partial content, as expected
                out = await r.read()
            elif "Content-Length" in r.headers:
                cl = int(r.headers["Content-Length"])
                if cl <= end - start:
                    # data size OK
                    out = await r.read()
                else:
                    raise BlockSizeError(
                        "Got more bytes so far (>%i) than requested (%i)"
                        % (cl, end - start)
                    )
            else:
                cl = 0
                out = []
                while True:
                    chunk = await r.content.read(2 ** 20)
                    # data size unknown, let's see if it goes too big
                    if chunk:
                        out.append(chunk)
                        cl += len(chunk)
                        if cl > end - start:
                            raise BlockSizeError(
                                "Got more bytes so far (>%i) than requested (%i)"
                                % (cl, end - start)
                            )
                    else:
                        break
                out = b"".join(out)
            return out
Download a block of data

        The expectation is that the server returns only the requested bytes,
        with HTTP code 206. If this is not the case, we first check the headers,
        and then stream the output - if the data size is bigger than we
        requested, an exception is raised.
        
Download a block of data
The expectation is that the server returns only the requested bytes,
with HTTP code 206. If this is not the case, we first check the headers,
and then stream the output - if the data size is bigger than we
requested, an exception is raised.
Download a block of data The expectation is that the server returns only the requested bytes with HTTP code 206 . If this is not the case we first check the headers and then stream the output - if the data size is bigger than we requested an exception is raised .
async def async_fetch_range(self, start, end):
        logger.debug(f"Fetch range for {self}: {start}-{end}")
        kwargs = self.kwargs.copy()
        headers = kwargs.pop("headers", {}).copy()
        headers["Range"] = "bytes=%i-%i" % (start, end - 1)
        logger.debug(self.url + " : " + headers["Range"])
        r = await self.session.get(self.url, headers=headers, **kwargs)
        async with r:
            if r.status == 416:
                return b""
            r.raise_for_status()
            if r.status == 206:
                out = await r.read()
            elif "Content-Length" in r.headers:
                cl = int(r.headers["Content-Length"])
                if cl <= end - start:
                    out = await r.read()
                else:
                    raise BlockSizeError(
                        "Got more bytes so far (>%i) than requested (%i)"
                        % (cl, end - start)
                    )
            else:
                cl = 0
                out = []
                while True:
                    chunk = await r.content.read(2 ** 20)
                    if chunk:
                        out.append(chunk)
                        cl += len(chunk)
                        if cl > end - start:
                            raise BlockSizeError(
                                "Got more bytes so far (>%i) than requested (%i)"
                                % (cl, end - start)
                            )
                    else:
                        break
                out = b"".join(out)
            return out
async def async_fetch_range ( self , start , end ) : logger . debug ( f"Fetch range for {self}: {start}-{end}" ) kwargs = self . kwargs . copy ( ) headers = kwargs . pop ( "headers" , { } ) . copy ( ) headers [ "Range" ] = "bytes=%i-%i" % ( start , end - 1 ) logger . debug ( self . url + " : " + headers [ "Range" ] ) r = await self . session . get ( self . url , headers = headers , ** kwargs ) async with r : if r . status == 416 : return b"" r . raise_for_status ( ) if r . status == 206 : out = await r . read ( ) elif "Content-Length" in r . headers : cl = int ( r . headers [ "Content-Length" ] ) if cl <= end - start : out = await r . read ( ) else : raise BlockSizeError ( "Got more bytes so far (>%i) than requested (%i)" % ( cl , end - start ) ) else : cl = 0 out = [ ] while True : chunk = await r . content . read ( 2 ** 20 ) if chunk : out . append ( chunk ) cl += len ( chunk ) if cl > end - start : raise BlockSizeError ( "Got more bytes so far (>%i) than requested (%i)" % ( cl , end - start ) ) else : break out = b"" . join ( out ) return out
Download a block of data
The expectation is that the server returns only the requested bytes,
with HTTP code 206.
Download a block of data The expectation is that the server returns only the requested bytes with HTTP code 206 .
"""Download a block of data

        The expectation is that the server returns only the requested bytes,
        with HTTP code 206. If this is not the case, we first check the headers,
        and then stream the output - if the data size is bigger than we
        requested, an exception is raised.
        """ # range request outside file # partial content, as expected # data size OK # data size unknown, let's see if it goes too big
self
start
end