Skip to content

Commit 45ef2f0

Browse files
Merge remote-tracking branch 'origin/bugfix/CLDSRV-839-fix-logs-operation' into w/9.3/bugfix/CLDSRV-839-fix-logs-operation
2 parents 5110e31 + a8f32a3 commit 45ef2f0

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

lib/api/apiUtils/object/corsResponse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ isPreflight) {
125125
rule.exposeHeaders.join(', ');
126126
}
127127
if (isPreflight) {
128-
resHeaders['content-length'] = '0';
128+
resHeaders['content-length'] = 0;
129129
resHeaders.date = new Date().toUTCString();
130130
}
131131
return resHeaders;

lib/utilities/serverAccessLogger.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ const methodToResType = Object.freeze({
251251
'bucketPutEncryption': 'ENCRYPTION',
252252
'bucketPutLogging': 'LOGGING_STATUS',
253253
'bucketGetLogging': 'LOGGING_STATUS',
254-
// 'corsPreflight': '',
254+
'corsPreflight': 'PREFLIGHT',
255255
'completeMultipartUpload': 'UPLOAD',
256256
'initiateMultipartUpload': 'UPLOADS',
257257
'listMultipartUploads': 'UPLOADS',
@@ -295,13 +295,25 @@ function getOperation(req) {
295295
if (req.apiMethod === 'objectPutCopyPart') {
296296
return 'REST.COPY.PART';
297297
}
298+
// Special handling for website operations
299+
if (req.apiMethod === 'websiteGet') {
300+
return 'WEBSITE.GET.OBJECT';
301+
}
302+
if (req.apiMethod === 'websiteHead') {
303+
return 'WEBSITE.HEAD.OBJECT';
304+
}
298305

299306
if (!resourceType) {
300-
process.emitWarning('Unknown apiMethod for server access log', {
301-
type: 'ServerAccessLogWarning',
302-
code: 'UNKNOWN_API_METHOD',
303-
detail: `apiMethod=${req.apiMethod}, method=${req.method}, url=${req.url}`
304-
});
307+
// Only emit a warning if apiMethod is not undefined, meaning request is valid.
308+
// Otherwise we could get spam by invalid or broken requests.
309+
// To help catch missing valid operation.
310+
if (req.apiMethod) {
311+
process.emitWarning('Unknown apiMethod for server access log', {
312+
type: 'ServerAccessLogWarning',
313+
code: 'UNKNOWN_API_METHOD',
314+
detail: `apiMethod=${req.apiMethod}, method=${req.method}, url=${req.url}`
315+
});
316+
}
305317
return `REST.${req.method}.UNKNOWN`;
306318
}
307319

0 commit comments

Comments
 (0)