Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-http

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-http - npm Package Compare versions

Comparing version 1.7.1 to 2.0.0

ie8-polyfill.js

11

lib/request.js
// var Base64 = require('Base64')
var capability = require('./capability')
var foreach = require('foreach')
var indexOf = require('indexof')
var inherits = require('inherits')
var keys = require('object-keys')
var response = require('./response')

@@ -38,3 +35,3 @@ var stream = require('stream')

self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
foreach(keys(opts.headers), function (name) {
Object.keys(opts.headers).forEach(function (name) {
self.setHeader(name, opts.headers[name])

@@ -72,3 +69,3 @@ })

// http-browserify did it, so I will too.
if (indexOf(unsafeHeaders, lowerName) !== -1)
if (unsafeHeaders.indexOf(lowerName) !== -1)
return

@@ -115,3 +112,3 @@

if (self._mode === 'fetch') {
var headers = keys(headersObj).map(function (name) {
var headers = Object.keys(headersObj).map(function (name) {
return [headersObj[name].name, headersObj[name].value]

@@ -153,3 +150,3 @@ })

foreach(keys(headersObj), function (name) {
Object.keys(headersObj).forEach(function (name) {
xhr.setRequestHeader(headersObj[name].name, headersObj[name].value)

@@ -156,0 +153,0 @@ })

var capability = require('./capability')
var foreach = require('foreach')
var inherits = require('inherits')

@@ -67,3 +66,3 @@ var stream = require('stream')

var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
foreach(headers, function (header) {
headers.forEach(function (header) {
var matches = header.match(/^([^:]+):\s*(.*)/)

@@ -70,0 +69,0 @@ if (matches) {

{
"name": "stream-http",
"version": "1.7.1",
"version": "2.0.0",
"description": "Streaming http in the browser",

@@ -27,6 +27,3 @@ "main": "index.js",

"builtin-status-codes": "^1.0.0",
"foreach": "^2.0.5",
"indexof": "0.0.1",
"inherits": "^2.0.1",
"object-keys": "^1.0.4",
"xtend": "^4.0.0"

@@ -33,0 +30,0 @@ },

@@ -32,2 +32,9 @@ # stream-http [![Build Status](https://travis-ci.org/jhiesey/stream-http.svg?branch=master)](https://travis-ci.org/jhiesey/stream-http)

### IE8 note:
As of version 2.0.0, IE8 support requires the user to supply polyfills for
`Object.keys`, `Array.prototype.forEach`, and `Array.prototype.indexOf`. Example
implementations are provided in [ie8-polyfill.js](ie8-polyfill.js); alternately,
you may want to consider using [es5-shim](https://github.com/es-shims/es5-shim).
All browsers with full ES5 support shouldn't require any polyfills.
## How do you use it?

@@ -34,0 +41,0 @@

@@ -33,2 +33,3 @@ var Buffer = require('buffer').Buffer

var firstData = true
var failOnData = false

@@ -40,8 +41,14 @@ res.on('end', function () {

res.on('data', function (data) {
if (firstData) {
if (failOnData)
t.fail('unexpected data')
else if (firstData) {
firstData = false
req.abort()
t.end()
} else {
t.fail('unexpected data')
process.nextTick(function () {
// Wait for any data that may have been queued
// in the stream before considering data events
// as errors
failOnData = true
})
}

@@ -48,0 +55,0 @@ })

var Buffer = require('buffer').Buffer
var fs = require('fs')
var keys = require('object-keys')
var test = require('tape')

@@ -9,11 +8,2 @@ var UAParser = require('ua-parser-js')

function indexOf (arr, item) {
var len = arr.length
for (var i = 0; i < len; i++) {
if (arr[i] === item)
return i
}
return -1
}
test('headers', function (t) {

@@ -33,6 +23,6 @@ http.get({

}
var header1Pos = indexOf(rawHeaders, 'test-response-header')
var header1Pos = rawHeaders.indexOf('test-response-header')
t.ok(header1Pos >= 0, 'raw response header 1 present')
t.equal(rawHeaders[header1Pos + 1], 'bar', 'raw response header value 1')
var header2Pos = indexOf(rawHeaders, 'test-response-header-2')
var header2Pos = rawHeaders.indexOf('test-response-header-2')
t.ok(header2Pos >= 0, 'raw response header 2 present')

@@ -51,3 +41,3 @@ t.equal(rawHeaders[header2Pos + 1], 'BAR2', 'raw response header value 2')

t.equal(body['test-request-header-2'], 'FOO2', 'request header 2')
t.equal(keys(body).length, 2, 'correct number of request headers')
t.equal(Object.keys(body).length, 2, 'correct number of request headers')
t.end()

@@ -54,0 +44,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc