working commit

This commit is contained in:
2026-03-10 12:52:12 +02:00
parent d0a5fab362
commit d1ef1fbe50
42 changed files with 242 additions and 426 deletions
+14 -9
View File
@@ -6,37 +6,42 @@ import (
"net/http"
)
func (cli *Client) GetUpload(ctx context.Context, rawrepo string) (string, error) {
func (cli *Client) GetUpload(ctx context.Context, rawrepo string) (string, string, error) {
var err error
var loc string
var id string
ref, err := NewReferer(rawrepo)
if err != nil {
return loc, err
return id, loc, err
}
uri := ref.Upload()
uri := ref.UploadEP()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, uri, nil)
if err != nil {
return loc, err
return id, loc, err
}
req.Header.Set("User-Agent", cli.userAgent)
req.Header.Set("Accept", "*/*")
resp, err := cli.httpClient.Do(req)
if err != nil {
return loc, err
return id, loc, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusAccepted {
err := fmt.Errorf("Unxected response code %s", resp.Status)
return loc, err
return id, loc, err
}
loc = resp.Header.Get("Location")
if loc == "" {
err := fmt.Errorf("Empty location declaration")
return loc, err
return id, loc, err
}
return loc, err
id = resp.Header.Get("Docker-Upload-UUID")
if id == "" {
err := fmt.Errorf("Empty Docker-Upload-UUID declaration")
return id, loc, err
}
return id, loc, err
}