@@ -169,6 +169,7 @@ def parse_args(
169169 )
170170 # Arguments processing and environment setup.
171171 self ._apply_no_options (no_options )
172+ self ._process_http_versions ()
172173 self ._process_request_type ()
173174 self ._process_download_options ()
174175 self ._setup_standard_streams ()
@@ -213,6 +214,38 @@ def parse_args(
213214
214215 return self .args
215216
217+ def _process_http_versions (self ):
218+ available , forced , disabled = (
219+ {1 , 2 , 3 },
220+ {
221+ self .args .force_http1 and 1 ,
222+ self .args .force_http2 and 2 ,
223+ self .args .force_http3 and 3 ,
224+ } - {False },
225+ {
226+ self .args .disable_http1 and 1 ,
227+ self .args .disable_http2 and 2 ,
228+ self .args .disable_http3 and 3 ,
229+ } - {False },
230+ )
231+ if forced and disabled :
232+ self .error (
233+ 'You cannot both force a http protocol version and disable some other. e.g. '
234+ '--http2 already force HTTP/2, do not use --disable-http1 at the same time.'
235+ )
236+ if len (forced ) > 1 :
237+ self .error (
238+ 'You may only force one of --http1, --http2 or --http3. Use --disable-http1, '
239+ '--disable-http2 or --disable-http3 instead if you prefer the excluding logic.'
240+ )
241+ if disabled == available :
242+ self .error ('At least one HTTP protocol version must be enabled.' )
243+
244+ if forced :
245+ self .args .disable_http1 = forced != {1 }
246+ self .args .disable_http2 = forced != {2 }
247+ self .args .disable_http3 = forced != {3 }
248+
216249 def _process_request_type (self ):
217250 request_type = self .args .request_type
218251 self .args .json = request_type is RequestType .JSON
0 commit comments