GetBootURL returns Boot File URL, see RFC 5970
(id []byte, clientArchType uint16)
| 83 | |
| 84 | // GetBootURL returns Boot File URL, see RFC 5970 |
| 85 | func (bc *APIBootConfiguration) GetBootURL(id []byte, clientArchType uint16) ([]byte, error) { |
| 86 | reqURL := fmt.Sprintf("%s/boot/%x/%d", bc.URLPrefix, id, clientArchType) |
| 87 | resp, err := bc.Client.Get(reqURL) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | if resp.StatusCode != http.StatusOK { |
| 92 | resp.Body.Close() |
| 93 | return nil, fmt.Errorf("%s: %s", reqURL, http.StatusText(resp.StatusCode)) |
| 94 | } |
| 95 | defer resp.Body.Close() |
| 96 | |
| 97 | buf := new(bytes.Buffer) |
| 98 | buf.ReadFrom(resp.Body) |
| 99 | url, _ := bc.makeURLAbsolute(buf.String()) |
| 100 | |
| 101 | return []byte(url), nil |
| 102 | } |
| 103 | |
| 104 | func (bc *APIBootConfiguration) makeURLAbsolute(urlStr string) (string, error) { |
| 105 | u, err := url.Parse(urlStr) |
nothing calls this directly
no test coverage detected