working commit

This commit is contained in:
2026-02-07 14:10:54 +02:00
parent 90905ace89
commit cd274d614a
12 changed files with 124 additions and 276 deletions
+8 -8
View File
@@ -36,14 +36,14 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, error) {
var res bool
authHeader := rctx.GetHeader("Authorization")
if authHeader != "" {
hand.logg.Debugf("Authorization header is %s", authHeader)
username, password, err := auxhttp.ParseBasicAuth(authHeader)
if err != nil {
return res, err
}
hand.logg.Debugf("Authorization username is %s:%s", username, password)
}
if authHeader != "" {
hand.logg.Debugf("Authorization header is %s", authHeader)
username, password, err := auxhttp.ParseBasicAuth(authHeader)
if err != nil {
return res, err
}
hand.logg.Debugf("Authorization username is %s:%s", username, password)
}
res = true
+1
View File
@@ -7,6 +7,7 @@
* Distribution of this work is permitted, but commercial use and
* modifications are strictly prohibited.
*/
package handler
import (
+9 -9
View File
@@ -31,24 +31,23 @@ func (hand *Handler) FileExists(rctx *router.Context) {
rctx.SetStatus(code)
return
}
// TODO
rctx.SetHeader("Content-Type", res.ContentType)
rctx.SetHeader("Content-Length", res.ContentLength)
rctx.SetHeader("Content-Size", res.ContentSize)
rctx.SetHeader("Content-Digest", res.ContentDigest)
//rctx.SetHeader("Content-Length", zeroContentLength)
rctx.SetHeader("Content-Length", zeroContentLength)
rctx.SetStatus(code)
}
func (hand *Handler) PutFile(rctx *router.Context) {
contentLength := rctx.GetHeader("Content-Length")
contentSize := rctx.GetHeader("Content-Size")
contentType := rctx.GetHeader("Content-Type")
filepath, _ := rctx.GetSubpath("filepath")
params := &operator.PutFileParams{
Filepath: filepath,
ContentLength: contentLength,
ContentType: contentType,
Source: rctx.Request.Body,
Filepath: filepath,
ContentType: contentType,
ContentSize: contentSize,
Source: rctx.Request.Body,
}
ctx := rctx.GetContext()
@@ -76,8 +75,9 @@ func (hand *Handler) GetFile(rctx *router.Context) {
}
rctx.SetHeader("Content-Type", res.ContentType)
rctx.SetHeader("Content-Length", res.ContentLength)
rctx.SetHeader("Content-Size", res.ContentSize)
rctx.SetHeader("Content-Digest", res.ContentDigest)
rctx.SetHeader("Content-Length", res.ContentSize)
rctx.SetStatus(code)
if res.Source != nil {
+7 -7
View File
@@ -10,7 +10,7 @@
package handler
import (
"net/http"
"net/http"
"mstore/app/operator"
"mstore/app/router"
@@ -21,12 +21,12 @@ func (hand *Handler) GetVersion(rctx *router.Context) {
params := &operator.GetVersionParams{}
hand.DumpHeaders("GetVersion", rctx)
authorization := rctx.GetHeader("Authorization")
if authorization == "" {
rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`)
rctx.SetStatus(http.StatusUnauthorized)
return
}
authorization := rctx.GetHeader("Authorization")
if authorization == "" {
rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`)
rctx.SetStatus(http.StatusUnauthorized)
return
}
ctx := rctx.GetContext()
_, code, err := hand.oper.GetVersion(ctx, params)
if err != nil {