streamlit/streamlit#1083 (comment)
from streamlit.server.Server import Server
import streamlit as st
def get_headers():
# Hack to get the session object from Streamlit.
current_server = Server.get_current()
if hasattr(current_server, '_session_infos'):
# Streamlit < 0.56
session_infos = Server.get_current()._session_infos.values()
else:
session_infos = Server.get_current()._session_info_by_id.values()
# Multiple Session Objects?
for session_info in session_infos:
headers = session_info.ws.request.headers
st.write(headers)
# return headers