request/core

Name: core

Owner: request

Description: HTTP Client Library

Created: 2015-12-01 09:30:28.0

Updated: 2018-03-20 17:02:33.0

Pushed: 2017-10-07 16:38:20.0

Homepage: null

Size: 196

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

@request/core

HTTP Duplex Streams2 client. By default it behaves identically to Node's Core http.request method.

Each additional feature must be enabled explicitly via option. Some options requires additional dependencies.


Options

URL
url/uri qs
Body
form json body multipart - requires @request/multipart

Pass Object for multipart/form-data body:

et item
ipart: {photo: fs.createReadStream('cat.png')}
ass additional info about the uploaded item
ipart: {
oto: {
value: fs.createReadStream('cat.png'),
options: {filename: 'cat.png', contentType: 'image/png', knownLength: 22025}


ass array of values for this item
ipart: {attachments: [fs.createReadStream('cat.png'), fs.createReadStream('dog.png')]}

The item's value can be either: Stream, Request, Buffer or String.

Pass Array for any other multipart/[TYPE], defaults to multipart/related:

xample: Upload image to Google Drive
ipart: [

'Content-Type': 'application/json',
body: JSON.stringify({title: 'cat.png'})


'Content-Type': 'image/png',
body: fs.createReadStream('cat.png')


The body key is required and reserved for setting up the item's body. It can be either: Stream, Request, Buffer or String.

Additionally you can set preambleCRLF and/or postambleCRLF to true.

Authentication
auth - digest auth requires @request/digest oauth - requires @request/oauth hawk - requires hawk httpSignature - requires http-signature aws - requires aws-sign2
Modifiers
gzip encoding - requires iconv-lite
Misc
cookie - requires tough-cookie length callback

buffers the response body

redirect timeout proxy

oxy: 'http://localhost:6767'

oxy: url.parse('http://localhost:6767')

oxy: {
url: 'http://localhost:6767',
headers: {
  allow: ['header-name'],
  exclusive: ['header-name']
}


tunnel - requires tunnel-agent parse stringify end

HTTPDuplex

Private Flags and State Public Methods

Request

Methods
Events
req/res

Generated Options

Logger

Requires @request/log

BUG=req,res node app.js

Errors
oauth
Notice

This module may contain code snippets initially implemented in request by request contributors.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.