mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
api: SourceInfo should be populated in GET/HEAD notification. (#4073)
Refer https://github.com/minio/mc/issues/2073
This commit is contained in:
parent
6b4f368dfe
commit
0497d5c342
@ -138,6 +138,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
startOffset = hrange.offsetBegin
|
startOffset = hrange.offsetBegin
|
||||||
length = hrange.getLength()
|
length = hrange.getLength()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicates if any data was written to the http.ResponseWriter
|
// Indicates if any data was written to the http.ResponseWriter
|
||||||
dataWritten := false
|
dataWritten := false
|
||||||
// io.Writer type which keeps track if any data was written.
|
// io.Writer type which keeps track if any data was written.
|
||||||
@ -156,7 +157,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Reads the object at startOffset and writes to mw.
|
// Reads the object at startOffset and writes to mw.
|
||||||
if err := objectAPI.GetObject(bucket, object, startOffset, length, writer); err != nil {
|
if err = objectAPI.GetObject(bucket, object, startOffset, length, writer); err != nil {
|
||||||
errorIf(err, "Unable to write to client.")
|
errorIf(err, "Unable to write to client.")
|
||||||
if !dataWritten {
|
if !dataWritten {
|
||||||
// Error response only if no data has been written to client yet. i.e if
|
// Error response only if no data has been written to client yet. i.e if
|
||||||
@ -174,12 +175,21 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req
|
|||||||
writer.Write(nil)
|
writer.Write(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get host and port from Request.RemoteAddr.
|
||||||
|
host, port, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
|
if err != nil {
|
||||||
|
host, port = "", ""
|
||||||
|
}
|
||||||
|
|
||||||
// Notify object accessed via a GET request.
|
// Notify object accessed via a GET request.
|
||||||
eventNotify(eventData{
|
eventNotify(eventData{
|
||||||
Type: ObjectAccessedGet,
|
Type: ObjectAccessedGet,
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
ObjInfo: objInfo,
|
ObjInfo: objInfo,
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
|
UserAgent: r.UserAgent(),
|
||||||
|
Host: host,
|
||||||
|
Port: port,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +240,21 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re
|
|||||||
// Successful response.
|
// Successful response.
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
|
// Get host and port from Request.RemoteAddr.
|
||||||
|
host, port, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
|
if err != nil {
|
||||||
|
host, port = "", ""
|
||||||
|
}
|
||||||
|
|
||||||
// Notify object accessed via a HEAD request.
|
// Notify object accessed via a HEAD request.
|
||||||
eventNotify(eventData{
|
eventNotify(eventData{
|
||||||
Type: ObjectAccessedHead,
|
Type: ObjectAccessedHead,
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
ObjInfo: objInfo,
|
ObjInfo: objInfo,
|
||||||
ReqParams: extractReqParams(r),
|
ReqParams: extractReqParams(r),
|
||||||
|
UserAgent: r.UserAgent(),
|
||||||
|
Host: host,
|
||||||
|
Port: port,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user