Documentation ¶
Overview ¶
Package cdc provides support for reading Chromium disk cache v2. https://www.chromium.org/developers/design-documents/network-stack/disk-cache
Example ¶
Example gets an entry from the cache and prints to stdout.
package main import ( "fmt" "image/png" "log" "github.com/schorlet/cdc" ) func main() { cache, err := cdc.OpenCache("testdata") if err != nil { log.Fatal(err) } entry, err := cache.OpenURL("https://golang.org/doc/gopher/pkg.png") if err != nil { log.Fatal(err) } fmt.Println(entry.URL()) header, err := entry.Header() if err != nil { log.Fatal(err) } for _, key := range []string{"Status", "Content-Length", "Content-Type"} { fmt.Printf("%s: %s\n", key, header.Get(key)) } body, err := entry.Body() if err != nil { log.Fatal(err) } defer body.Close() config, err := png.DecodeConfig(body) if err != nil { log.Fatal(err) } fmt.Printf("PNG image data, %d x %d\n", config.Width, config.Height) }
Output: https://golang.org/doc/gopher/pkg.png Status: 200 Content-Length: 5409 Content-Type: image/png PNG image data, 83 x 120
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("entry not found")
ErrNotFound is returned if the entry is not found.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache gives read access to the chromium disk cache.
The cache is composed of one "index" file, four or more "data_[0-9]" files and many of "f_[0-9]+" separate files.
Learn more: http://www.forensicswiki.org/wiki/Google_Chrome#Disk_Cache http://www.forensicswiki.org/wiki/Chrome_Disk_Cache_Format
func OpenCache ¶
OpenCache opens the cache in dir. Opens the "index" file to read the addresses and then opens each Entry to read the URL and associate it to an address.
func (*Cache) GetAddr ¶
GetAddr returns the address of the URL. An error is returned if the URL is not found.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a HTTP response as stored in the cache. An Entry is stored in one of the "data_[0-9]" files or in a "f_[0-9]+" separate file.