MCPcopy Create free account
hub / github.com/TritonDataCenter/node-manta / createOptions

Function createOptions

lib/client.js:187–277  ·  view source on GitHub ↗
(opts, userOpts)

Source from the content-addressed store, hash-verified

185
186
187function createOptions(opts, userOpts) {
188 assert.object(opts, 'options');
189 assert.string(opts.path, 'options.path');
190 assert.object(userOpts, 'userOptions');
191
192 var id = opts.req_id || libuuid.v4();
193 var options = {
194 headers: normalizeHeaders(userOpts.headers),
195 id: id,
196 path: opts.path.replace(/\/$/, ''),
197 query: clone(userOpts.query || {})
198 };
199
200 if (userOpts.role)
201 options.headers['role'] = userOpts.role.join(',');
202
203 options.headers.accept = options.headers.accept || opts.accept || '*/*';
204
205 if (options.headers['content-length'] !== undefined ||
206 opts.contentLength !== undefined) {
207 options.headers['content-length'] =
208 options.headers['content-length'] ||
209 opts.contentLength;
210 }
211
212 if (options.headers['content-md5'] || opts.contentMD5) {
213 options.headers['content-md5'] =
214 options.headers['content-md5'] ||
215 opts.contentMD5;
216 }
217
218 if (options.headers['content-type'] || opts.contentType) {
219 options.headers['content-type'] =
220 options.headers['content-type'] ||
221 opts.contentType;
222 }
223
224 if (options.headers.expect || opts.expect) {
225 options.headers.expect = options.headers.expect || opts.expect;
226 }
227
228 if (options.headers.location || opts.location) {
229 options.headers.location =
230 options.headers.location ||
231 opts.location;
232 }
233
234 options.headers['x-request-id'] = options.headers['x-request-id'] || id;
235
236 var tmp = {};
237 Object.keys(options.headers).forEach(function (k) {
238 if (options.headers[k] !== undefined)
239 tmp[k] = options.headers[k];
240 });
241 options.headers = tmp;
242
243 if (opts.limit)
244 options.query.limit = options.query.limit || opts.limit;

Callers 1

client.jsFile · 0.85

Calls 1

normalizeHeadersFunction · 0.85

Tested by

no test coverage detected