Introduced in SQLPage 0.33.0.
Returns all HTTP request headers as a JSON object.
Example
The following displays all HTTP request headers in a list,
using SQLite's json_each()
function.
select 'list' as component;
select key as title, value as description
from json_each(sqlpage.headers()); -- json_each() is SQLite only
If not on SQLite, use your database's JSON function.
Details
The function returns a JSON object where:
- Keys are lowercase header names
- Values are the corresponding header values
- If no headers are present, returns an empty JSON object
{}
This is useful when you need to:
- Debug HTTP requests
- Access multiple headers at once
If you only need access to a single known header, use sqlpage.header(name)
instead.
basic_auth_password
basic_auth_username
client_ip
cookie
current_working_directory
environment_variable
exec
fetch
fetch_with_meta
hash_password
header
headers
link
path
persist_uploaded_file
protocol
random_string
read_file_as_data_url
read_file_as_text
request_body
request_body_base64
request_method
run_sql
uploaded_file_mime_type
uploaded_file_name
uploaded_file_path
url_encode
variables
version