working commit

This commit is contained in:
2026-03-01 21:35:40 +02:00
parent 86c7831cd8
commit 32c9cc26fc
3 changed files with 20 additions and 2 deletions

View File

@@ -22,6 +22,19 @@ func NewClient() *Client {
}
}
func NewClientWithTransport(transport http.RoundTripper, mwFunc ...MiddlewareFunc) *Client {
if transport == nil {
transport = NewDefaultTransport()
}
httpClient := &http.Client{
Transport: transport,
}
return &Client{
httpClient: httpClient,
userAgent: "ociClient/1.0",
}
}
func (cli *Client) SetTransport(transport http.RoundTripper) {
cli.httpClient.Transport = transport
}

View File

@@ -33,7 +33,7 @@ func xxxTestClientGetManifest(t *testing.T) {
}
}
func TestClientManifestExists(t *testing.T) {
func xxxTestClientManifestExists(t *testing.T) {
rawrepo := "mirror.gcr.io/alpine"
tags := []string{
"3.20.0",
@@ -70,7 +70,7 @@ func xxxTestClientBlobExists(t *testing.T) {
}
}
func TestClientGetBlob(t *testing.T) {
func xxxTestClientGetBlob(t *testing.T) {
rawrepos := []string{
"mirror.gcr.io/alpine",
}

View File

@@ -3,6 +3,7 @@ package repocli
import (
"bytes"
"context"
"errors"
"fmt"
"net/http"
"strconv"
@@ -41,6 +42,10 @@ func (cli *Client) GetManifest(ctx context.Context, rawrepo, tag string) (bool,
return exist, mime, man, err
}
contentLength := resp.Header.Get("Content-Length")
if contentLength == "" {
err = errors.New("Empty Content-Length header")
return exist, mime, man, err
}
manSize, err := strconv.ParseInt(contentLength, 10, 64)
if err != nil {
return exist, mime, man, err