MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / gguf_http_get

Function gguf_http_get

tests/gguf-model-data.cpp:413–443  ·  view source on GitHub ↗

HuggingFace file auto-detection and HTTP download

Source from the content-addressed store, hash-verified

411
412// HuggingFace file auto-detection and HTTP download
413static std::pair<long, std::vector<char>> gguf_http_get(
414 const std::string & url,
415 const httplib::Headers & headers = {},
416 int timeout_sec = 60) {
417 try {
418 auto [cli, parts] = common_http_client(url);
419
420 if (timeout_sec > 0) {
421 cli.set_read_timeout(timeout_sec, 0);
422 cli.set_write_timeout(timeout_sec, 0);
423 }
424 cli.set_connection_timeout(30, 0);
425
426 std::vector<char> body;
427 auto res = cli.Get(parts.path, headers,
428 [&](const char * data, size_t len) {
429 body.insert(body.end(), data, data + len);
430 return true;
431 }, nullptr);
432
433 if (!res) {
434 fprintf(stderr, "gguf_fetch: HTTP request failed for %s (error %d)\n",
435 url.c_str(), (int)res.error());
436 return {-1, {}};
437 }
438 return {res->status, std::move(body)};
439 } catch (const std::exception & e) {
440 fprintf(stderr, "gguf_fetch: HTTP error: %s\n", e.what());
441 return {-1, {}};
442 }
443}
444
445// Find the filename for given repo/quant.
446// For split models, returns the first shard (the one containing "00001-of-")

Callers 2

detect_gguf_filenameFunction · 0.85
fetch_and_parseFunction · 0.85

Calls 5

common_http_clientFunction · 0.85
endMethod · 0.80
insertMethod · 0.45
errorMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected