OkHttp retries consume RequestBody streams, causing empty payloads on retry for multipart uploads
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- networking
Direzione di ricerca
Start by reading OkHttp's retry behavior and how multipart RequestBody writes its InputStream; the issue does not name source files or tests. Reproduce the described connection failure with a mock server, then verify that a retry does not send an empty upload body.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
OkHttp version 4.12.0
Description
When retryOnConnectionFailure is enabled (default behavior), OkHttp retries failed requests (e.g., due to connection errors) by reusing the same RequestBody. For multipart uploads using a non-repeatable InputStream (e.g., ByteArrayInputStream), the stream is fully consumed during the first attempt. This results in an empty payload (0-byte file) being sent on retry, leading to data loss or incomplete uploads.
This issue affects scenarios like file uploads where the InputStream cannot be reliably reset (e.g., network streams). Workarounds include disabling retries (retryOnConnectionFailure(false)) but they are not ideal when relying on automatic retries.
A common attempt to fix this is calling InputStream.reset() after marking the stream, but this fails because OkHttp's retry mechanism does not provide a hook to reset the stream between attempts.
Steps to Reproduce
- Create an OkHttp client with
retryOnConnectionFailure(true)(default). - Prepare a multipart
RequestBodyusing a non-repeatableInputStream(e.g.,ByteArrayInputStream). - Send a POST request to a mock server (e.g., via WireMock) that simulates a connection failure on the first attempt (e.g., returns an empty response or fault to trigger retry).
- Observe the retry request: The
InputStreamis exhausted, sending an empty body (0 bytes).
- Lingua principale
- Kotlin
- Stelle
- 47.1k
- Fork
- 9.3k
- Merge medio
- 18h 18m
- PR unite (30g)
- 15
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 lysine-dev/okhttp
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
lysine-dev/okhttp#9788 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
lysine-dev/okhttp#9761 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Remove crossinline `addInterceptor` and `addNetworkInterceptor` overloadsForse di nuovo libera @Amir-Golmoradi l’ha presa 7 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
lysine-dev/okhttp#9779 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
HTTP/2 Data padding is not counted toward the connection flow-control window. This deadlocks connections with peers that pad.Forse di nuovo libera @Amir-Golmoradi l’ha presa 7 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
lysine-dev/okhttp#9772 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
lysine-dev/okhttp#9760 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lysine-dev/okhttp
Issue simili
-
Dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ankidroid/Anki-Android#22555 ·
I maintainer di solito rispondono entro 1 giorno
-
Good first issue: add kotlin-spring-boot stack budget preset (Kotlin + Spring Boot 3 + Gradle)Apertaenhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
core: RAC_LLM_OPTIONS_DEFAULT.min_p disagrees with the IDL's annotated defaultForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug core p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
RunanywhereAI/runanywhere-sdks#1083 ·
I maintainer di solito rispondono entro 5 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Java and Kotlin (JVM): parse gradle/wrapper/gradle-wrapper.properties with exact line locationsApertaarea: detector eco: java help wanted lane: free-agent roadmap size: S type: parser
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
arminazimi/evergreen#355 ·
I maintainer di solito rispondono entro 1 giorno