HTTP Client Utilities

Related tags

Node.js HTTP wreck
Overview

@hapi/wreck

HTTP client utilities.

wreck is part of the hapi ecosystem and was designed to work seamlessly with the hapi web framework and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out hapi – they work even better together.

Visit the hapi.dev Developer Portal for tutorials, documentation, and support

Useful resources

Comments
  • Fix issues with node 0.12

    Fix issues with node 0.12

    The main issue is that calls to abort() can now cause the stream to stop without any notification at all. As a consequence, I have implemented a workaround that intercepts all calls to abort().

    The SSL test fix might be specific to my homebrew 0.12 install, though it should not cause any issues.

    bug 
    opened by kanongil 17
  • Dont try to parse JSON if the statusCode is 204 (No Content)

    Dont try to parse JSON if the statusCode is 204 (No Content)

    I dont think that wreck should try to parse json when the status code is 204 no content. We keep getting '''Unexpected end of line''' and other errors.

    I have created a test and updated the code not to parse JSON if the statusCode is 204.

    If there is any problem with it, just let me know :)

    bug 
    opened by Torsph 15
  • How to handle HTTP_PROXY with Wreck

    How to handle HTTP_PROXY with Wreck

    We need to pass through proxy for our http(s) calls.

    request npm use by default envrionment variables HTTP_PROXY, HTTPS_PROXY, NO_PROXY Is there a way to configure that with wreck ?

    At the moment we use with success global-tunnel npm but he did'nt provide the no_proxy feature.

    non issue 
    opened by SachaCR 14
  • Missing release notes for 16.0 release

    Missing release notes for 16.0 release

    Is there a chance to get some release notes about the new major version 16.0 in https://github.com/hapijs/wreck/milestone/67?closed=1 (As it happened, for instance, with https://github.com/hapijs/wreck/issues/244 in https://github.com/hapijs/wreck/milestone/59?closed=1)?

    documentation 
    opened by nulltoken 13
  • Support promises on shortcut methods

    Support promises on shortcut methods

    Only supporting the shortcut methods, for now, as they previously required a callback, which makes it easy to detect users who will instead use promises.

    feature 
    opened by geek 12
  • Mistake in manual

    Mistake in manual

    Hi

    const Wreck = require('wreck');
    
    Wreck.post('https://posttestserver.com/post.php', { payload: { hello: 'post' } }, (err, res, payload) => {
        /* do stuff */
    });
    

    this gives me error

    Error: Uncaught error: options.payload must be a string, a Buffer, or a Stream

    Am i doing something wrong or there is a mistake in manual?

    Indrek

    non issue 
    opened by indreek 11
  • Stack trace lost during exception in latest Wreck

    Stack trace lost during exception in latest Wreck

    UPDATE: The problem below is a fundamental issue with async/await, the purpose of the issue is to see if we can find a way to resolve it in the wreck library.

    When a Wreck call throws an exception, the error returned has an incomplete stack.

    See below for the example code and output.

    $ node .
    Error: Response Error: 500 Internal Server Error
        at internals.Client._shortcut (.../wreck-async-await-stacktrace/node_modules/wreck/lib/index.js:593:11)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
    

    REL: https://github.com/lostthetrail/wreck-async-await-stacktrace/tree/master

    I am investigating this, but if someone sees this issue and know the issue, feel free to give me a heads up.

    Node v8.9.1

    opened by lostthetrail 10
  • Request - built-in handling of x-ww-form-urlencoded POST payloads?

    Request - built-in handling of x-ww-form-urlencoded POST payloads?

    Unless I've missed something, POST'ing to endpoints that require this content-type requires jumping through hoops to correctly encode your payload.

    It seems like it would be helpful if it was possible to pass in an object or some JSON and have it encoded for you. I'm not quite sure how the mechanics of this would work, but implementing it wouldn't be that hard.

    If there's interest, I'd be happy to try to put together a pull request.

    feature 
    opened by mattboutet 10
  • Fails on node v4

    Fails on node v4

    > lab -i 22
    
    _http_server.js:515
      this._handle.readStart();
                  ^
    
    TypeError: Cannot read property 'readStart' of null
        at Socket.onSocketResume (_http_server.js:515:15)
        at emitNone (events.js:67:13)
        at Socket.emit (events.js:166:7)
        at resume_ (_stream_readable.js:712:10)
        at doNTCallback2 (node.js:429:9)
        at process._tickDomainCallback (node.js:384:17)
    

    Also 84 and 85.

    test 
    opened by hueniverse 10
  • Preserve `agents` across .defaults({...})

    Preserve `agents` across .defaults({...})

    problem

    const Wreck = require('wreck') and Wreck.defaults({}) instantiate their own agents rather than preserving the properties as you might expect when creating increasing granular http clients via .defaults()

    (my) use case

    declare application-level defaults via a hapijs plugin

    const MAX_FREE_SOCKETS = process.env.MAX_FREE_SOCKETS || 256;
    const MAX_SOCKETS = process.env.MAX_SOCKETS || 128;
    const KEEP_ALIVE = process.env.KEEP_ALIVE || true;
    const KEEP_ALIVE_MSECS = process.env.KEEP_ALIVE_MSECS || 512;
    
    exports.register = function (server, options, next) {
    
        function configureAgent(agent /* , type */) {
            agent.maxFreeSockets = MAX_FREE_SOCKETS;
            agent.maxSockets = MAX_SOCKETS;
            agent.keepAlive = KEEP_ALIVE;
            agent.keepAliveMsecs = KEEP_ALIVE_MSECS;
        }
    
        configureAgent(require('wreck').agents.http);
        configureAgent(require('wreck').agents.https);
        configureAgent(require('wreck').agents.httpsAllowUnauthorized);
        configureAgent(require('http').globalAgent);
        configureAgent(require('https').globalAgent);
    
        next();
      }
    
    exports.register.attributes = {
        name: 'configure-http-agents',
        version: '1'
    };
    

    create an http client pre-wired for our API

    function generateHerokuClient() {
    
        const proto = options.proto || HEROKU_API_PROTO;
        const host = options.host || HEROKU_API_HOST;
        const timeout = options.timeout || HTTP_TIMEOUT;
        const userAgent = options['user-agent'] || '';
        const variant = options.variant || 'application/vnd.heroku+json; version=3';
        const headers = {
            'accept': variant,
            'user-agent': `${pkg.name}/${pkg.version} ${userAgent}`.trim()
        };
    
        const heroku = Wreck.defaults({
            baseUrl: `${proto}//${host}/`,
            headers,
            timeout,
            json: true
        });
    
        return heorku;
    }
    

    make succinct API calls

    heroku.get('/version', (err, version) => {
        reply(version);
    });
    
    feature 
    opened by jmonster 9
  • Redirect 302 changes method from POST to GET

    Redirect 302 changes method from POST to GET

    I'm having some problems when following https redirects with wreck.

    I have this code:

    server.ext('onRequest', function (request, reply) {
        Wreck.read(request.raw.req, null, function (err, reqBody) {
    
          var requestOptions = {
            baseUrl: request.host,
            headers: request.headers,
            redirects: 10,
            beforeRedirect: function (redirectMethod, statusCode, location, resHeaders, redirectOptions, next) {
              console.log('location: ' + location);
              return next();
            },
            timeout: 100000,
            secureProtocol: 'SSLv3_method'
          };
    
          if(request.method === 'post') {
            requestOptions.payload = reqBody;
          }
    
          var optionalCallback = function (err, res) {
            return reply(res);
          };
    
          return Wreck.request(request.method, request.url.href, requestOptions, optionalCallback);
    
        });
    

    It all works fine until I get a 302 Moved Temporarily which points the request to https://www.testsite.com/test.The location log above in beforeRedirectalso prints https://www.testsite.com/test but the actual url for the Wreck redirect will be http://www.testsite.com:443/test (note that it is still using http). This will end up in socket hangup.

    Am I missing something in my the code or is this a bug in Wreck?

    bug 
    opened by dankle 9
  • add deflate parsing support

    add deflate parsing support

    inflate/deflate is supported by Hapi, along with gzip https://github.com/hapijs/hapi/blob/dc2213c880f16ff6853eccc684782ec888326475/lib/compression.js#L17. But is not listed in the parsing options for Wreck.read.

    This PR adds the option inflate in the same way that gunzip is written.

    opened by sjdonado 1
Owner
hapi.js
The Simple, Secure Framework Developers Trust
hapi.js
Promise based HTTP client for the browser and node.js

axios Promise based HTTP client for the browser and node.js New axios docs website: click here Table of Contents Features Browser Support Installing E

axios 98k Dec 31, 2022
🏊🏾 Simplified HTTP request client.

Deprecated! As of Feb 11th 2020, request is fully deprecated. No new changes are expected to land. In fact, none have landed for some time. For more i

request 25.6k Jan 4, 2023
Ajax for Node.js and browsers (JS HTTP client)

superagent Small progressive client-side HTTP request library, and Node.js module with the same API, supporting many high-level HTTP client features T

Sloth 16.2k Jan 1, 2023
HTTP Client for Visual Studio Code to POST JSON, XML, image, ... files to REST APIs

friflo POST Goal Main goal of this extension is storing all HTTP request & response data automatically as files in a VSCode workspace. This ensures th

Ullrich Praetz 2 Nov 18, 2021
Very very very powerful, extensible http client for both node.js and browser.

ES-Fetch-API 中文 | English Very very very powerful, extensible http client for both node.js and browser. Why should you use ES-Fetch API? Still using a

null 17 Dec 12, 2022
A full-featured http proxy for node.js

node-http-proxy node-http-proxy is an HTTP programmable proxying library that supports websockets. It is suitable for implementing components such as

http ... PARTY! 13.1k Jan 3, 2023
HTTP server mocking and expectations library for Node.js

Nock HTTP server mocking and expectations library for Node.js Nock can be used to test modules that perform HTTP requests in isolation. For instance,

Nock 11.9k Jan 3, 2023
🌐 Human-friendly and powerful HTTP request library for Node.js

Sindre's open source work is supported by the community. Special thanks to: Human-friendly and powerful HTTP request library for Node.js Moving from R

Sindre Sorhus 12.5k Jan 9, 2023
make streaming http requests

hyperquest treat http requests as a streaming transport The hyperquest api is a subset of request. This module works in the browser with browserify. r

James Halliday 711 Sep 8, 2022
Full-featured, middleware-oriented, programmatic HTTP and WebSocket proxy for node.js

rocky A multipurpose, full-featured, middleware-oriented and hackable HTTP/S and WebSocket proxy with powerful built-in features such as versatile rou

Tom 370 Nov 24, 2022
Simplifies node HTTP request making.

Requestify - Simplifies node HTTP request making. Requestify is a super easy to use and extendable HTTP client for nodeJS + it supports cache (-:. Ins

Ran Mizrahi 222 Nov 28, 2022
Wrap native HTTP requests with RFC compliant cache support

cacheable-request Wrap native HTTP requests with RFC compliant cache support RFC 7234 compliant HTTP caching for native Node.js HTTP/HTTPS requests. C

Luke Childs 259 Dec 20, 2022
Run HTTP over UDP with Node.js

nodejs-httpp - Run HTTP over UDP based transport and Bring Web in Peer or P2P styles main js modules: udt.js, httpp.js, udts.js and httpps.js, that's

AppNet.Link 142 Aug 2, 2022
Global HTTP/HTTPS proxy agent configurable using environment variables.

global-agent Global HTTP/HTTPS proxy configurable using environment variables. Usage Setup proxy using global-agent/bootstrap Setup proxy using bootst

Gajus Kuizinas 267 Dec 20, 2022
An HTTP Web Server for Chrome (chrome.sockets API)

An HTTP Web Server for Chrome (chrome.sockets API)

Kyle Graehl 1.2k Dec 31, 2022
Library agnostic in-process recording of http(s) requests and responses

@gr2m/http-recorder Library agnostic in-process recording of http(s) requests and responses Install npm install @gr2m/http-recorder Usage import http

Gregor Martynus 4 May 12, 2022
A fully-featured Node.js REST client built for ease-of-use and resilience

flashheart A fully-featured Node.js REST client built for ease-of-use and resilience flashheart is built on http-transport to provide everything you n

BBC 118 Jun 21, 2022
Minimal, type-safe REST client using JS proxies

Minimal, type-safe REST client using JS proxies.

Johann Schopplich 124 Dec 16, 2022
📡Usagi-http-interaction: A library for interacting with Http Interaction API

?? - A library for interacting with Http Interaction API (API for receiving interactions.)

Rabbit House Corp 3 Oct 24, 2022
Node.js web server framework for Http/1.1 or Http/2

Node.js web server framework for Http/1.1 or Http/2 Description: This is http framework, you can use it to create Http/1.1 or Http/2 service。 Now let'

Jeremy Yu 10 Mar 24, 2022