2018-02-26 10:45:52 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-09-06 15:02:21 +02:00
|
|
|
"crypto/sha256"
|
2018-02-26 10:45:52 +02:00
|
|
|
"encoding/binary"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-02-26 11:41:37 +02:00
|
|
|
var notModifiedErr = newError(304, "Not modified", "Not modified")
|
2018-02-26 10:45:52 +02:00
|
|
|
|
2018-02-26 11:41:37 +02:00
|
|
|
func calcETag(b []byte, po *processingOptions) string {
|
2018-09-06 15:02:21 +02:00
|
|
|
footprint := sha256.Sum256(b)
|
2018-02-26 10:45:52 +02:00
|
|
|
|
2018-09-06 15:02:21 +02:00
|
|
|
hash := sha256.New()
|
2018-02-26 10:45:52 +02:00
|
|
|
hash.Write(footprint[:])
|
2018-09-06 15:02:21 +02:00
|
|
|
hash.Write([]byte(version))
|
|
|
|
binary.Write(hash, binary.LittleEndian, conf)
|
2018-02-26 10:45:52 +02:00
|
|
|
binary.Write(hash, binary.LittleEndian, *po)
|
|
|
|
|
|
|
|
return fmt.Sprintf("%x", hash.Sum(nil))
|
|
|
|
}
|