The "primary" section records a single URL identifying the primary URL of the bundle. The URL MUST refer to a resource with representations contained in the bundle itself.
(sectionContents []byte)
| 303 | |
| 304 | // The "primary" section records a single URL identifying the primary URL of the bundle. The URL MUST refer to a resource with representations contained in the bundle itself. |
| 305 | func parsePrimarySection(sectionContents []byte) (*url.URL, error) { |
| 306 | dec := cbor.NewDecoder(bytes.NewBuffer(sectionContents)) |
| 307 | urlString, err := dec.DecodeTextString() |
| 308 | if err != nil { |
| 309 | return nil, fmt.Errorf("bundle: failed to parse primary section: %v", err) |
| 310 | } |
| 311 | primaryURL, err := url.Parse(urlString) |
| 312 | // If url is a failure, its fragment is not null, or it includes credentials, return an error. |
| 313 | if err != nil { |
| 314 | return nil, fmt.Errorf("bundle: failed to parse primary URL (%s): %v", urlString, err) |
| 315 | } |
| 316 | if !primaryURL.IsAbs() || primaryURL.Fragment != "" || primaryURL.User != nil { |
| 317 | return nil, fmt.Errorf("bundle: primary URL (%s) must be an absolute url without fragment or credentials.", urlString) |
| 318 | } |
| 319 | return primaryURL, nil |
| 320 | } |
| 321 | |
| 322 | // https://wpack-wg.github.io/bundled-responses/draft-ietf-wpack-bundled-responses.html#manifest-section |
| 323 | func parseManifestSection(sectionContents []byte) (*url.URL, error) { |
no test coverage detected