Update core client

This commit is contained in:
Ingo Oppermann
2024-04-29 17:05:13 +02:00
parent 24cc87ae7e
commit 72ba297a75
4 changed files with 44 additions and 3 deletions

2
go.mod
View File

@@ -12,7 +12,7 @@ require (
github.com/atrox/haikunatorgo/v2 v2.0.1
github.com/caddyserver/certmagic v0.20.0
github.com/casbin/casbin/v2 v2.88.0
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240424105158-86a7f261b92c
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240429143858-23ad5985b894
github.com/datarhei/gosrt v0.6.0
github.com/datarhei/joy4 v0.0.0-20240229100136-43bcaf8ef5e7
github.com/fujiwara/shapeio v1.0.0

2
go.sum
View File

@@ -51,6 +51,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHH
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240424105158-86a7f261b92c h1:RIzMclqmSYwpMZxyW7nLg0XyKjY6prQWcuIdgm97U8o=
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240424105158-86a7f261b92c/go.mod h1:7XrUOUlB165Gs8JUE4lzVuNve6HW90Yz3/+lTY2EV4A=
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240429143858-23ad5985b894 h1:ZQCTobOGpzfuZxgMWsZviFSXfI5QuttkTgPQz1PKbhU=
github.com/datarhei/core-client-go/v16 v16.11.1-0.20240429143858-23ad5985b894/go.mod h1:Mu2bHqvGJe46KvAhY2ElohuQYhHB64PZeaCNDv6C5b8=
github.com/datarhei/gosrt v0.6.0 h1:HrrXAw90V78ok4WMIhX6se1aTHPCn82Sg2hj+PhdmGc=
github.com/datarhei/gosrt v0.6.0/go.mod h1:fsOWdLSHUHShHjgi/46h6wjtdQrtnSdAQFnlas8ONxs=
github.com/datarhei/joy4 v0.0.0-20240229100136-43bcaf8ef5e7 h1:MG5XQMTTDPcuvvRzc1c37QbwgDbYPhKmPFo9gSaPdBE=

View File

@@ -19,6 +19,8 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/gobwas/glob"
jwtgo "github.com/golang-jwt/jwt/v4"
"github.com/klauspost/compress/gzip"
"github.com/klauspost/compress/zstd"
)
const (
@@ -843,12 +845,47 @@ func (r *restclient) info() (api.About, error) {
}
func (r *restclient) request(req *http.Request) (int, io.ReadCloser, error) {
/*
fmt.Printf("%s %s\n", req.Method, req.URL)
for key, value := range req.Header {
for _, v := range value {
fmt.Printf("%s: %s\n", key, v)
}
}
fmt.Printf("\n")
*/
resp, err := r.client.Do(req)
if err != nil {
return -1, nil, err
}
/*
for key, value := range resp.Header {
for _, v := range value {
fmt.Printf("%s: %s\n", key, v)
}
}
*/
reader := resp.Body
return resp.StatusCode, resp.Body, nil
contentEncoding := resp.Header.Get("Content-Encoding")
if contentEncoding == "gzip" {
reader, err = gzip.NewReader(resp.Body)
if err != nil {
resp.Body.Close()
return -1, nil, err
}
} else if contentEncoding == "zstd" {
zstd, err := zstd.NewReader(resp.Body)
if err != nil {
resp.Body.Close()
return -1, nil, err
}
reader = zstd.IOReadCloser()
}
return resp.StatusCode, reader, nil
}
func (r *restclient) stream(ctx context.Context, method, path string, query *url.Values, header http.Header, contentType string, data io.Reader) (io.ReadCloser, error) {
@@ -874,6 +911,8 @@ func (r *restclient) stream(ctx context.Context, method, path string, query *url
req.Header.Add("Content-Type", contentType)
}
req.Header.Set("Accept-Encoding", "zstd, gzip")
if r.accessToken.IsSet() {
if r.accessToken.IsExpired() {
if err := r.refresh(); err != nil {

2
vendor/modules.txt vendored
View File

@@ -82,7 +82,7 @@ github.com/cespare/xxhash/v2
# github.com/cpuguy83/go-md2man/v2 v2.0.2
## explicit; go 1.11
github.com/cpuguy83/go-md2man/v2/md2man
# github.com/datarhei/core-client-go/v16 v16.11.1-0.20240424105158-86a7f261b92c
# github.com/datarhei/core-client-go/v16 v16.11.1-0.20240429143858-23ad5985b894
## explicit; go 1.18
github.com/datarhei/core-client-go/v16
github.com/datarhei/core-client-go/v16/api