mirror of
https://github.com/flatpak/flatpak.git
synced 2026-01-26 06:07:56 +00:00
tests/oci-registry-client.py: Parse URL parameter
This commit is contained in:
parent
82706e6d28
commit
34acb5799e
@ -6,6 +6,11 @@ import http.client
|
||||
import urllib.parse
|
||||
|
||||
|
||||
def get_conn(url):
|
||||
parsed = urllib.parse.urlparse(url)
|
||||
return http.client.HTTPConnection(host=parsed.hostname, port=parsed.port)
|
||||
|
||||
|
||||
if sys.argv[2] == 'add':
|
||||
detach_icons = '--detach-icons' in sys.argv
|
||||
if detach_icons:
|
||||
@ -14,7 +19,7 @@ if sys.argv[2] == 'add':
|
||||
if detach_icons:
|
||||
params['detach-icons'] = 1
|
||||
query = urllib.parse.urlencode(params)
|
||||
conn = http.client.HTTPConnection(sys.argv[1])
|
||||
conn = get_conn(sys.argv[1])
|
||||
path = "/testing/{repo}/{tag}?{query}".format(repo=sys.argv[3],
|
||||
tag=sys.argv[4],
|
||||
query=query)
|
||||
@ -25,7 +30,7 @@ if sys.argv[2] == 'add':
|
||||
print("Failed: status={}".format(response.status), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
elif sys.argv[2] == 'delete':
|
||||
conn = http.client.HTTPConnection(sys.argv[1])
|
||||
conn = get_conn(sys.argv[1])
|
||||
path = "/testing/{repo}/{ref}".format(repo=sys.argv[3],
|
||||
ref=sys.argv[4])
|
||||
conn.request("DELETE", path)
|
||||
|
||||
@ -29,7 +29,7 @@ echo "1..14"
|
||||
|
||||
httpd oci-registry-server.py .
|
||||
port=$(cat httpd-port)
|
||||
client="python3 $test_srcdir/oci-registry-client.py 127.0.0.1:$port"
|
||||
client="python3 $test_srcdir/oci-registry-client.py http://127.0.0.1:$port"
|
||||
|
||||
setup_repo_no_add oci
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user