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

httpreq

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpreq - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

14

examples.js
var httpreq = require('./httpreq');
fs = require('fs')

@@ -90,1 +91,14 @@ // get www.google.com

// download a binary file:
httpreq.get('https://ssl.gstatic.com/gb/images/k1_a31af7ac.png', {binary: true}, function (err, res){
if (err){
console.log(err);
}else{
fs.writeFile(__dirname + '/test.png', res.body, function (err) {
if(err)
console.log("error writing file");
});
}
});

22

httpreq.js
/*
Copyright (c) 2011 Sam Decrock <sam.decrock@gmail.com>
Copyright (c) 2013 Sam Decrock <sam.decrock@gmail.com>

@@ -53,3 +53,3 @@ MIT License

exports.doRequest = function(o, callback){
var responsebody = "";
var chunks = [];
var params;

@@ -100,9 +100,11 @@

function requestResponse(res){
res.setEncoding('utf8');
res.on('data', function (chunk) {
responsebody += chunk;
chunks.push(chunk);
});
res.on('end', function (err) {
var responsebody = Buffer.concat(chunks);
if(!o.binary)
responsebody = responsebody.toString('utf8');
callback(null, {headers: res.headers, body: responsebody});

@@ -136,3 +138,3 @@ });

exports.uploadFiles = function(o, callback){
var responsebody = "";
var chunks = [];

@@ -201,9 +203,11 @@ var reqUrl = url.parse(o.url);

function requestResponse(res){
res.setEncoding('utf8');
res.on('data', function (chunk) {
responsebody += chunk;
chunks.push(chunk);
});
res.on('end', function (err) {
var responsebody = Buffer.concat(chunks);
if(!o.binary)
responsebody = responsebody.toString('utf8');
callback(null, {headers: res.headers, body: responsebody});

@@ -210,0 +214,0 @@ });

{
"name": "httpreq",
"description": "node-httpreq is a node.js library to do HTTP(S) requests the easy way",
"version": "0.1.1",
"version": "0.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Sam Decrock",

@@ -31,2 +31,3 @@ node-httpreq

- cookies: an array of cookies
- binary: true/false (default: false), if true, res.body will a buffer containing the binary data
- callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ) and the body ( __res.body__ )

@@ -84,2 +85,3 @@

- cookies: an array of cookies
- binary: true/false (default: false), if true, res.body will a buffer containing the binary data
- callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ) and the body ( __res.body__ )

@@ -142,2 +144,3 @@

- cookies: an array of cookies
- binary: true/false (default: false), if true, res.body will a buffer containing the binary data
- callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ) and the body ( __res.body__ )

@@ -178,2 +181,3 @@

- cookies: an array of cookies
- binary: true/false (default: false), if true, res.body will a buffer containing the binary data
- callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ) and the body ( __res.body__ )

@@ -180,0 +184,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