package faraday-lwt-unix

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file faraday_lwt_unix.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
include Faraday_lwt

open Lwt.Infix

let writev_of_fd fd =
  fun iovecs ->
    let lwt_iovecs = Lwt_unix.IO_vectors.create () in
    iovecs |> List.iter (fun {Faraday.buffer; off; len} ->
      Lwt_unix.IO_vectors.append_bigarray lwt_iovecs buffer off len);

    Lwt.catch
      (fun () ->
        Lwt_unix.writev fd lwt_iovecs
        >|= fun n -> `Ok n)
      (function
      | Unix.Unix_error (Unix.EBADF, "check_descriptor", _)
      | Unix.Unix_error (Unix.EPIPE, _, _) ->
        Lwt.return `Closed
      | exn ->
        Lwt.fail exn)
OCaml

Innovation. Community. Security.