How to use the @hint/utils-connector-tools.Requester function in @hint/utils-connector-tools

To help you get started, we’ve selected a few @hint/utils-connector-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / connector-puppeteer / src / connector.ts View on Github external
public fetchContent(target: URL | string, customHeaders?: object): Promise {
        /*
         * TODO: This should create a new tab, navigate to the
         * resource and control what is received somehow via an event.
         */
        const assigns = compact([this && this._headers, customHeaders]);
        const headers = Object.assign({}, ...assigns);
        const href = typeof target === 'string' ? target : target.href;
        const options = {
            headers,
            // we sync the ignore SSL error options with `request`. This is neeeded for local https tests
            rejectUnauthorized: !this._options.ignoreHTTPSErrors,
            strictSSL: !this._options.ignoreHTTPSErrors
        };

        const request = new Requester(options);

        return request.get(href);
    }
github webhintio / hint / packages / utils-debugging-protocol-common / src / request-response.ts View on Github external
private fetchContent(href: string, headers: HttpHeaders) {
        const options = {
            headers,
            // we sync the ignore SSL error options with `request`. This is neeeded for local https tests
            rejectUnauthorized: !this._ignoreHTTPSErrors,
            strictSSL: !this._ignoreHTTPSErrors
        };

        const request: Requester = new Requester(options);

        return request.get(href);
    }
github webhintio / hint / packages / connector-jsdom / src / connector.ts View on Github external
private _fetchUrl(target: URL, customHeaders?: object): Promise {
        const uri: string = url.format(target);

        /* istanbul ignore else */
        if (!customHeaders) {
            return this.request.get(uri);
        }

        const r: Requester = new Requester({
            headers: customHeaders,
            rejectUnauthorized: !this._options.ignoreHTTPSErrors,
            strictSSL: !this._options.ignoreHTTPSErrors
        });

        return r.get(uri);
    }
github webhintio / hint / packages / connector-jsdom / src / connector.ts View on Github external
public constructor(server: Engine, config?: any) {
        this._options = { ...defaultOptions, ...config };

        const requesterOptions = {
            rejectUnauthorized: !this._options.ignoreHTTPSErrors,
            strictSSL: !this._options.ignoreHTTPSErrors,
            ...this._options.requestOptions || {}
        };

        this.request = new Requester(requesterOptions);
        this.server = server;
        this._timeout = server.timeout;
        this._subprocesses = new Set();

        (server as Engine).on('parse::end::html', (event) => {
            /* istanbul ignore if */
            if (!this._originalDocument) {
                this._originalDocument = event.document;
            }
        });
    }
github webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
public fetchContent(target: URL | string, customHeaders?: object): Promise {
        /*
         * TODO: This should create a new tab, navigate to the
         * resource and control what is received somehow via an event.
         */
        const href: string = typeof target === 'string' ? target : target.href;
        const options = {
            headers: customHeaders || {},
            // we sync the ignore SSL error options with `request`. This is neeeded for local https tests
            rejectUnauthorized: !this._options.ignoreHTTPSErrors,
            strictSSL: !this._options.ignoreHTTPSErrors
        };

        const request: Requester = new Requester(options);

        return request.get(href);
    }
github webhintio / hint / packages / hint-no-broken-links / src / hint.ts View on Github external
public constructor(context: HintContext) {

        const options: CoreOptions = { method: context.hintOptions && context.hintOptions.method ? context.hintOptions.method : 'GET' };
        const requester = new Requester(options);
        const brokenStatusCodes = [404, 410, 500, 503];

        /** Stores the elements with their URLs which have been collected while traversing the page. */
        const collectedElementsWithURLs: [HTMLElement, string[]][] = [];

        /** Stores the URLs and it's response status codes */
        const fetchedURLs: any[] = [];

        /** Returns an array with all the URLs in the given `srcset` attribute or an empty string if none. */
        const parseSrcSet = (element: HTMLElement): string[] => {
            const srcset = element.getAttribute('srcset');

            if (!srcset) {
                return [];
            }