00001 // Filename: config_downloader.cxx 00002 // Created by: mike (19Mar00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "dconfig.h" 00020 #include "get_config_path.h" 00021 #include "config_downloader.h" 00022 #include "httpChannel.h" 00023 00024 00025 ConfigureDef(config_downloader); 00026 NotifyCategoryDef(downloader, ""); 00027 00028 // How often we write to disk is determined by this ratio which is 00029 // relative to the downloader-byte-rate (e.g. if disk-write-ratio is 4, 00030 // we will write every 4 seconds if the frequency is 0.2) 00031 const int downloader_disk_write_frequency = 00032 config_downloader.GetInt("downloader-disk-write-frequency", 4); 00033 00034 // We'd like this to be about 1 second worth of download assuming a 00035 // 28.8Kb connection (28.8Kb / 8 = 3600 bytes per second). 00036 const int downloader_byte_rate = 00037 config_downloader.GetInt("downloader-byte-rate", 3600); 00038 00039 // Frequency of download chunk requests in seconds (or fractions of) 00040 // (Estimated 200 msec round-trip to server). 00041 const float downloader_frequency = 00042 config_downloader.GetFloat("downloader-frequency", 0.2); 00043 00044 const int downloader_timeout = 00045 config_downloader.GetInt("downloader-timeout", 15); 00046 00047 const int downloader_timeout_retries = 00048 config_downloader.GetInt("downloader-timeout-retries", 5); 00049 00050 const int decompressor_buffer_size = 00051 config_downloader.GetInt("decompressor-buffer-size", 4096); 00052 00053 const float decompressor_frequency = 00054 config_downloader.GetFloat("decompressor-frequency", 0.2); 00055 00056 const int extractor_buffer_size = 00057 config_downloader.GetInt("extractor-buffer-size", 4096); 00058 00059 const float extractor_frequency = 00060 config_downloader.GetFloat("extractor-frequency", 0.2); 00061 00062 const int patcher_buffer_size = 00063 config_downloader.GetInt("patcher-buffer-size", 4096); 00064 00065 // Configure this true (the default) to compute the SSL random seed 00066 // early on in the application (specifically, when the first 00067 // HTTPClient is created), or false to defer this until it is actually 00068 // needed, causing a delay the first time a https connection is 00069 // attempted. 00070 const bool early_random_seed = 00071 config_downloader.GetBool("early-random-seed", true); 00072 00073 // Configure this true (the default) to insist on verifying all SSL 00074 // (e.g. https) servers against a known certificate, or false to allow 00075 // an unverified connection. This controls the default behavior; the 00076 // specific behavior for a particular HTTPClient can be adjusted at 00077 // runtime with set_verify_ssl(). 00078 const bool verify_ssl = 00079 config_downloader.GetBool("verify-ssl", true); 00080 00081 // This specifies the proxy that we will contact for all HTTP 00082 // connections that don't specify otherwise. 00083 const string http_proxy = 00084 config_downloader.GetString("http-proxy", ""); 00085 const string http_proxy_username = 00086 config_downloader.GetString("http-proxy-username", ""); 00087 00088 // This is the default amount of time to wait for a TCP/IP connection 00089 // to be established, in seconds. It is presently only used for 00090 // nonblocking sockets. 00091 const double connect_timeout = 00092 config_downloader.GetDouble("connect-timeout", 5.0); 00093 00094 // This is the default amount of time to wait for the HTTP server to 00095 // finish sending its response to our request, in seconds. It starts 00096 // counting after the TCP connection has been established 00097 // (connect_timeout, above) and the request has been sent. 00098 const double http_timeout = 00099 config_downloader.GetDouble("http-timeout", 20.0); 00100 00101 // This is the maximum number of times to try reconnecting to the 00102 // server on any one document attempt. This is just a failsafe to 00103 // prevent the code from attempting runaway connections; this limit 00104 // should never be reached in practice. 00105 const int http_max_connect_count = 00106 config_downloader.GetInt("http-max-connect-count", 10); 00107 00108 ConfigureFn(config_downloader) { 00109 #ifdef HAVE_SSL 00110 HTTPChannel::init_type(); 00111 #endif 00112 }