[Bug]: HTTP Range Responses not within spec
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- android
- Ambito
- networking
Direzione di ricerca
Esegui la riproduzione fornita con pnpm i, pnpm build, pnpm cap sync android e pnpm cap run android, quindi ispeziona l’implementazione dell’Android Web Server che gestisce le richieste HTTP Range. Verifica i dati della risposta della richiesta di esempio rispetto ai relativi header Content-Length e Content-Range; il lavoro è completato quando lo stream viene troncato all’intervallo richiesto oppure gli header descrivono accuratamente il resto restituito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Capacitor Version
8.1.0
Other API Details
Platforms Affected
- iOS
- Android
- Web
Current Behavior
This issue has been reported: https://github.com/ionic-team/capacitor/issues/7151#issuecomment-1897113728
When constructing the response for an HTTP Range request, the InputStream is not properly truncated at the end of the requested range. This results in the response including data from the specified start index, all the way to the end of the file.
The results of this failed truncation are as follows:
- The
Content-Lengthresponse header gives a byte length that would be correct if the InputStream was truncated - The
Content-Rangeresponse header gives a byte range that would be correct if the InputStream was truncated
From my understanding of the HTTP Range spec, if the server plans to send the remainder of the file in the response (which is the current behavior of the Capacitor implementation), the Content-Length and Content-Range must be updated to reflect the extra returned length and ending byte range (length - 1).
This appears to cause issues specifically with the PMTiles decoder since it appears to rely on the response headers to understand how much data it received.
Reproduction Steps
- Install dependencies and build app with pnpm (crucial for patches to apply)
pnpm i
pnpm build
pnpm cap sync android
pnpm cap run android
- Using the demo app, observe a
cstat.pmtilesrequest from within Chrome Devtools. - You will see a Content-Length header in the response.
- Convert the Content-Length value to hexadecimal
- View the Response data tab in Devtools
- Go to the Hexadecimal index you calculated in Step 3.
- See that there is lots of data returned that exceeds the Content-Length.
- You will see that the data continues to the end of the file (
index = totalFileLength - startRange - 1=> Convert to Hex)
Example
Request Range: bytes=850902-889367
Response Content-Length Header: 38466 (0x00009642)
Response Content-Range Header: bytes 850902-889367/3949417
Response Data @ 0x00009642
Response Data @ 0x002F4792 (See step 7: 3949417-850902-1)
Expected Behavior
The stream is properly truncated at the specified byte index or the response headers match the fact that the remainder of the file is sent. Ideally the stream is properly truncated to minimize large data transfer.
Project Reproduction
https://github.com/bwees/range-request-capacitor-repro/tree/fix/lowercase-range
UPDATE: March 3 17:00 UTC, the example project was broken and has since been fixed
Additional Information
The provided project branch includes a pnpm patch that resolves issues that are fixed in #8368. This is needed to properly debug this problem as otherwise the range response headers are not sent.
I also took multiple attempts at creating a PR to solve this issue but could not get the stream to properly truncate without a ERR:FAILED error being thrown or the Content-Length header being overridden before response to the client. Maybe someone more versed in the Web Server implementation has some insight but I was not able to solve it
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 1.3k
- Merge medio
- 3g 10h
- PR unite (30g)
- 10
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ionic-team/capacitor
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
ionic-team/capacitor#8616 ·
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ionic-team/capacitor#8601 ·
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ionic-team/capacitor#8574 ·
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16) Apertatriage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ionic-team/capacitor#8530 · 2 commenti ·
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ionic-team/capacitor#8529 ·
Tutte le issue di ionic-team/capacitor
Issue simili
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Automattic/studio#4908 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100