mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-18 23:15:35 -05:00
* enhancement: enable icap preview mode and use a forked icap client which fixes tcp socket keepalive * enhancement: make use of human time for the icap timout config option * enhancement: update icap-client * enhancement: bump icap client library and deprecate ANTIVIRUS_ICAP_TIMEOUT env * chore: vendor icap library * enhancement: set preview size only if greater than 0 * Update services/antivirus/pkg/config/config.go Co-authored-by: Martin <github@diemattels.at> * enhancement: add changelog --------- Co-authored-by: Martin <github@diemattels.at>
2.0 KiB
2.0 KiB
icap-client
Talk to the ICAP servers using probably the first ICAP client package in GO!
Installing
go get -u github.com/egirna/icap-client
Usage
Import The Package
import ic "github.com/egirna/icap-client"
Making a simple RESPMOD call
req, err := ic.NewRequest(context.Background(), MethodRESPMOD, "icap://<host>:<port>/<path>", httpReq, httpResp)
if err != nil {
log.Fatal(err)
}
client, err := ic.NewClient(
ic.WithICAPConnectionTimeout(5 * time.Second),
)
if err != nil {
log.Fatal(err)
}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
Note: httpReq & httpResp here are *http.Response & *http.Request respectively
Setting preview obtained from OPTIONS call
req, err := ic.NewRequest(context.Background(), ic.MethodOPTIONS, "icap://<host>:<port>/<path>", nil, nil)
if err != nil {
log.Fatal(err)
}
client, err := ic.NewClient(
ic.WithICAPConnectionTimeout(5 * time.Second),
)
if err != nil {
log.Fatal(err)
}
req.SetPreview(optReq.PreviewBytes)
// do something with req(ICAP *Request)
By default, the icap-client will dump the debugging logs to the standard output(stdout), but you can always add your custom writer
f, _ := os.OpenFile("logs.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
ic.SetDebugOutput(f)
For more details, see the docs and examples.
Contributing
This package is still WIP, so totally open to suggestions. See the contribution guide here.
License
icap-client is licensed under the Apache License.