| 531 | } |
| 532 | |
| 533 | func (r *dockerBase) request(host RegistryHost, method string, ps ...string) *request { |
| 534 | header := r.header.Clone() |
| 535 | if header == nil { |
| 536 | header = http.Header{} |
| 537 | } |
| 538 | |
| 539 | for key, value := range host.Header { |
| 540 | header[key] = append(header[key], value...) |
| 541 | } |
| 542 | |
| 543 | if len(header.Get("User-Agent")) == 0 { |
| 544 | header.Set("User-Agent", "containerd/"+version.Version) |
| 545 | } |
| 546 | |
| 547 | parts := append([]string{"/", host.Path, r.repository}, ps...) |
| 548 | p := path.Join(parts...) |
| 549 | // Join strips trailing slash, re-add ending "/" if included |
| 550 | if len(parts) > 0 && strings.HasSuffix(parts[len(parts)-1], "/") { |
| 551 | p = p + "/" |
| 552 | } |
| 553 | return &request{ |
| 554 | method: method, |
| 555 | path: p, |
| 556 | header: header, |
| 557 | host: host, |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | func (r *request) authorize(ctx context.Context, req *http.Request) error { |
| 562 | // Check if has header for host |