Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support to the Curl backend #2007

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions core/src/main/scalanative/sttp/client4/curl/internal/CCurl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ package sttp.client4.curl.internal
import sttp.client4.curl.internal.CurlCode.CurlCode

import scala.scalanative.unsafe._
import scala.scalanative.meta.LinktimeInfo.isWindows

private[curl] trait Curl {}

private[curl] trait Mime {}

private[curl] trait MimePart {}

@link("curl")
private[curl] object libcurlPlatformCompat {
@extern @link("libcurl") @link("crypt32")
private object libcurlWin64 extends CCurl

@extern @link("curl")
private object libcurlDefault extends CCurl

val instance: CCurl =
if (isWindows) libcurlWin64
else libcurlDefault
}

@extern
private[curl] object CCurl {
private[curl] trait CCurl {
@name("curl_easy_init")
def init: Ptr[Curl] = extern

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ package object internal {
type CurlSlist = CStruct2[CString, Ptr[_]]
type CurlFetch = CStruct2[CString, CSize]
val CurlZeroTerminated = -1L

private[curl] final val CCurl = libcurlPlatformCompat.instance
}
Loading