server: split HTTP into its own interface#17216
Merged
ngxson merged 23 commits intoggml-org:masterfrom Nov 17, 2025
Merged
Conversation
0594df9 to
45b2fe1
Compare
Collaborator
Author
|
No rush for reviewing this, would appreciate if you can do some testings on your side @ggerganov In the next PR, I'll try to break the
While working on this, I'm also thinking about maybe re-using server code in |
This was referenced Nov 13, 2025
5 tasks
ggerganov
approved these changes
Nov 17, 2025
ronaldmannak
pushed a commit
to PicoMLX/llama.cpp
that referenced
this pull request
Nov 19, 2025
* server: split HTTP into its own interface * move server-http and httplib to its own file * add the remaining endpoints * fix exception/error handling * renaming * missing header * fix missing windows header * fix error responses from http layer * fix slot save/restore handler * fix case where only one stream chunk is returned * add NOMINMAX * do not call sink.write on empty data * use safe_json_to_str for SSE * clean up * add some comments * improve usage of next() * bring back the "server is listening on" message * more generic handler * add req.headers * move the chat template print to init() * add req.path * cont : minor --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This was referenced Nov 27, 2025
Open
Anico2
added a commit
to Anico2/llama.cpp
that referenced
this pull request
Jan 15, 2026
* server: split HTTP into its own interface * move server-http and httplib to its own file * add the remaining endpoints * fix exception/error handling * renaming * missing header * fix missing windows header * fix error responses from http layer * fix slot save/restore handler * fix case where only one stream chunk is returned * add NOMINMAX * do not call sink.write on empty data * use safe_json_to_str for SSE * clean up * add some comments * improve usage of next() * bring back the "server is listening on" message * more generic handler * add req.headers * move the chat template print to init() * add req.path * cont : minor --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
blime4
referenced
this pull request
in blime4/llama.cpp
Feb 5, 2026
* server: split HTTP into its own interface * move server-http and httplib to its own file * add the remaining endpoints * fix exception/error handling * renaming * missing header * fix missing windows header * fix error responses from http layer * fix slot save/restore handler * fix case where only one stream chunk is returned * add NOMINMAX * do not call sink.write on empty data * use safe_json_to_str for SSE * clean up * add some comments * improve usage of next() * bring back the "server is listening on" message * more generic handler * add req.headers * move the chat template print to init() * add req.path * cont : minor --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #16488
How it works:
sequenceDiagram participant User participant server_http_context participant server_http_res User->>server_http_context: request server_http_context->>server_http_req: create request server_http_req->>handler: handler->>server_http_res: create response loop for each result server_http_res->>server_http_context: response chunk server_http_context->>User: response chunk server_http_context->>server_http_res: next() end server_http_res->>server_http_context: terminate server_http_context->>User: close connectionserver_res_generator, which is a derived class fromserver_http_resserver_res_generatorindicates one of 2 modes: stream or non-streamserver_res_generator::next()until it returnsfalse. Each time we callnext(), we get a new chunk of dataTODO:
server_routeslevelTesting:
tests.sh