-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_headers.py
More file actions
executable file
·55 lines (47 loc) · 1.47 KB
/
Copy pathdebug_headers.py
File metadata and controls
executable file
·55 lines (47 loc) · 1.47 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
#!/usr/bin/env python3
"""调试工具:输出实际发送到CodeBuddy的headers"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from codebuddy_proxy.codebuddy_client_demo import CodeBuddyClient
import json
def main():
client = CodeBuddyClient()
print("=" * 60)
print("当前Session信息")
print("=" * 60)
print(json.dumps(client.session, indent=2, ensure_ascii=False))
print("\n" + "=" * 60)
print("auth_headers() 输出")
print("=" * 60)
headers = client.auth_headers()
for k, v in headers.items():
print(f"{k}: {v}")
print("\n" + "=" * 60)
print("完整请求Headers(模拟聊天请求)")
print("=" * 60)
full_headers = {
"User-Agent": "Mozilla/5.0 (compatible; Genie-IDE/1.0)",
"X-Product-Code": "codebuddy",
**headers,
"Content-Type": "application/json",
"Accept": "text/event-stream",
}
for k, v in sorted(full_headers.items()):
print(f"{k}: {v}")
print("\n" + "=" * 60)
print("可能遗漏的Headers(根据插件分析)")
print("=" * 60)
missing_candidates = [
"X-IDE-Name",
"X-IDE-Type",
"X-IDE-Version",
"X-Machine-Id",
"X-Product-Version",
"X-Session-ID",
]
for header in missing_candidates:
status = "✅" if header in full_headers else "❌"
print(f"{status} {header}")
if __name__ == "__main__":
main()