| @@ -58,14 +58,14 @@ impl crate::Repository { · 57 unmodified lines |
| 58 | value_name, | 58 | value_name, |
| 59 | .. | 59 | .. |
| 60 | } = git_config::parse::key(key).expect("valid key statically known"); | 60 | } = git_config::parse::key(key).expect("valid key statically known"); |
| 61 | let integer = config | 61 | let integer = check_lenient( |
| 62 | .integer_filter(section_name, None, value_name, &mut filter) | 62 | config |
| 63 | .transpose() | 63 | .integer_filter(section_name, None, value_name, &mut filter) |
| 64 | .map_err(|err| crate::config::transport::Error::ConfigValue { | 64 | .transpose() |
| 65 | source: err, | 65 | .map_err(|err| crate::config::transport::Error::ConfigValue { source: err, key }), |
| 66 | key: "http.lowSpeedTime", | 66 | lenient, |
| 67 | })? | 67 | )? |
| 68 | .unwrap_or_default(); | 68 | .unwrap_or_default(); |
| 69 | check_lenient_default( | 69 | check_lenient_default( |
| 70 | integer | 70 | integer |
| 71 | .try_into() | 71 | .try_into() |
| @@ -78,6 +78,42 @@ impl crate::Repository { · 6 unmodified lines |
| 78 | || default, | 78 | || default, |
| 79 | ) | 79 | ) |
| 80 | } | 80 | } |
| | 81 | fn integer_opt<T>( |
| | 82 | config: &git_config::File<'static>, |
| | 83 | lenient: bool, |
| | 84 | key: &'static str, |
| | 85 | kind: &'static str, |
| | 86 | mut filter: fn(&git_config::file::Metadata) -> bool, |
| | 87 | ) -> Result<Option<T>, crate::config::transport::Error> |
| | 88 | where |
| | 89 | T: TryFrom<i64>, |
| | 90 | { |
| | 91 | let git_config::parse::Key { |
| | 92 | section_name, |
| | 93 | subsection_name, |
| | 94 | value_name, |
| | 95 | } = git_config::parse::key(key).expect("valid key statically known"); |
| | 96 | check_lenient( |
| | 97 | check_lenient( |
| | 98 | config |
| | 99 | .integer_filter(section_name, subsection_name, value_name, &mut filter) |
| | 100 | .transpose() |
| | 101 | .map_err(|err| crate::config::transport::Error::ConfigValue { source: err, key }), |
| | 102 | lenient, |
| | 103 | )? |
| | 104 | .map(|integer| { |
| | 105 | integer |
| | 106 | .try_into() |
| | 107 | .map_err(|_| crate::config::transport::Error::InvalidInteger { |
| | 108 | actual: integer, |
| | 109 | key, |
| | 110 | kind, |
| | 111 | }) |
| | 112 | }) |
| | 113 | .transpose(), |
| | 114 | lenient, |
| | 115 | ) |
| | 116 | } |
| 81 | let mut opts = http::Options::default(); | 117 | let mut opts = http::Options::default(); |
| 82 | let config = &self.config.resolved; | 118 | let config = &self.config.resolved; |
| 83 | let mut trusted_only = self.filter_config_section(); | 119 | let mut trusted_only = self.filter_config_section(); |
| @@ -140,6 +176,9 @@ impl crate::Repository { · 56 unmodified lines |
| 140 | proxy | 176 | proxy |
| 141 | } | 177 | } |
| 142 | }); | 178 | }); |
| | 179 | opts.connect_timeout = |
| | 180 | integer_opt(config, lenient, "gitoxide.http.connectTimeout", "u64", trusted_only)? |
| | 181 | .map(std::time::Duration::from_millis); |
| 143 | opts.user_agent = config | 182 | opts.user_agent = config |
| 144 | .string_filter("http", None, "userAgent", &mut trusted_only) | 183 | .string_filter("http", None, "userAgent", &mut trusted_only) |
| 145 | .and_then(|v| try_cow_to_string(v, lenient, "http.userAgent").transpose()) | 184 | .and_then(|v| try_cow_to_string(v, lenient, "http.userAgent").transpose()) |