Skip to content

Commit

Permalink
删除可能暴露隐私的字段
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Apr 12, 2024
1 parent c14ee6b commit c613140
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions service/avatar.go
Expand Up @@ -35,11 +35,23 @@ func (s *Service) GetAvatar(in *protocols.GetAvatarRequest) {

defer resp.Body.Close()

for name, value := range resp.Header {
in.SetHeader(name, value[0])
// 删除可能有隐私的头部字段。
// TODO:内部缓存,只正向代理 body。
for k := range knownHeaders {
if v := resp.Header.Get(k); v != "" {
in.SetHeader(k, v)
}
}

in.SetStatus(resp.StatusCode)

io.Copy(in.W, resp.Body)
}

var knownHeaders = map[string]bool{
`Content-Length`: true,
`Content-Type`: true,
`Last-Modified`: true,
`Expires`: true,
`Cache-Control`: true,
}

0 comments on commit c613140

Please sign in to comment.