2018-02-26 08:45:52 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2018-10-05 22:20:29 +06:00
|
|
|
"context"
|
2018-09-06 19:02:21 +06:00
|
|
|
"crypto/sha256"
|
2018-02-26 08:45:52 +00:00
|
|
|
"encoding/binary"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
2018-02-26 15:41:37 +06:00
|
|
|
var notModifiedErr = newError(304, "Not modified", "Not modified")
|
2018-02-26 08:45:52 +00:00
|
|
|
|
2018-10-05 22:20:29 +06:00
|
|
|
func calcETag(ctx context.Context) []byte {
|
|
|
|
|
footprint := sha256.Sum256(getImageData(ctx).Bytes())
|
2018-02-26 08:45:52 +00:00
|
|
|
|
2018-09-06 19:02:21 +06:00
|
|
|
hash := sha256.New()
|
2018-02-26 08:45:52 +00:00
|
|
|
hash.Write(footprint[:])
|
2018-09-06 19:02:21 +06:00
|
|
|
hash.Write([]byte(version))
|
|
|
|
|
binary.Write(hash, binary.LittleEndian, conf)
|
2018-10-05 22:20:29 +06:00
|
|
|
binary.Write(hash, binary.LittleEndian, *getProcessingOptions(ctx))
|
2018-02-26 08:45:52 +00:00
|
|
|
|
2018-10-05 22:20:29 +06:00
|
|
|
return []byte(fmt.Sprintf("%x", hash.Sum(nil)))
|
2018-02-26 08:45:52 +00:00
|
|
|
}
|