Skip to content

Conversation

@xerial
Copy link
Member

@xerial xerial commented Jan 12, 2026

This commit implements HTTP client support for Scala Native by
leveraging libcurl bindings. The implementation provides:

  • CurlBindings: Low-level Scala Native bindings for libcurl
    including easy interface functions, error codes, and options
  • CurlChannel: HttpChannel implementation using libcurl
  • NativeHttpClientBackend: Backend factory for creating HTTP clients
  • LocalRPCContext: Thread-local RPC context management for Native
  • Updated Compat.scala with real implementations

Requirements:

  • libcurl 7.56.0 or newer must be installed on the system
  • For HTTPS: libcurl must be built with SSL support (OpenSSL, etc.)

Supported features:

  • All standard HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.)
  • Request/response headers and bodies
  • Connect and read timeouts
  • Automatic redirect following
  • Automatic decompression (gzip, deflate)
  • Both sync and async clients (async wraps sync via Rx)

This commit implements HTTP client support for Scala Native by
leveraging libcurl bindings. The implementation provides:

- CurlBindings: Low-level Scala Native bindings for libcurl
  including easy interface functions, error codes, and options
- CurlChannel: HttpChannel implementation using libcurl
- NativeHttpClientBackend: Backend factory for creating HTTP clients
- LocalRPCContext: Thread-local RPC context management for Native
- Updated Compat.scala with real implementations

Requirements:
- libcurl 7.56.0 or newer must be installed on the system
- For HTTPS: libcurl must be built with SSL support (OpenSSL, etc.)

Supported features:
- All standard HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.)
- Request/response headers and bodies
- Connect and read timeouts
- Automatic redirect following
- Automatic decompression (gzip, deflate)
- Both sync and async clients (async wraps sync via Rx)
claude and others added 4 commits January 12, 2026 16:26
Add libcurl4-openssl-dev installation step to:
- test_native_3 job (Scala Native tests)
- test_airspec job (AirSpec Native tests)
- release-native workflow (Scala Native publishing)

This is required for linking the new curl-based HTTP client
implementation for Scala Native.
- Use @name annotation pattern for curl extern bindings (following sttp)
- Create separate named wrapper functions to avoid overload ambiguity
- Use Long instead of CLong for better Scala 3 compatibility
- Use Zone.acquire syntax for Scala 3
- Fix CSize conversion with toCSize extension method
- Use proper nativeConfig syntax for build.sbt
…mpatibility

Move SSL, connection, and root cause exception classifiers to platform-specific
Compat implementations to avoid referencing JVM-only classes (javax.net.ssl.*,
java.net.*, java.lang.reflect.*) in Scala Native builds.

- Add sslExceptionClassifier, connectionExceptionClassifier, and
  rootCauseExceptionClassifier methods to CompatApi
- JVM Compat provides full implementations with all exception types
- Native/JS Compat provide empty or simplified classifiers
- Remove JVM-specific imports from shared HttpClientException.scala

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
@xerial xerial merged commit 4e36cf5 into main Jan 12, 2026
23 checks passed
@xerial xerial deleted the claude/scalanative-http-client-WJ1Kp branch January 12, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants