-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_https.py
More file actions
61 lines (49 loc) · 1.71 KB
/
Copy pathdebug_https.py
File metadata and controls
61 lines (49 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
"""
Debug the HTTPS redirect issue
"""
import requests
import urllib3
# Disable SSL warnings for testing
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def debug_https_issue():
"""Debug the HTTPS redirect issue"""
print("🔍 Debugging HTTPS redirect issue...")
# Test with explicit HTTP and allow redirects
try:
response = requests.get(
"http://127.0.0.1:5001/api/v1/health",
allow_redirects=False,
timeout=5
)
print(f"Direct HTTP (no redirects): {response.status_code}")
print(f"Headers: {dict(response.headers)}")
if response.status_code in [301, 302, 307, 308]:
print(f"Redirect location: {response.headers.get('Location', 'No location')}")
except Exception as e:
print(f"Error: {str(e)}")
# Test with following redirects
try:
response = requests.get(
"http://127.0.0.1:5001/api/v1/health",
allow_redirects=True,
timeout=5,
verify=False # Ignore SSL verification
)
print(f"With redirects: {response.status_code}")
print(f"Final URL: {response.url}")
print(f"Response: {response.text[:200]}")
except Exception as e:
print(f"Error with redirects: {str(e)}")
# Test the root endpoint
try:
response = requests.get(
"http://127.0.0.1:5001/",
allow_redirects=False,
timeout=5
)
print(f"Root endpoint: {response.status_code}")
except Exception as e:
print(f"Root endpoint error: {str(e)}")
if __name__ == "__main__":
debug_https_issue()