MCPcopy
hub / github.com/Sophomoresty/gemini-web2api / _build_headers

Function _build_headers

gemini_web2api/gemini.py:88–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87
88def _build_headers() -> dict:
89 account_prefix = _account_prefix()
90 headers = {
91 "Content-Type": "application/x-www-form-urlencoded",
92 "Origin": "https://gemini.google.com",
93 "Referer": f"https://gemini.google.com{account_prefix}/app",
94 "X-Same-Domain": "1",
95 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
96 }
97 if account_prefix:
98 headers["X-Goog-AuthUser"] = str(CONFIG["auth_user"])
99 cookie_str, sapisid = load_cookie()
100 if cookie_str:
101 headers["Cookie"] = cookie_str
102 if sapisid:
103 headers["Authorization"] = make_sapisidhash(sapisid)
104 return headers
105
106
107def _build_payload(prompt: str, model_id: int, think_mode: int, file_refs: list = None, extra_fields: dict = None) -> str:

Callers 2

generateFunction · 0.85
generate_streamFunction · 0.85

Calls 3

_account_prefixFunction · 0.85
load_cookieFunction · 0.70
make_sapisidhashFunction · 0.70

Tested by

no test coverage detected