@@ -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