added more http versions flags
CI / build (push) Successful in 15s

This commit is contained in:
2024-09-15 14:48:42 +08:00
parent c00a8d1bd5
commit b56ddf528b
5 changed files with 206 additions and 57 deletions
+21 -11
View File
@@ -128,13 +128,11 @@ class JpacrepoClient:
cond: Condition
thread: Optional[Thread]
verbose: bool
http2: bool
http3: bool
http_version : int
def __init__(self, config: Config,
verbose: bool = False,
http2: bool = False,
http3: bool = False
**kwargs,
):
self.config: Config = config
self.token: Optional[TokenResponse] = None
@@ -143,8 +141,16 @@ class JpacrepoClient:
self.cond = Condition()
self.thread: Optional[Thread] = None
self.verbose: bool = verbose
self.http2: bool = http2
self.http3: bool = http3
if kwargs.get('http1.0'):
self.http_version = pycurl.CURL_HTTP_VERSION_1_0
elif kwargs.get('http1.1'):
self.http_version = pycurl.CURL_HTTP_VERSION_1_1
elif kwargs.get('http2'):
self.http_version = pycurl.CURL_HTTP_VERSION_2
elif kwargs.get('http3'):
self.http_version = pycurl.CURL_HTTP_VERSION_3
else:
self.http_version = pycurl.CURL_HTTP_VERSION_NONE
def __enter__(self) -> Self:
return self
@@ -311,11 +317,7 @@ class JpacrepoClient:
curl.setopt(pycurl.NOPROGRESS, False)
curl.setopt(pycurl.VERBOSE, self.verbose)
curl.setopt(pycurl.CAINFO, certifi.where())
if self.http2:
curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_2)
if self.http3:
curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_3)
curl.setopt(pycurl.HTTP_VERSION, self.http_version)
with open(str(file_path), 'rb') as file:
curl.setopt(pycurl.READDATA, file)
curl.perform()
@@ -333,6 +335,14 @@ def main() -> None:
default=False,
action='store_true',
help="Enable verbose output")
parser.add_argument('-0', '--http1.0',
default=True,
action='store_true',
help="Force HTTP/1.1 protocol")
parser.add_argument('-1', '--http1.1',
default=True,
action='store_true',
help="Force HTTP/1.1 protocol")
parser.add_argument('-2', '--http2',
default=True,
action='store_true',