Skip to content

Custom HTTP headers for proxy and faucet API requests - Duplicate#566

Merged
popenta merged 4 commits intomainfrom
http-headers
May 5, 2026
Merged

Custom HTTP headers for proxy and faucet API requests - Duplicate#566
popenta merged 4 commits intomainfrom
http-headers

Conversation

@popenta
Copy link
Copy Markdown
Collaborator

@popenta popenta commented Apr 23, 2026

Description

Summary

This change lets users attach extra HTTP headers to proxy traffic (MultiversX API / ProxyNetworkProvider) and to faucet native-auth API calls. That supports authenticated or gated gateways (for example API keys) without changing proxy URLs.

What changed

  • --proxy-headers KEY=VALUE [KEY=VALUE ...]: Added wherever add_proxy_arg() is used. Values are parsed in parse_proxy_headers(); each token must contain = or the CLI raises a clear error.
  • Global application: Before the subcommand runs, cli.py calls config.set_proxy_headers(...). get_config_for_network_providers() passes those headers to the SDK via NetworkProviderConfig(requests_options={"headers": ...}), so SDK proxy clients pick them up consistently.
  • mxpy faucet request: New --api-headers with the same KEY=VALUE form, forwarded to NativeAuthClientConfig(extra_request_headers=...).
  • Environment model: env.mxpy.json defaults and MxpyEnv include a proxy_headers field (documented as space-separated KEY=VALUE pairs in get_proxy_headers()).
  • utils.parse_headers_list(): Shared parsing for KEY=VALUE lists.
  • cli_get: Uses shared add_proxy_arg() so get subcommands get --proxy-headers like the rest of the CLI.
  • cli_tokens: TokenManagementController now builds ProxyNetworkProvider with get_config_for_network_providers() so token flows respect the same header configuration.
  • Tests: test_proxy_extra_headers asserts custom headers are passed through on ProxyNetworkProvider GETs (mocked requests.Session.get).
  • Docs: CLI.md updated with the new flags across affected commands.

Usage examples

mxpy get network-config \
  --proxy https://gateway.example.com \
  --proxy-headers "Api-Key=secret"
mxpy faucet request \
  --chain D \
  --api https://api.example.com \
  --api-headers "Api-Key=secret"

radumojic
radumojic previously approved these changes May 4, 2026
schimih
schimih previously approved these changes May 4, 2026
@popenta popenta dismissed stale reviews from schimih and radumojic via 62d8e1e May 4, 2026 14:14
@popenta popenta merged commit c3d19ea into main May 5, 2026
11 checks passed
@popenta popenta deleted the http-headers branch May 5, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants