diff options
author | Johannes Winkelmann <jw@smts.ch> | 2006-02-23 14:18:42 +0000 |
---|---|---|
committer | Johannes Winkelmann <jw@smts.ch> | 2006-02-23 14:18:42 +0000 |
commit | b103cf5e680227d5214faba552fd6be8367a00aa (patch) | |
tree | 291fddef8614ca8e2d7076c194c2c83d4f54a0a9 | |
parent | 18c22c5a414a8beeac0d958ab39589c883ab06d4 (diff) | |
download | httpup-b103cf5e680227d5214faba552fd6be8367a00aa.tar.gz httpup-b103cf5e680227d5214faba552fd6be8367a00aa.tar.xz |
httpup: sync with bzr repo (0.4.0g)
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | configparser.cpp | 39 | ||||
-rw-r--r-- | configparser.h | 17 | ||||
-rw-r--r-- | httpup.conf.example | 3 | ||||
-rw-r--r-- | httpup.cpp | 13 | ||||
-rw-r--r-- | httpup.h | 2 |
8 files changed, 59 insertions, 24 deletions
@@ -7,3 +7,4 @@ THANKS: Simone Rota for testing and bug reports Jürgen Daubert for testing Han Boetes for optimizing the repgen script +Oleksiy V. Khilkevich for the operation_timeout patch prototype @@ -1,4 +1,8 @@ -* 0.4.0f 22.09.2005 Johannes Winkelmann +* 0.4.0g 23.02.2006 Johannes Winkelmann +- change default timeout to 60s +- add configuration variable for timeout: operation_timeout + + * 0.4.0f 22.09.2005 Johannes Winkelmann - remove deflate option again * 0.4.0e 20.09.2005 Johannes Winkelmann @@ -5,7 +5,7 @@ all: httpup ## Configuration # NAME=httpup -VERSION="0.4.0f" +VERSION="0.4.0g" CXX=g++ CXXFLAGS=-Wall -ansi -pedantic -DMF_VERSION='${VERSION}' LDFLAGS=-lcurl diff --git a/configparser.cpp b/configparser.cpp index bee5cf0..f6af600 100644 --- a/configparser.cpp +++ b/configparser.cpp @@ -3,10 +3,10 @@ // AUTHOR: Johannes Winkelmann, jw@tks6.net // COPYRIGHT: (c) 2002-2005 by Johannes Winkelmann // --------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. //////////////////////////////////////////////////////////////////////// #include <iostream> @@ -21,37 +21,44 @@ int ConfigParser::parseConfig(const std::string& fileName, if (!fp) { return -1; } - + char line[512]; string s; while (fgets(line, 512, fp)) { if (line[strlen(line)-1] == '\n') { line[strlen(line)-1] = '\0'; - } + } s = line; - + + // strip comments string::size_type pos = s.find("#"); if (pos != string::npos) { s = s.substr(0, pos); } - if (s.length() > 10) { - string key = s.substr(0, 10); - string val = stripWhiteSpace(s.substr(10)); + // whitespace separates + pos = s.find(' '); + if (pos == string::npos) { + pos = s.find('\t'); + } + if (pos != string::npos) { + string key = s.substr(0, pos); + string val = stripWhiteSpace(s.substr(pos)); if (key == "proxy_host") { config.proxyHost = val; - } else if (s.substr(0, 10) == "proxy_port") { + } else if (key == "proxy_port") { config.proxyPort = val; - } else if (s.substr(0, 10) == "proxy_user") { + } else if (key == "proxy_user") { config.proxyUser = val; - } else if (s.substr(0, 10) == "proxy_pass") { + } else if (key == "proxy_pass") { config.proxyPassword = val; + } else if (key == "operation_timeout") { + config.operationTimeout = val; } } - } - + fclose(fp); return 0; } @@ -65,6 +72,6 @@ string ConfigParser::stripWhiteSpace(const string& input) while (isspace(output[output.length()-1])) { output = output.substr(0, output.length()-1); } - + return output; } diff --git a/configparser.h b/configparser.h index a8386c6..febf687 100644 --- a/configparser.h +++ b/configparser.h @@ -3,10 +3,10 @@ // AUTHOR: Johannes Winkelmann, jw@tks6.net // COPYRIGHT: (c) 2002-2005 by Johannes Winkelmann // --------------------------------------------------------------------- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. //////////////////////////////////////////////////////////////////////// #ifndef _CONFIGPARSER_H_ @@ -16,12 +16,19 @@ struct Config { - Config() : proxyHost(""), proxyPort(""), proxyUser(""), proxyPassword("") + Config() + : proxyHost(""), + proxyPort(""), + proxyUser(""), + proxyPassword(""), + operationTimeout("") {} + std::string proxyHost; std::string proxyPort; std::string proxyUser; std::string proxyPassword; + std::string operationTimeout; }; class ConfigParser diff --git a/httpup.conf.example b/httpup.conf.example index 362f84c..ea28990 100644 --- a/httpup.conf.example +++ b/httpup.conf.example @@ -4,3 +4,6 @@ proxy_host http://test.proxy.ch proxy_port 80 proxy_user winkj proxy_pass very_secret + +# timeout settings +operation_timeout 60
\ No newline at end of file @@ -27,6 +27,7 @@ const string HttpUp::REPOCURRENTFILEOLD = "REPO.CURRENT"; const string HttpUp::REPOCURRENTFILE = ".httpup-repo.current"; const string HttpUp::URLINFO = ".httpup-urlinfo"; +const int HttpUp::DEFAULT_TIMEOUT = 60; HttpUp::HttpUp(const HttpupArgparser& argParser, const string& url, const string& target, @@ -227,8 +228,18 @@ int HttpUp::exec(ExecType type) curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); + long timeout = DEFAULT_TIMEOUT; + if (config.operationTimeout != "") { + char* end = 0; + long config_timeout = 0; + config_timeout = strtol(config.operationTimeout.c_str(), &end, 10); + if (*end == 0) { + timeout = config_timeout; + } + } + curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); + // proxy, proxy auth if (config.proxyHost != "") { @@ -49,6 +49,8 @@ public: static const std::string REPOCURRENTFILE; static const std::string REPOCURRENTFILEOLD; static const std::string URLINFO; + + static const int DEFAULT_TIMEOUT; private: int syncOrReturn(CURL* curl, char* curlErrorBuffer); |