MCPcopy Create free account
hub / github.com/acl-dev/acl / send_file

Method send_file

lib_acl_cpp/src/http/http_request.cpp:547–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547bool http_request::send_file(const char *filepath) const {
548 // ���뱣֤�������Ѿ���
549 if (client_ == NULL) {
550 logger_error("connection not opened yet!");
551 return false;
552 }
553
554 client_->reset(); // ����״̬
555
556 // д HTTP ����ͷ
557 if (!client_->write_head(header_)) {
558 return false;
559 }
560
561 ifstream in;
562 if (!in.open_read(filepath)) {
563 logger_error("open %s error: %s", filepath, last_serror());
564 return false;
565 }
566
567 char buf[8192];
568 while (!in.eof()) {
569 const int ret = in.read(buf, sizeof(buf), false);
570 if (ret <= 0) {
571 break;
572 }
573 if (!client_->write_body(buf, ret)) {
574 return false;
575 }
576 }
577 return true;
578}
579
580bool http_request::upload(http_mime &mime, const char *filepath, bool savefile) {
581 if (filepath == NULL || filepath[0] == '\0') {

Callers

nothing calls this directly

Calls 7

last_serrorFunction · 0.50
resetMethod · 0.45
write_headMethod · 0.45
open_readMethod · 0.45
eofMethod · 0.45
readMethod · 0.45
write_bodyMethod · 0.45

Tested by

no test coverage detected