Skip to content
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
14 changes: 14 additions & 0 deletions core/src/main/resources/scala-native/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@ const char* sttp_curl_get_version() {
return curl_version_info(CURLVERSION_NOW)->version;
}
int sttp_curl_getinfo_pointer(CURL *curl, CURLINFO info, void* arg) {return curl_easy_getinfo(curl, info, arg); }

/* curl_multi wrappers */
/* Most curl_multi functions are called directly via @extern bindings.
This wrapper exists because CURLMsg contains a union that can't be
safely represented in Scala Native's type system. */
int sttp_curl_multi_info_read_result(CURLM *multi, CURL **easy_out) {
int msgs_in_queue;
CURLMsg *msg = curl_multi_info_read(multi, &msgs_in_queue);
if (msg && msg->msg == CURLMSG_DONE) {
if (easy_out) *easy_out = msg->easy_handle;
return (int)msg->data.result;
}
return -1; /* no completed transfer */
}
#endif
12 changes: 11 additions & 1 deletion core/src/main/scalanative/sttp/client4/SttpExtensions.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package sttp.client4

import java.io.File
import java.io.{File, InputStream}
import java.nio.file.Path

import sttp.client4.internal._
import sttp.model.{Part, StatusCode}

trait SttpExtensions {

def asInputStream[T](f: InputStream => T): ResponseAs[Either[String, T]] =
asEither(asStringAlways, asInputStreamAlways(f))

def asInputStreamAlways[T](f: InputStream => T): ResponseAs[T] = new ResponseAs(ResponseAsInputStream(f))

def asInputStreamUnsafe: ResponseAs[Either[String, InputStream]] = asEither(asStringAlways, asInputStreamAlwaysUnsafe)

def asInputStreamAlwaysUnsafe: ResponseAs[InputStream] = new ResponseAs(ResponseAsInputStreamUnsafe)

def asFile(file: File): ResponseAs[Either[String, File]] = asEither(asStringAlways, asFileAlways(file))

def asFileAlways(file: File): ResponseAs[File] =
Expand Down
Loading
Loading