Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/binded/broken-http-server

A broken HTTP server for testing & debugging
https://github.com/binded/broken-http-server

Last synced: about 4 hours ago
JSON representation

A broken HTTP server for testing & debugging

Awesome Lists containing this project

README

        

# broken-http-server

[![Build Status](https://travis-ci.org/blockai/broken-http-server.svg?branch=master)](https://travis-ci.org/blockai/broken-http-server)

A broken HTTP server for testing.

![cli-gif](./stop-writing-body-halfway.gif)

## Install

As a CLI:

```bash
npm install -g broken-http-server
```

As a library:

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

Requires Node v6+

## Usage

```bash
broken-http-server [port]
```

As a library:

```javascript
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](./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.