1.0.1 • Published 8 years ago

broken-http-server v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

broken-http-server

Build Status

A broken HTTP server for testing.

Install

As a CLI:

npm install -g broken-http-server

As a library:

npm install --save-dev broken-http-server

Requires Node v6+

Usage

broken-http-server [port]

As a library:

import startServer from 'broken-http-server'
startServer()
  .then(({ baseURL, close }) => {
    console.log(`server listening at ${baseURL}`)
    console.log('closing server...')
    return close()
  }).then(() => {
    console.log('server closed')
  })

See ./test directory for more usage examples.

Routes

GET /abort

Closes the socket immediately before replying

GET /content-length-too-small

Sends content-length header which is smaller than the actual body

GET /content-length-too-large

Sends content-length header which is larger than the actual body

GET /stop-writing-body-halfway

Writes about half the body but stops half way without closing the socket.