Skip to content

ref(transport): unify and restructure HTTP transport layer#1514

Draft
jpnurmi wants to merge 15 commits intomasterfrom
jpnurmi/ref/http-transport
Draft

ref(transport): unify and restructure HTTP transport layer#1514
jpnurmi wants to merge 15 commits intomasterfrom
jpnurmi/ref/http-transport

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Feb 12, 2026

Summary

  • Extracts a shared HTTP transport base (sentry_http_transport.c/.h) from the curl and WinHTTP transports, eliminating duplicated logic for background workers, rate limiting, request preparation, and envelope lifecycle management
  • Moves all HTTP-specific types, functions, and state out of the generic transport (sentry_transport.c/.h) into the HTTP transport layer, keeping the generic transport truly transport-agnostic
  • Normalizes the curl and WinHTTP transports into thin client implementations behind a unified sentry_http_send_func_t callback interface
  • Prepares the transport architecture for HTTP retry support by establishing a clean separation where retry logic can be added in one place (the HTTP base transport) rather than duplicated across transports

Test plan

  • All existing tests pass (test_integration_http/ratelimits/proxy.py)

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 12, 2026

@sentry review

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 12, 2026

@cursor review

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 12, 2026

@sentry review

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 12, 2026

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

jpnurmi and others added 15 commits February 12, 2026 10:39
Introduce sentry_http_transport as a shared base for curl and WinHTTP
transports. This centralizes bgworker management (start, flush, shutdown,
send_envelope, dump) so each backend only provides state, start, and
send_task. WinHTTP's force-close-on-timeout behavior is supported via an
optional shutdown_hook parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move fields duplicated across curl and WinHTTP backends into the shared
http_transport_state_t. The shared http_send_task() now calls
sentry__prepare_http_request() and passes the prepared request to
backend send functions via a new sentry_http_send_func_t callback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid ambiguity with sentry_backend_t by renaming backend_state,
free_backend_state, start_backend, and platform-specific types/functions
(curl_state_t, winhttp_state_t, etc.) to use "client" terminology.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add sentry__transport_get_state as a generic internal accessor and move
the HTTP-specific bgworker helper to sentry__http_transport_get_bgworker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the monolithic constructor with individual setters, mirroring the
public transport API. Rename shutdown_hook to shutdown_client for consistency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…names

Rename sentry_transport_{curl,winhttp}.c to sentry_http_transport_{curl,winhttp}.c
to group with the base sentry_http_transport. Normalize local function names to
consistent {prefix}_client_{verb} pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce sentry_http_response_t so clients just populate response
metadata (status_code, retry_after, x_sentry_rate_limits) and the
abstract transport handles rate limiting in one place.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sport

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
curl_easy_getinfo writes a long* and WinHttpQueryHeaders writes a
DWORD. Use local variables of the correct native type and assign to
the int status_code field to avoid type-size mismatches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The curl header_callback may populate retry_after/x_sentry_rate_limits
before curl_easy_perform fails. Moving the frees outside the success
branch avoids leaking these strings on network errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…port

If sentry__http_transport_new returns NULL, the subsequent set_* calls
would dereference a null pointer. Free the client and return NULL early.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant