* Parse and validate attribute headers from a request. * @param {object} headers - Request headers object * @param {string} headerName - Name of the header to parse (e.g., 'x-amz-object-attributes') * @param {Set } supportedAttributes - Set of valid attribute names * @returns {Set
(headers, headerName, supportedAttributes)
| 17 | * ['ETag', 'ObjectSize', 'x-amz-meta-custom'] |
| 18 | */ |
| 19 | function parseAttributesHeaders(headers, headerName, supportedAttributes) { |
| 20 | const result = new Set(); |
| 21 | |
| 22 | const rawValue = headers[headerName]; |
| 23 | if (rawValue === null || rawValue === undefined) { |
| 24 | return result; |
| 25 | } |
| 26 | |
| 27 | for (const rawAttr of rawValue.split(',')) { |
| 28 | let attr = rawAttr.trim(); |
| 29 | |
| 30 | if (!supportedAttributes.has(attr)) { |
| 31 | attr = attr.toLowerCase(); |
| 32 | } |
| 33 | |
| 34 | if (!attr.startsWith('x-amz-meta-') && !supportedAttributes.has(attr)) { |
| 35 | throw errorInstances.InvalidArgument.customizeDescription('Invalid attribute name specified.'); |
| 36 | } |
| 37 | |
| 38 | result.add(attr); |
| 39 | } |
| 40 | |
| 41 | return result; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * buildAttributesXml - Builds XML reponse for requested object attributes |
no outgoing calls
no test coverage detected