Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
[#125] Set object ids in a separate function
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
  • Loading branch information
KirillovDenis authored and cthulhu-rider committed Feb 15, 2022
1 parent 2764fab commit 39c29c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions downloader/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ func (r request) receiveFile(clnt pool.Object, objectAddress *object.Address) {
contentType = val
}
}
r.Response.Header.Set(hdrObjectID, obj.ID().String())
r.Response.Header.Set(hdrOwnerID, obj.OwnerID().String())
r.Response.Header.Set(hdrContainerID, obj.ContainerID().String())

idsToResponse(&r.Response, obj)

if len(contentType) == 0 {
if readDetector.err != nil {
Expand Down
11 changes: 8 additions & 3 deletions downloader/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ func (r request) headObject(clnt pool.Object, objectAddress *object.Address) {
contentType = val
}
}
r.Response.Header.Set(hdrObjectID, obj.ID().String())
r.Response.Header.Set(hdrOwnerID, obj.OwnerID().String())
r.Response.Header.Set(hdrContainerID, obj.ContainerID().String())

idsToResponse(&r.Response, obj)

if len(contentType) == 0 {
objRange := object.NewRange()
Expand All @@ -86,6 +85,12 @@ func (r request) headObject(clnt pool.Object, objectAddress *object.Address) {
r.SetContentType(contentType)
}

func idsToResponse(resp *fasthttp.Response, obj *object.Object) {
resp.Header.Set(hdrObjectID, obj.ID().String())
resp.Header.Set(hdrOwnerID, obj.OwnerID().String())
resp.Header.Set(hdrContainerID, obj.ContainerID().String())
}

// HeadByAddress handles head requests using simple cid/oid format.
func (d *Downloader) HeadByAddress(c *fasthttp.RequestCtx) {
d.byAddress(c, request.headObject)
Expand Down

0 comments on commit 39c29c6

Please sign in to comment.