forked from TrueCloudLab/frostfs-s3-gw
parent
ab8dd4201c
commit
c4631e5806
2 changed files with 14 additions and 16 deletions
|
@ -13,8 +13,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type copyObjectArgs struct {
|
type copyObjectArgs struct {
|
||||||
IfModifiedSince time.Time
|
IfModifiedSince *time.Time
|
||||||
IfUnmodifiedSince time.Time
|
IfUnmodifiedSince *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// path2BucketObject returns bucket and object.
|
// path2BucketObject returns bucket and object.
|
||||||
|
@ -74,11 +74,11 @@ func (h *handler) CopyObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !args.IfModifiedSince.IsZero() && inf.Created.Before(args.IfModifiedSince) {
|
if args.IfModifiedSince != nil && inf.Created.Before(*args.IfModifiedSince) {
|
||||||
w.WriteHeader(http.StatusNotModified)
|
w.WriteHeader(http.StatusNotModified)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !args.IfUnmodifiedSince.IsZero() && inf.Created.After(args.IfUnmodifiedSince) {
|
if args.IfUnmodifiedSince != nil && inf.Created.After(*args.IfUnmodifiedSince) {
|
||||||
w.WriteHeader(http.StatusPreconditionFailed)
|
w.WriteHeader(http.StatusPreconditionFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type getObjectArgs struct {
|
type getObjectArgs struct {
|
||||||
IfModifiedSince time.Time
|
IfModifiedSince *time.Time
|
||||||
IfUnmodifiedSince time.Time
|
IfUnmodifiedSince *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchRangeHeader(headers http.Header, fullSize uint64) (*layer.RangeParams, error) {
|
func fetchRangeHeader(headers http.Header, fullSize uint64) (*layer.RangeParams, error) {
|
||||||
|
@ -90,11 +90,11 @@ func (h *handler) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !args.IfModifiedSince.IsZero() && inf.Created.Before(args.IfModifiedSince) {
|
if args.IfModifiedSince != nil && inf.Created.Before(*args.IfModifiedSince) {
|
||||||
w.WriteHeader(http.StatusNotModified)
|
w.WriteHeader(http.StatusNotModified)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !args.IfUnmodifiedSince.IsZero() && inf.Created.After(args.IfUnmodifiedSince) {
|
if args.IfUnmodifiedSince != nil && inf.Created.After(*args.IfUnmodifiedSince) {
|
||||||
w.WriteHeader(http.StatusPreconditionFailed)
|
w.WriteHeader(http.StatusPreconditionFailed)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -133,18 +133,16 @@ func parseGetObjectArgs(headers http.Header) (*getObjectArgs, error) {
|
||||||
return args, nil
|
return args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseHTTPTime(data string) (time.Time, error) {
|
func parseHTTPTime(data string) (*time.Time, error) {
|
||||||
var result time.Time
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return result, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if result, err = time.Parse(http.TimeFormat, data); err != nil {
|
result, err := time.Parse(http.TimeFormat, data)
|
||||||
return result, fmt.Errorf("couldn't parse http time %s: %w", data, err)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("couldn't parse http time %s: %w", data, err)
|
||||||
}
|
}
|
||||||
return result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeRangeHeaders(w http.ResponseWriter, params *layer.RangeParams, size int64) {
|
func writeRangeHeaders(w http.ResponseWriter, params *layer.RangeParams, size int64) {
|
||||||
|
|
Loading…
Reference in a new issue