working commit

This commit is contained in:
2026-02-27 19:04:57 +02:00
parent 7de22e3816
commit 9fa5a00421
12 changed files with 210 additions and 213 deletions
+5 -12
View File
@@ -6,16 +6,15 @@ import (
"net/http"
)
func (cli *Client) GetUpload(ctx context.Context, rawref string) (string, error) {
func (cli *Client) GetUpload(ctx context.Context, rawrepo string) (string, error) {
var err error
var loc string
ref, err := NewReference(rawref)
ref, err := NewRepository(rawrepo)
if err != nil {
return loc, err
}
uri := ref.Upload()
user, pass := ref.Userinfo()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, uri, nil)
if err != nil {
@@ -23,26 +22,20 @@ func (cli *Client) GetUpload(ctx context.Context, rawref string) (string, error)
}
req.Header.Set("User-Agent", cli.userAgent)
req.Header.Set("Accept", "*/*")
if cli.authenticator != nil {
authHeader, authKey, err := cli.authenticator.MakeHeader(user, pass)
if err != nil {
return loc, err
}
req.Header.Set(authHeader, authKey)
}
resp, err := cli.httpClient.Do(req)
if err != nil {
return loc, err
}
defer resp.Body.Close()
fmt.Printf("=== %++v\n", resp.Header)
if resp.StatusCode != http.StatusAccepted {
err := fmt.Errorf("Unxected response code %s", resp.Status)
return loc, err
}
loc = resp.Header.Get("Location")
if loc == "" {
err := fmt.Errorf("Empty location declaration")
return loc, err