asgiref icon indicating copy to clipboard operation
asgiref copied to clipboard

Add `offset` and `count` to Path Send

Open Archmonger opened this issue 1 year ago • 3 comments

This discussion exists to talk about whether the Path Send spec can be reasonably modified to support offset and count, in a similar manner to those respective variables within zerocopysend.

As a summary of the original discussion...

  • zerocopysend was effectively dead on arrival due to integration challenges with existing webservers.
  • pathsend can be considered as an alternative that is more compatible with a variety of webservers.
  • pathsend currently does not support offset and count, which makes it impossible to use with HTTP range requests.
  • andrewgodwin agreed that offset and count can be added to pathsend if it can be implemented in a backwards compatible manner
  • I suggested if backwards compatibility is too challenging, then the extension namespace can be cluttered with http.response.pathsend2

Archmonger avatar Sep 25 '24 08:09 Archmonger

On the backward compatibility thing, I personally think is fine to add new features on top of an existing extension, given there's a way for the application to understand if those features are supported.

One idea might be to add this information to the scope, eg:

"scope": {
    "extensions": {
        "http.response.pathsend": {
            "ranges": True
        },
    },
}

in such way the application knows if the server supports the additional keys in the messages and use them; the lack of that boolean means no support is given. I'd also personally prefer a single key in the message for the range, as the application should already know the total size of the file to produce valid range headers, eg:

{
    "type": "http.response.pathsend",
    "path": "foobar.txt",
    "range": (0, 4096)   # send only the first 4KB
}

gi0baro avatar Sep 25 '24 10:09 gi0baro

That's a good idea - extensions entries were meant to be dicts exactly so we could definitely add signal in there.

andrewgodwin avatar Sep 25 '24 13:09 andrewgodwin

What is the proper procedure for introducing this as an ASGI spec change? Should I create an informal GitHub issue within asgiref?

Apologies for my inexperience with the Django team's workflow.

Archmonger avatar Jun 10 '25 06:06 Archmonger