MCPcopy Create free account
hub / github.com/Azure/powershell / _prepareRequest

Method _prepareRequest

lib/index.js:2885–2911  ·  view source on GitHub ↗
(method, requestUrl, headers)

Source from the content-addressed store, hash-verified

2883 return this._getAgent(parsedUrl);
2884 }
2885 _prepareRequest(method, requestUrl, headers) {
2886 const info = {};
2887 info.parsedUrl = requestUrl;
2888 const usingSsl = info.parsedUrl.protocol === 'https:';
2889 info.httpModule = usingSsl ? https : http;
2890 const defaultPort = usingSsl ? 443 : 80;
2891 info.options = {};
2892 info.options.host = info.parsedUrl.hostname;
2893 info.options.port = info.parsedUrl.port
2894 ? parseInt(info.parsedUrl.port)
2895 : defaultPort;
2896 info.options.path =
2897 (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
2898 info.options.method = method;
2899 info.options.headers = this._mergeHeaders(headers);
2900 if (this.userAgent != null) {
2901 info.options.headers['user-agent'] = this.userAgent;
2902 }
2903 info.options.agent = this._getAgent(info.parsedUrl);
2904 // gives handlers an opportunity to participate
2905 if (this.handlers) {
2906 for (const handler of this.handlers) {
2907 handler.prepareRequest(info.options);
2908 }
2909 }
2910 return info;
2911 }
2912 _mergeHeaders(headers) {
2913 if (this.requestOptions && this.requestOptions.headers) {
2914 return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));

Callers 1

requestMethod · 0.95

Calls 3

_mergeHeadersMethod · 0.95
_getAgentMethod · 0.95
prepareRequestMethod · 0.45

Tested by

no test coverage detected