working commit
This commit is contained in:
13
client.go
13
client.go
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user