Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/vendor/github.com/anacrolix/missinggo/httptoo/headers.go
akuma06 a41f938cec Add Godep support (#758)
As we have seen, dependencies version can prevent the build. We should
user lock versions on dependencies that we know work:
* Packages are vendored
* Add Godep support
* Added addtional install step in readme
* Fix travis build error
2017-05-26 13:07:22 +02:00

61 lignes
962 o
Go

package httptoo
import (
"fmt"
"strings"
"time"
)
type Visibility int
const (
Default = 0
Public = 1
Private = 2
)
type CacheControlHeader struct {
MaxAge time.Duration
Caching Visibility
NoStore bool
}
func (me *CacheControlHeader) caching() []string {
switch me.Caching {
case Public:
return []string{"public"}
case Private:
return []string{"private"}
default:
return nil
}
}
func (me *CacheControlHeader) maxAge() []string {
if me.MaxAge == 0 {
return nil
}
d := me.MaxAge
if d < 0 {
d = 0
}
return []string{fmt.Sprintf("max-age=%d", d/time.Second)}
}
func (me *CacheControlHeader) noStore() []string {
if me.NoStore {
return []string{"no-store"}
}
return nil
}
func (me *CacheControlHeader) concat(sss ...[]string) (ret []string) {
for _, ss := range sss {
ret = append(ret, ss...)
}
return
}
func (me CacheControlHeader) String() string {
return strings.Join(me.concat(me.caching(), me.maxAge()), ", ")
}