better code comment and move val into its own const

This commit is contained in:
6543 2022-11-12 00:29:45 +01:00
parent 9df4a50e10
commit ba00db990b
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862

View file

@ -29,6 +29,7 @@ const (
// pages server
PagesCacheIndicatorHeader = "X-Pages-Cache"
symlinkReadLimit = 10000
// gitea
giteaObjectTypeHeader = "X-Gitea-Object-Type"
@ -128,9 +129,9 @@ func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource str
objType := resp.Header.Get(giteaObjectTypeHeader)
log.Trace().Msgf("server raw content object %q", objType)
if client.followSymlinks && objType == objTypeSymlink {
// limit to 1000 chars
defer reader.Close()
linkDestBytes, err := io.ReadAll(io.LimitReader(reader, 10000))
// read limited chars for symlink
linkDestBytes, err := io.ReadAll(io.LimitReader(reader, symlinkReadLimit))
if err != nil {
return nil, nil, http.StatusInternalServerError, err
}