2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-01-20 23:22:22 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#ifndef _FILE_XFER_
|
|
|
|
#define _FILE_XFER_
|
|
|
|
|
2006-01-18 21:07:04 +00:00
|
|
|
// A FILE_XFER object represents a file transfer "episode"
|
|
|
|
// (see pers_file_xfer.h), i.e. an HTTP transaction with a
|
|
|
|
// particular data server.
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-06-01 20:26:21 +00:00
|
|
|
#include "client_types.h"
|
2005-08-09 22:01:28 +00:00
|
|
|
#include "http_curl.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2006-01-18 21:07:04 +00:00
|
|
|
#define MIN_DOWNLOAD_INCREMENT 5000
|
2009-07-16 20:14:57 +00:00
|
|
|
#define FILE_SIZE_CHECK_THRESHOLD 8192
|
|
|
|
// upload: skip file size check if file is smaller than this
|
2006-01-18 21:07:04 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
class FILE_XFER : public HTTP_OP {
|
|
|
|
public:
|
|
|
|
FILE_INFO* fip;
|
2002-07-05 05:33:40 +00:00
|
|
|
char pathname[256];
|
|
|
|
char header[4096];
|
2002-08-21 19:12:42 +00:00
|
|
|
bool file_size_query;
|
2003-05-10 00:52:36 +00:00
|
|
|
bool is_upload;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// File size at start of transfer, used for:
|
|
|
|
/// 1) a "minimum download increment"
|
|
|
|
/// that rejects partial downloads of less than 5K,
|
|
|
|
/// since these may be error messages from proxies.
|
|
|
|
/// 2) lets us recover when server ignored Range request
|
|
|
|
/// and sent us whole file
|
2006-01-18 21:07:04 +00:00
|
|
|
double starting_size;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
FILE_XFER();
|
|
|
|
~FILE_XFER();
|
|
|
|
|
2003-09-30 18:09:58 +00:00
|
|
|
int parse_upload_response(double &offset);
|
2002-07-05 05:33:40 +00:00
|
|
|
int init_download(FILE_INFO&);
|
|
|
|
int init_upload(FILE_INFO&);
|
2002-04-30 22:22:54 +00:00
|
|
|
bool file_xfer_done;
|
|
|
|
int file_xfer_retval;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FILE_XFER_SET {
|
|
|
|
HTTP_OP_SET* http_ops;
|
|
|
|
public:
|
2008-10-04 23:44:24 +00:00
|
|
|
/// has there been transfer activity since last call to check_active()?
|
2005-11-25 18:17:09 +00:00
|
|
|
bool up_active, down_active;
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_XFER*> file_xfers;
|
2002-04-30 22:22:54 +00:00
|
|
|
FILE_XFER_SET(HTTP_OP_SET*);
|
|
|
|
int insert(FILE_XFER*);
|
|
|
|
int remove(FILE_XFER*);
|
2005-06-07 19:22:50 +00:00
|
|
|
bool poll();
|
2005-11-25 18:17:09 +00:00
|
|
|
void check_active(bool&, bool&);
|
2006-10-02 16:13:08 +00:00
|
|
|
void set_bandwidth_limits(bool is_upload);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|