Bounded ICAP/1.0 codec, OPTIONS negotiation and Preview client transaction engine
moon add TangShiJi/moonicap@0.1.0let request = @icap.message(
Request(Reqmod,"icap://scanner.example/scan"),
headers=[("Host","scanner.example")],
body_kind=RequestBody,
body=b"file-content",
)
let client = @icap.new_session(request,preview=Some(4)).unwrap()
let first = client.start().unwrap()
// 宿主写出 first,并将服务端读取的 Bytes 传入 receive。
let actions = client.receive(b"ICAP/1.0 100 Continue\r\n\r\n").unwrap()
// actions 中的 Send(bytes) 必须由宿主写出;Unchanged/Adapted/Rejected 为终态。moon info
moon fmt --check
moon check --target all --deny-warn
moon test --target all --deny-warn
moon build --target native --release cmd/main
moon run --target native cmd/main -- options icap://localhost:1344/echomoon run --target native examples/upload_scan
moon run --target native examples/proxy_response
moon run --target native examples/service_optionsfn ClientSession::receive(self : ClientSession, bytes : Bytes) -> Result[Array[Action], ProtocolError]fn encode_chunks(body : Bytes, chunk_size? : Int, ieof? : Bool, trailers? : Array[(String, String)]) -> Result[Bytes, ProtocolError]fn exchange(request : Message, read : () -> Result[Bytes, ProtocolError], write : (Bytes) -> Result[Unit, ProtocolError], preview? : Int?, allow_204? : Bool, bounds? : Limits, max_reads? : Int) -> Result[Action, ProtocolError]fn new_session(request : Message, preview? : Int?, allow_204? : Bool, bounds? : Limits) -> Result[ClientSession, ProtocolError]fn prepare_http(start_line : String, fields : Array[(String, String)]) -> Result[AdaptationHeaders, ProtocolError]Install
Download zipBounded ICAP/1.0 codec, OPTIONS negotiation and Preview client transaction engine