Skip to content

Commit c023e6a

Browse files
author
user123456
committed
清理冗余written字段
1 parent 44c6e4c commit c023e6a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/docker.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,16 @@ func proxyDockerAuthWithCache(c *gin.Context) {
364364
globalCache.SetToken(cacheKey, string(recorder.body), ttl)
365365
}
366366

367-
// 6. 写入实际响应(如果还没写入)
368-
if !recorder.written {
369-
c.Writer = recorder.ResponseWriter
370-
c.Data(recorder.statusCode, "application/json", recorder.body)
371-
}
367+
// 6. 写入实际响应
368+
c.Writer = recorder.ResponseWriter
369+
c.Data(recorder.statusCode, "application/json", recorder.body)
372370
}
373371

374372
// ResponseRecorder HTTP响应记录器
375373
type ResponseRecorder struct {
376374
gin.ResponseWriter
377375
statusCode int
378376
body []byte
379-
written bool
380377
}
381378

382379
func (r *ResponseRecorder) WriteHeader(code int) {
@@ -385,7 +382,6 @@ func (r *ResponseRecorder) WriteHeader(code int) {
385382

386383
func (r *ResponseRecorder) Write(data []byte) (int, error) {
387384
r.body = append(r.body, data...)
388-
r.written = true
389385
return len(data), nil
390386
}
391387

0 commit comments

Comments
 (0)