Add HTTP Downstream Metadata API
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with stubs/wit_world/imports/http_downstream.py and compare its interface with the Request wrapper planned in issue #009. Review src/component/compute/http_downstream.rs and the Viceroy testing notes to separate supported metadata from stubbed TLS and fingerprint functions. Done means exposing the agreed downstream API and covering supported behavior, multi-request handling, and documented Viceroy limitations.
Written by the indexing model from the issue text.
Description
Overview
Add support for accessing downstream (incoming) HTTP request metadata, including client/server IP addresses, TLS connection details, security fingerprints, and compliance information.
Relationship to Issue #009: Issue #009 covers the low-level Request/Response wrappers. This issue (#014) specifically focuses on implementing the downstream metadata functions from the http-downstream WIT interface. These functions take a Request and return metadata, and will likely be exposed via a request.downstream accessor as shown in #009's examples.
WIT Interface
interface http-downstream {
use http-req.{request, client-cert-verify-result};
use types.{ip-address, error};
use http-body.body;
use async-io.pollable;
// Multi-request handling
next-request: func(options: next-request-options) -> result<pending-request, error>;
await-request: func(pending: pending-request) -> result<option<tuple<request, body>>, error>;
// IP addresses
downstream-client-ip-addr: func(ds-request: request) -> option<ip-address>;
downstream-server-ip-addr: func(ds-request: request) -> option<ip-address>;
// TLS metadata
downstream-tls-cipher-openssl-name: func(ds-request: request, max-len: u64) -> result<option<list<u8>>, error>;
downstream-tls-protocol: func(ds-request: request, max-len: u64) -> result<option<list<u8>>, error>;
downstream-tls-client-hello: func(ds-request: request, max-len: u64) -> result<option<list<u8>>, error>;
downstream-tls-raw-client-certificate: func(ds-request: request, max-len: u64) -> result<option<list<u8>>, error>;
downstream-tls-client-cert-verify-result: func(ds-request: request) -> result<option<client-cert-verify-result>, error>;
downstream-tls-client-servername: func(ds-request: request, max-len: u64) -> result<option<string>, error>;
downstream-tls-ja3-md5: func(ds-request: request) -> result<option<list<u8>>, error>;
downstream-tls-ja4: func(ds-request: request, max-len: u64) -> result<option<string>, error>;
// Security and fingerprinting
downstream-client-h2-fingerprint: func(ds-request: request, max-len: u64) -> result<string, error>;
downstream-client-oh-fingerprint: func(ds-request: request, max-len: u64) -> result<string, error>;
downstream-client-ddos-detected: func(ds-request: request) -> result<bool, error>;
downstream-client-request-id: func(ds-request: request, max-len: u64) -> result<string, error>;
// Compliance and headers
downstream-compliance-region: func(ds-request: request, max-len: u64) -> result<option<string>, error>;
downstream-original-header-names: func(ds-request: request, max-len: u64, cursor: u32) -> result<tuple<string, option<u32>>, error>;
downstream-original-header-count: func(ds-request: request) -> result<u32, error>;
// Purge authentication
fastly-key-is-valid: func(ds-request: request) -> result<bool, error>;
}
WIT bindings: stubs/wit_world/imports/http_downstream.py
API Design
Functions that take a Request and return metadata (likely exposed via request.downstream accessor):
- IP Access:
get_client_ip(request)/get_server_ip(request)returningOptional[Union[IPv4Address, IPv6Address]] - TLS Info:
get_tls_cipher(request),get_tls_protocol(request),get_tls_ja3_md5(request),get_tls_ja4(request) - Client Certificates:
get_client_certificate(request),get_client_cert_verify_result(request) - Security:
is_ddos_detected(request),get_request_id(request),get_h2_fingerprint(request) - Compliance:
get_compliance_region(request)for GDPR/data residency - Headers:
get_original_headers(request)preserving case and order - Multi-request:
next_request(timeout_ms)/await_request(pending)for handling multiple requests per sandbox
Usage via Request wrapper (see issue #009):
client_ip = incoming_req.downstream.client_ip()
tls_ja3 = incoming_req.downstream.tls_ja3_md5()
Cross-SDK Comparison: Rust exposes these as methods on Request extensions, Go uses functions in fsthttp package, JS provides via event.client object. Python will likely expose via request.downstream namespace for clean API.
Viceroy Testing
Viceroy implementation status (src/component/compute/http_downstream.rs):
✅ Fully Supported:
downstream_client_ip_addr- Returns client IP from request contextdownstream_server_ip_addr- Returns server IP from request contextdownstream_original_header_names/downstream_original_header_count- Preserves original header casing/orderdownstream_client_request_id- Returns generated request ID (format: 32-char hex)downstream_compliance_region- Returns compliance region if configurednext_request/await_request- Multi-request handling works
⚠️ Stubbed (returns None/empty):
- All
downstream_tls_*functions - ReturnNone(no TLS metadata in local testing) downstream_client_h2_fingerprint- Returns empty stringdownstream_client_oh_fingerprint- Returns empty stringdownstream_client_ddos_detected- Always returnsfalsefastly_key_is_valid- Always returnsfalse
Testing Approach:
- Use
@on_viceroywith inline TOML for IP address configuration - Mark TLS/fingerprint tests as
xfail- they returnNonein Viceroy - Test multi-request handling with sequential request pattern
- Test original header preservation with mixed-case headers
Example test config:
[local_server]
client_ip = "203.0.113.42"
compliance_region = "EU"
Reference
- Dominant language
- Python
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fastly/compute-sdk-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fastly/compute-sdk-python#116 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
fastly/compute-sdk-python#98 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
fastly/compute-sdk-python#74 ·
-
fastly/compute-sdk-python#60 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fastly/compute-sdk-python#59 ·
All issues in fastly/compute-sdk-python
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·