chore: port lab4 solution as lab5 base

This commit is contained in:
2026-11-15 14:42:12 +03:00
parent 276dbdad8a
commit 19dda6e286
90 changed files with 18537 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
import sys
import urllib.error
import urllib.request
bucket, key = sys.argv[1:3]
base = 'http://s3:9000/' + bucket
attempts = (
('GET', '/<object>', base + '/' + key, None),
('GET', '/', base + '/', None),
('PUT', '/anon.txt', base + '/anon.txt', b'x'),
)
failed = False
for method, label, url, data in attempts:
try:
code = urllib.request.urlopen(urllib.request.Request(url, data=data, method=method), timeout=5).status
except urllib.error.HTTPError as error:
code = error.code
print(method, bucket + label, '->', code)
failed = failed or code != 403
sys.exit(1 if failed else 0)