How to use the @hapi/wreck.parseCacheControl function in @hapi/wreck

To help you get started, we’ve selected a few @hapi/wreck 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 hapijs / h2o2 / lib / index.js View on Github external
const Https = require('https');

const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Wreck = require('@hapi/wreck');


const internals = {
    NS_PER_SEC: 1e9
};


internals.defaults = {
    httpClient: {
        request: Wreck.request.bind(Wreck),
        parseCacheControl: Wreck.parseCacheControl.bind(Wreck)
    },
    xforward: false,
    passThrough: false,
    redirects: false,
    timeout: 1000 * 60 * 3, // Timeout request after 3 minutes
    localStatePassThrough: false,   // Pass cookies defined by the server upstream
    maxSockets: Infinity,
    downstreamResponseTime: false
};


internals.schema = Joi.object({
    httpClient: Joi.object({
        request: Joi.func(),
        parseCacheControl: Joi.func()
    }),
github hapijs / h2o2 / test / index.js View on Github external
it('uses a custom http-client', async () => {

        const upstream = Hapi.server();
        upstream.route({ method: 'GET', path: '/', handler: () => 'ok' });
        await upstream.start();

        const httpClient = {
            request: Wreck.request.bind(Wreck),
            parseCacheControl: Wreck.parseCacheControl.bind(Wreck)
        };

        const server = Hapi.server();
        await server.register(H2o2);

        server.route({ method: 'GET', path: '/', handler: { proxy: { host: 'localhost', port: upstream.info.port, httpClient } } });

        const res = await server.inject('/');

        expect(res.payload).to.equal('ok');
    });
});

@hapi/wreck

HTTP Client Utilities

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

82 / 100
Full package analysis