Commit e59e343
committed
Added offset and count parameters to pathsend extension
This extends the http.response.pathsend extension to support partial
file sends by adding optional offset and count parameters, enabling
HTTP Range request support (RFC 7233) and efficient seeking in large
media files.
The parameters mirror the existing http.response.zerocopysend API:
- offset: byte position to start reading from (default: beginning)
- count: number of bytes to send (default: to end of file)
This allows ASGI frameworks to implement range requests without
handling file descriptors directly, offloading the operation to
the server while maintaining pathsend's simpler API.
Capability Signaling:
Servers that support offset and count parameters MUST advertise this
by setting {"ranges": True} in the pathsend extension scope dict.
Applications should check for this flag before using these parameters.
This provides a clear upgrade path from basic pathsend to range-capable
pathsend without ambiguity.
The application remains responsible for:
- Checking the "ranges" capability flag
- Parsing Range request headers
- Setting appropriate response headers (Content-Range, Content-Length,
Accept-Ranges, status 206)
Fixes #469
Related: emmett-framework/granian#1571 parent b7b15b2 commit e59e343
2 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
| |||
160 | 176 | | |
161 | 177 | | |
162 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
163 | 187 | | |
164 | 188 | | |
165 | 189 | | |
| |||
0 commit comments