File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ def __init__(
3333 user_agent : str = DEFAULT_USER_AGENT ,
3434 connect_timeout : int = 5 ,
3535 max_time : int = 10 ,
36+ max_redirects : int = 3 ,
3637 ) -> None :
3738 self .url = url
3839 self ._stderr : Optional [str ] = None
@@ -41,14 +42,20 @@ def __init__(
4142 [
4243 "curl" ,
4344 "-sSf" ,
45+ "-L" , # follow redirects
46+ "--max-redirs" ,
47+ f"{ max_redirects } " , # limit number of redirects
48+ # "--proto", "=https", # (optional) only allow https for the initial URL
49+ "--proto-redir" ,
50+ "=all,https" , # only allow https after redirects; http will fail
4451 "--output" ,
45- "-" ,
52+ "-" , # discard body
4653 "--connect-timeout" ,
47- str ( connect_timeout ) ,
54+ f" { connect_timeout } " ,
4855 "--max-time" ,
49- str ( max_time ) ,
56+ f" { max_time } " ,
5057 "--user-agent" ,
51- user_agent ,
58+ f" { user_agent } " ,
5259 self .url ,
5360 ],
5461 stdout = open (os .devnull , "w" ),
You can’t perform that action at this time.
0 commit comments