shot

Injects a fake HTTP request/response into a node HTTP server

This module has moved and is now available at @hapi/shot. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
Last updated 2 years ago by hueniverse .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install shot 
SYNC missed versions from official npm registry.

shot

Injects a fake HTTP request/response into a node HTTP server for simulating server logic, writing tests, or debugging. Does not use a socket connection so can be run against an inactive server (server not in listen mode).

Build Status

License

This version of the package requires a commercial license. You may not use, copy, or distribute it without first acquiring a commercial license from Sideway Inc. Using this software without a license is a violation of US and international law. To obtain a license, please contact sales@sideway.com. The open source version of this package can be found here.

Example

// Load modules

const Http = require('http');
const Shot = require('shot');


// Declare internals

const internals = {};


internals.main = function () {

    const dispatch = function (req, res) {

        const reply = 'Hello World';
        res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length });
        res.end(reply);
    };

    const server = Http.createServer(dispatch);

    Shot.inject(dispatch, { method: 'get', url: '/' }, (res) => {

        console.log(res.payload);
    });
};


internals.main();

Note how server.listen is never called.

API

See the API Reference

Current Tags

  • 4.0.7                                ...           latest (2 years ago)

67 Versions

  • 4.0.7 [deprecated]           ...           2 years ago
  • 4.0.6 [deprecated]           ...           2 years ago
  • 4.0.5 [deprecated]           ...           3 years ago
  • 4.0.4 [deprecated]           ...           3 years ago
  • 4.0.3 [deprecated]           ...           3 years ago
  • 4.0.2 [deprecated]           ...           3 years ago
  • 4.0.1 [deprecated]           ...           3 years ago
  • 4.0.0 [deprecated]           ...           3 years ago
  • 3.4.2 [deprecated]           ...           3 years ago
  • 3.4.1 [deprecated]           ...           3 years ago
  • 3.4.0 [deprecated]           ...           4 years ago
  • 3.3.2 [deprecated]           ...           4 years ago
  • 3.3.1 [deprecated]           ...           4 years ago
  • 3.3.0 [deprecated]           ...           4 years ago
  • 3.2.1 [deprecated]           ...           4 years ago
  • 3.2.0 [deprecated]           ...           4 years ago
  • 3.1.1 [deprecated]           ...           4 years ago
  • 3.1.0 [deprecated]           ...           4 years ago
  • 3.0.1 [deprecated]           ...           5 years ago
  • 3.0.0 [deprecated]           ...           5 years ago
  • 2.0.1 [deprecated]           ...           5 years ago
  • 1.7.0 [deprecated]           ...           5 years ago
  • 1.6.1 [deprecated]           ...           5 years ago
  • 1.6.0 [deprecated]           ...           5 years ago
  • 1.5.3 [deprecated]           ...           5 years ago
  • 1.5.2 [deprecated]           ...           5 years ago
  • 1.5.1 [deprecated]           ...           5 years ago
  • 1.5.0 [deprecated]           ...           6 years ago
  • 1.4.2 [deprecated]           ...           6 years ago
  • 1.4.1 [deprecated]           ...           6 years ago
  • 1.4.0 [deprecated]           ...           6 years ago
  • 1.3.5 [deprecated]           ...           6 years ago
  • 1.3.4 [deprecated]           ...           6 years ago
  • 1.3.3 [deprecated]           ...           6 years ago
  • 1.3.2 [deprecated]           ...           7 years ago
  • 1.3.1 [deprecated]           ...           7 years ago
  • 1.3.0 [deprecated]           ...           7 years ago
  • 1.2.0 [deprecated]           ...           7 years ago
  • 1.1.1 [deprecated]           ...           7 years ago
  • 1.1.0 [deprecated]           ...           7 years ago
  • 1.0.0 [deprecated]           ...           7 years ago
  • 0.4.5 [deprecated]           ...           7 years ago
  • 0.4.4 [deprecated]           ...           7 years ago
  • 0.4.3 [deprecated]           ...           7 years ago
  • 0.4.2 [deprecated]           ...           7 years ago
  • 0.4.1 [deprecated]           ...           7 years ago
  • 0.4.0 [deprecated]           ...           7 years ago
  • 0.3.0 [deprecated]           ...           7 years ago
  • 0.2.2 [deprecated]           ...           8 years ago
  • 0.2.1 [deprecated]           ...           8 years ago
  • 0.2.0 [deprecated]           ...           8 years ago
  • 0.1.3 [deprecated]           ...           8 years ago
  • 0.1.2 [deprecated]           ...           8 years ago
  • 0.1.1 [deprecated]           ...           8 years ago
  • 0.1.0 [deprecated]           ...           8 years ago
  • 0.0.13 [deprecated]           ...           8 years ago
  • 0.0.12 [deprecated]           ...           8 years ago
  • 0.0.11 [deprecated]           ...           8 years ago
  • 0.0.10 [deprecated]           ...           8 years ago
  • 0.0.9 [deprecated]           ...           8 years ago
  • 0.0.8 [deprecated]           ...           8 years ago
  • 0.0.7 [deprecated]           ...           8 years ago
  • 0.0.6 [deprecated]           ...           8 years ago
  • 0.0.5 [deprecated]           ...           8 years ago
  • 0.0.4 [deprecated]           ...           8 years ago
  • 0.0.3 [deprecated]           ...           8 years ago
  • 0.0.1 [deprecated]           ...           8 years ago
Maintainers (1)
Downloads
Today 31
This Week 140
This Month 575
Last Day 75
Last Week 286
Last Month 1,939
Dependencies (2)
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |