- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.3k
 
Description
Notice
If you need support or clarification regarding the usage of Drogon in your project, visit the official Drogon support channel at gitter
Please create a new issue only if you think you have found a bug or if have a feature request/enhancement.
Describe the bug
I have a method which receives json documents:
void ServiceController::SaveDocument(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)>&& callback)
{
    std::string session_id;
    if (!GetSessionId(req, callback, session_id))
        return;
    GetLogger(session_id)->Debug("SaveDocument request");
    for (const auto &h : req->getHeaders())
        GetLogger(session_id)->Debug("{}:{}", h.first, h.second);
    GetLogger(session_id)->Debug("Body length: {}", req->getBody().size());
    GetLogger(session_id)->Debug("Body: {}", req->getBody());
    auto json = req->getJsonObject();
    if (!json || !json->isObject())
    {
        GetLogger(session_id)->Error("SaveDocument error: Wrong request: Json not found in the request");
        SendError(k400BadRequest, "Json not found in the request", session_id, callback);
        return;
    }
...
}
I log the received request in it.
I send a large json - the method works fine. I send many large documents - the method works fine. After I send the same document - getJsonObject() returns null.
I dig into the problem, wrote a request with a little json file, which works fine:
curl -v -X POST http://127.0.0.1:9001/service/save-document -H "Content-Type: application/json" -H "access_token:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3MtdXVpZCI6IjJhNjc5NTY4LWU3Y2QtNDM0ZC1hNTJkLTJiMTI5YWVkYzcwMyIsImV4cCI6MTc2MTc0NjU4OSwiaWF0IjoxNzYxNzQ2NDY5LCJpc3MiOiJhdXRoMCIsImp0aSI6Inl1dG92by1zZXJ2ZXIiLCJsb2dpbiI6InVzZXIyIn0.CO3XzGEThd4V1IB-Wpy_gHBeKzIc4Rwamy7eX-QQj_uoBmMzvSluY3Kv56T7mhd3nk8BcF_dTooU2FEH1Fim_TvmWj6ZQvb_BvsqXEBEzw_Ng5NN4xMkjVEckXbiODbEtATjIqtLBm7MSo3KBovSWIVHLIVj0QcVSaY_A5r2RPNKKshQ-X87iot8-bwg-VGmVK64eQAEaXXY8psolVNKJ0z5VoVkg1xEoVv8sfmNgKHdWAfsrusa2bhjsEuDp36IMBXr6Le3MGcGaoPE736-gWdc3Ocjl5OgX3BV6Tkm-hi6r-W0QsWmFrEH3JShpTvvp7B9c_PtU_mqLK5UFBkwRQ" -H "Cookie:session_id=e264b882-1f03-4297-94d5-cd898b06d642;JSESSIONID=36bd6810-0af8-4c24-9ef6-90b18ff03502" --upload-file /home/denis/programs/Math/yutovo/yutovo-desktop/build/debug/22
*   Trying 127.0.0.1:9001...
* Connected to 127.0.0.1 (127.0.0.1) port 9001
> POST /service/save-document HTTP/1.1
> Host: 127.0.0.1:9001
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> access_token:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3MtdXVpZCI6IjJhNjc5NTY4LWU3Y2QtNDM0ZC1hNTJkLTJiMTI5YWVkYzcwMyIsImV4cCI6MTc2MTc0NjU4OSwiaWF0IjoxNzYxNzQ2NDY5LCJpc3MiOiJhdXRoMCIsImp0aSI6Inl1dG92by1zZXJ2ZXIiLCJsb2dpbiI6InVzZXIyIn0.CO3XzGEThd4V1IB-Wpy_gHBeKzIc4Rwamy7eX-QQj_uoBmMzvSluY3Kv56T7mhd3nk8BcF_dTooU2FEH1Fim_TvmWj6ZQvb_BvsqXEBEzw_Ng5NN4xMkjVEckXbiODbEtATjIqtLBm7MSo3KBovSWIVHLIVj0QcVSaY_A5r2RPNKKshQ-X87iot8-bwg-VGmVK64eQAEaXXY8psolVNKJ0z5VoVkg1xEoVv8sfmNgKHdWAfsrusa2bhjsEuDp36IMBXr6Le3MGcGaoPE736-gWdc3Ocjl5OgX3BV6Tkm-hi6r-W0QsWmFrEH3JShpTvvp7B9c_PtU_mqLK5UFBkwRQ
> Cookie:session_id=e264b882-1f03-4297-94d5-cd898b06d642;JSESSIONID=36bd6810-0af8-4c24-9ef6-90b18ff03502
> Content-Length: 23400
> 
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< content-length: 31
< content-type: application/json; charset=utf-8
< server: drogon/1.9.10
< date: Wed, 29 Oct 2025 18:35:00 GMT
< 
* Connection #0 to host 127.0.0.1 left intact
After I take a file with more size, the method doesn't work:
curl -v -X POST http://127.0.0.1:9001/service/save-document -H "Content-Type: application/json" -H "access_token:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3MtdXVpZCI6IjJhNjc5NTY4LWU3Y2QtNDM0ZC1hNTJkLTJiMTI5YWVkYzcwMyIsImV4cCI6MTc2MTc0NjU4OSwiaWF0IjoxNzYxNzQ2NDY5LCJpc3MiOiJhdXRoMCIsImp0aSI6Inl1dG92by1zZXJ2ZXIiLCJsb2dpbiI6InVzZXIyIn0.CO3XzGEThd4V1IB-Wpy_gHBeKzIc4Rwamy7eX-QQj_uoBmMzvSluY3Kv56T7mhd3nk8BcF_dTooU2FEH1Fim_TvmWj6ZQvb_BvsqXEBEzw_Ng5NN4xMkjVEckXbiODbEtATjIqtLBm7MSo3KBovSWIVHLIVj0QcVSaY_A5r2RPNKKshQ-X87iot8-bwg-VGmVK64eQAEaXXY8psolVNKJ0z5VoVkg1xEoVv8sfmNgKHdWAfsrusa2bhjsEuDp36IMBXr6Le3MGcGaoPE736-gWdc3Ocjl5OgX3BV6Tkm-hi6r-W0QsWmFrEH3JShpTvvp7B9c_PtU_mqLK5UFBkwRQ" -H "Cookie:session_id=e264b882-1f03-4297-94d5-cd898b06d642;JSESSIONID=36bd6810-0af8-4c24-9ef6-90b18ff03502" --upload-file /home/denis/programs/Math/yutovo/yutovo-desktop/build/debug/33
*   Trying 127.0.0.1:9001...
* Connected to 127.0.0.1 (127.0.0.1) port 9001
> POST /service/save-document HTTP/1.1
> Host: 127.0.0.1:9001
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> access_token:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3MtdXVpZCI6IjJhNjc5NTY4LWU3Y2QtNDM0ZC1hNTJkLTJiMTI5YWVkYzcwMyIsImV4cCI6MTc2MTc0NjU4OSwiaWF0IjoxNzYxNzQ2NDY5LCJpc3MiOiJhdXRoMCIsImp0aSI6Inl1dG92by1zZXJ2ZXIiLCJsb2dpbiI6InVzZXIyIn0.CO3XzGEThd4V1IB-Wpy_gHBeKzIc4Rwamy7eX-QQj_uoBmMzvSluY3Kv56T7mhd3nk8BcF_dTooU2FEH1Fim_TvmWj6ZQvb_BvsqXEBEzw_Ng5NN4xMkjVEckXbiODbEtATjIqtLBm7MSo3KBovSWIVHLIVj0QcVSaY_A5r2RPNKKshQ-X87iot8-bwg-VGmVK64eQAEaXXY8psolVNKJ0z5VoVkg1xEoVv8sfmNgKHdWAfsrusa2bhjsEuDp36IMBXr6Le3MGcGaoPE736-gWdc3Ocjl5OgX3BV6Tkm-hi6r-W0QsWmFrEH3JShpTvvp7B9c_PtU_mqLK5UFBkwRQ
> Cookie:session_id=e264b882-1f03-4297-94d5-cd898b06d642;JSESSIONID=36bd6810-0af8-4c24-9ef6-90b18ff03502
> Content-Length: 201447
> 
* We are completely uploaded and fine
< HTTP/1.1 400 Bad Request
< content-length: 41
< content-type: application/json; charset=utf-8
< server: drogon/1.9.10
< date: Wed, 29 Oct 2025 18:34:55 GMT
< 
* Connection #0 to host 127.0.0.1 left intact
{"error":"Json not found in the request"}%              
I found the setClientMaxBodySize() method, and will check it. The question is: why large json documents were recognized in the beginning, but after some iterations were not? Is it well behavior? Is there a cache which accumulates?
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
 - Click on '....'
 - Scroll down to '....'
 - See error
 
Expected behavior
The server processes large json requests without errors and regardless their quantity.
Desktop (please complete the following information):
- OS: Ubuntu 24.04
 - Browser curl
 
Additional context
Add any other context about the problem here.