# should-http

> Http requests, response assertions for should.js

Latest version **0.1.1** (published 2017-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install should-http
pnpm add should-http
yarn add should-http
bun add should-http
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-03-22 |
| First published | 2014-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | TJ Holowaychuk |
| Maintainers | btd |
| Keywords | should, should.js, http |

## Links

- npm: https://www.npmjs.com/package/should-http
- Repository: https://github.com/shouldjs/http
- Issues: https://github.com/shouldjs/http/issues
- npm.io page: https://npm.io/package/should-http

## Dependencies (1)

- [content-type](https://npm.io/package/content-type.md) ^1.0.2

## Recent versions

- 0.1.1 (latest) — 2017-03-22
- 0.1.0 — 2017-02-06
- 0.0.4 — 2015-06-18
- 0.0.3 — 2015-04-21
- 0.0.2 — 2014-05-29
- 0.0.1 — 2014-05-29

## README

# should.js http assertions

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

This module can be usefull for asserting on node standard `http` modele request and response.

## Install

```
npm install should-http --save-dev
```

```
require('should-http');
```

That row patch your should instance adding assertions. With mocha you can use it via `-r` switch.

This module have built in formatting for node http IncommingMessage's.

## .status(code)

Asserts that `.statusCode` is `code`:
```javascript
res.should.have.status(200);
```

## .header(field[, value])

Asserts that a `.headers` object with `field` and optional `value` are present:
```javascript
res.should.have.header('content-length');
res.should.have.header('Content-Length', '123');
```

## .json()

Assert that Content-Type is "application/json"

```javascript
res.should.be.json()
```

## .html()

Assert that Content-Type is "text/html"
```javascript
res.should.be.html()
```

## .xml()

Assert that Content-Type is "application/xml"

```js
res.should.be.xml()
```

## .contentType(type [, charset])

Assert that Content-Type is a given `type` with optional `charset`

```js
res.should.have.contentType('application/xml');
```

---
_Source: https://npm.io/package/should-http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
