修复部分语法问题
This commit is contained in:
@@ -114,8 +114,8 @@ func (c *CacheBackendBlobReader) Open(ctx context.Context, owner, repo, commit,
|
||||
return nil, err
|
||||
}
|
||||
if open.StatusCode == http.StatusNotFound {
|
||||
// 缓存 404 路由
|
||||
_ = c.cache.Put(ctx, key, nil, time.Hour)
|
||||
// TODO: 缓存 404 路由
|
||||
//_ = c.cache.Put(ctx, key, nil, time.Hour)
|
||||
_ = open.Body.Close()
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
@@ -241,9 +241,9 @@ func (s *Server) Serve(writer http.ResponseWriter, request *http.Request) error
|
||||
}
|
||||
defer result.Close()
|
||||
if reader, ok := result.(*cache.Content); ok {
|
||||
writer.Header().Add("X-CacheBlob", "HIT")
|
||||
writer.Header().Add("X-Cache", "HIT")
|
||||
writer.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(fileName)))
|
||||
writer.Header().Add("CacheBlob-Control", "public, max-age=86400")
|
||||
writer.Header().Add("Cache-Control", "public, max-age=86400")
|
||||
if render != nil {
|
||||
if err = render.Render(writer, request, reader); err != nil {
|
||||
return err
|
||||
@@ -256,8 +256,8 @@ func (s *Server) Serve(writer http.ResponseWriter, request *http.Request) error
|
||||
writer.Header().Add("Content-Length", strconv.FormatUint(reader.Size, 10))
|
||||
}
|
||||
// todo(bug) : 直连模式下告知数据长度
|
||||
writer.Header().Add("X-CacheBlob", "MISS")
|
||||
writer.Header().Add("CacheBlob-Control", "public, max-age=86400")
|
||||
writer.Header().Add("X-Cache", "MISS")
|
||||
writer.Header().Add("Cache-Control", "public, max-age=86400")
|
||||
writer.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(fileName)))
|
||||
writer.WriteHeader(http.StatusOK)
|
||||
if render != nil {
|
||||
|
||||
Reference in New Issue
Block a user