readWebBundlePayloadLength returns the length of the web bundle parsed from the last 8 bytes of the web bundle file. [Web Bundle's Trailing Length]: https://wpack-wg.github.io/bundled-responses/draft-ietf-wpack-bundled-responses.html#name-trailing-length
(bundleFile *os.File)
| 111 | // readWebBundlePayloadLength returns the length of the web bundle parsed from the last 8 bytes of the web bundle file. |
| 112 | // [Web Bundle's Trailing Length]: https://wpack-wg.github.io/bundled-responses/draft-ietf-wpack-bundled-responses.html#name-trailing-length |
| 113 | func readWebBundlePayloadLength(bundleFile *os.File) (int64, error) { |
| 114 | // Finds the offset, from which the 8 bytes containing the web bundle length start. |
| 115 | _, err := bundleFile.Seek(-8, io.SeekEnd) |
| 116 | if err != nil { |
| 117 | return 0, err |
| 118 | } |
| 119 | |
| 120 | // Reads from the offset to the end of the file (those 8 bytes). |
| 121 | webBundleLengthBytes, err := ioutil.ReadAll(bundleFile) |
| 122 | if err != nil { |
| 123 | return 0, err |
| 124 | } |
| 125 | |
| 126 | return int64(binary.BigEndian.Uint64(webBundleLengthBytes)), nil |
| 127 | } |
| 128 | |
| 129 | // obtainIntegrityBlock returns either the existing integrity block parsed (not supported in v1) or a newly |
| 130 | // created empty integrity block. Integrity block preceeds the actual web bundle bytes. The second return |
no outgoing calls
no test coverage detected