MCPcopy
hub / github.com/scality/cloudserver / parseAttributesHeaders

Function parseAttributesHeaders

lib/api/apiUtils/object/objectAttributes.js:19–42  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

17 * ['ETag', 'ObjectSize', 'x-amz-meta-custom']
18 */
19function 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

Callers 3

objectGetAttributesFunction · 0.85
bucketGetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected