Merge branch 'main' into std-http

This commit is contained in:
6543 2022-08-28 14:35:27 +02:00
commit e1c78d6069
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
17 changed files with 138 additions and 79 deletions

View file

@ -16,8 +16,7 @@ import (
)
const (
giteaAPIRepos = "/api/v1/repos/"
giteaObjectTypeHeader = "X-Gitea-Object-Type"
giteaAPIRepos = "/api/v1/repos/"
)
type Client struct {
@ -71,7 +70,10 @@ func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource str
switch resp.StatusCode() {
case fasthttp.StatusOK:
if client.followSymlinks && string(resp.Header.Peek(giteaObjectTypeHeader)) == "symlink" {
objType := string(resp.Header.Peek(giteaObjectTypeHeader))
log.Trace().Msgf("server raw content object: %s", objType)
if client.followSymlinks && objType == "symlink" {
// TODO: limit to 1000 chars if we switched to std
linkDest := strings.TrimSpace(string(resp.Body()))
log.Debug().Msgf("follow symlink from '%s' to '%s'", resource, linkDest)
return client.ServeRawContent(targetOwner, targetRepo, ref, linkDest)