# request-stream

> Extremely minimal wrapper around node core http/https to conveniently get request and response streams

Latest version **1.2.2** (published 2015-11-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install request-stream
pnpm add request-stream
yarn add request-stream
bun add request-stream
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2015-11-20 |
| First published | 2012-11-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | max ogden |
| Maintainers | karissa, mafintosh, maxogden |

## Links

- npm: https://www.npmjs.com/package/request-stream
- Repository: https://github.com/maxogden/request-stream
- Homepage: https://github.com/maxogden/request-stream#readme
- Issues: https://github.com/maxogden/request-stream/issues
- npm.io page: https://npm.io/package/request-stream

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [xtend](https://npm.io/package/xtend.md) ^4.0.1

## Recent versions

- 1.2.2 (latest) — 2015-11-20
- 1.2.1 — 2015-11-20
- 1.2.0 — 2015-11-19
- 1.1.1 — 2015-11-19
- 1.1.0 — 2015-11-19
- 1.0.0 — 2015-11-19
- 0.1.2 — 2012-11-21
- 0.1.1 — 2012-11-18
- 0.1.0 — 2012-11-18

## README

# request-stream

Extremely minimal wrapper around node core `http`/`https` to get request and response streams.

[![travis][travis-image]][travis-url]

[travis-image]: https://img.shields.io/travis/maxogden/request-stream.svg?style=flat
[travis-url]: https://travis-ci.org/maxogden/request-stream

### why

This module is under 100 lines of code, total file + folder size including `node_modules` is 150kb, compared to 4.7mb for the popular `request` module. The benefit and drawback of this module is that it doesn't have that many features. Use it if you want something low level and lightweight.

## usage

### `var request = require('request-stream')`

You can now use `request` to make new requests

### `var req = request(url, [opts], callback)`

`req` is a writable stream. Data written to it will be written to the request upload body. For requests wtih an upload body you **must call** `req.end()` for the request to finish, even if you write no data to it. If you don't call `req.end()` you will never receive a response.

`url` is the HTTP url for this request

`opts` are request options:

- **method** - default `GET` - sets HTTP method
- **host** - defaults to the hostname from `url`
- **path** - defaults to the path from `url`
- **port** - defaults to the port from `url`
- **maxRedirects** - defaults to `10`
- **followRedirects** - defaults to `true`

`callback` is called with `(err, res)`. If there was no `err`, `res` will be a readable stream of the response data.

In the event that `maxRedirects` was exceeded you will receive both an `err` and the `res` of the last redirect.

Both `req` and `res` are the unmodified [`http.ClientRequest`](https://nodejs.org/api/http.html#http_class_http_clientrequest) and [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_http_incomingmessage)

### convenience methods

These set the `method` option for you

#### request.get(url, opts, cb)

#### request.post(url, opts, cb)

#### request.put(url, opts, cb)

#### request.delete(url, opts, cb)

#### request.head(url, opts, cb)

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