[Server] Decode an HTTP request body once instead of per pipeline stage
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- php
- Domaine
- backend, documentation, performance
Piste de recherche
Start with InboundClassifier::classify(), Protocol and StatelessProtocol, MessageFactory::create(), and Json::objectsToArrays() to trace how the request body is decoded across the StreamableHttpTransport pipeline. Check the HTTP transport tests and add coverage showing that one decoded message is shared through classification and handling. Update docs/run/http.md to explain that maxBodyBytes limits encoded bytes and that decoded memory use depends on body shape; the issue leaves whether to lower the default unresolved.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Currently a POST body is decoded several times before it reaches a handler: InboundClassifier::classify(), then Protocol or StatelessProtocol, then MessageFactory::create() and Json::objectsToArrays(). Not all copies are alive at the same time, but peak memory ends up at about twice a single decode, and the CPU cost is paid on every pass - also for requests that are rejected right after.
Measured on main with a tools/call for an unknown tool through StreamableHttpTransport:
| body (600 KB) | one json_decode() |
full pipeline |
|---|---|---|
list of [0] |
35.6 MB | 74.4 MB |
list of {"a":0} |
31.9 MB | 68.4 MB |
list of {} |
4.0 MB | 33.4 MB |
| list of ints | 8.0 MB | 19.1 MB |
Two things to do:
- decode once at the edge and pass the decoded message down, so classification, the protocol and the
MessageFactoryshare it - document in
docs/run/http.mdthatmaxBodyBytesbounds bytes, not decoded size - adversarial shapes need ~60x the body in memory, so the cap should be sized againstmemory_limit. Maybe also worth lowering the 4 MiB default.
Reported by @kanokwut.
- Langage dominant
- PHP
- Étoiles
- 1.7k
- Forks
- 206
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 102
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/php-sdk
-
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
modelcontextprotocol/php-sdk#746 ·
Les mainteneurs répondent en général sous 1 jour
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStanOuverteServer
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
modelcontextprotocol/php-sdk#468 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
[Server] Handle notifications/cancelled on the handshake eraPeut-être pris @ump45nose l’a pris il y a 5 jours. Ouvertehelp wanted improves spec compliance Server
Difficulté 4/5 3-5 jours Accessibilité débutants 57/100
modelcontextprotocol/php-sdk#732 ·
Les mainteneurs répondent en général sous 1 jour
-
[Client][Server] Ship extension classes for the two authorization extensionsPeut-être pris @chr-hertel l’a pris il y a 6 jours. Ouverteauth Client Server
modelcontextprotocol/php-sdk#721 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[Client] Test cross-app access against a real identity providerPeut-être pris @chr-hertel l’a pris il y a 6 jours. Ouverteauth Client
modelcontextprotocol/php-sdk#720 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/php-sdk
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedPeut-être pris @pcvelz l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
OpenMage/magento-lts#5869 ·
Les mainteneurs répondent en général sous 2 jours
-
Map Info Window ButtonsOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
OpenGIS/waymark-wp#82 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
claude
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
sprain/sprainocchio#39 ·
Les mainteneurs répondent en général sous 1 jour