Git Product home page Git Product logo

curl-request's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

curl-request's Issues

Interface not working

I try to use interface option but it doesnt work. No error but gives me other interface's ip

var curl = new (require( 'curl-request' ))();

curl
.setOpt('interface', 'eth0')
.setHeaders([
    'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
])
.get('www.wtfismyip.com/json')
.then(({statusCode, body, headers}) => {
    console.log(statusCode,body)
})
.catch((e) => {
    console.log(e);
});

It works on command tool with curl. I get the right ip with that command;

sudo curl -s http://www.wtfismyip.com/text --interface eth0

Error: Unknown option given. First argument must be the option internal id or the option name. You can use the Curl.option constants.

-------------------------------------------------detail error -----------------------------------
Error: Unknown option given. First argument must be the option internal id or the option name. You can use the Curl.option constants.
at Error (native)
at Curl.setOpt (/home/js2/Version2/node_modules/node-libcurl/lib/Curl.js:1004:15)
at module.exports.setOpt (/home/js2/Version2/node_modules/curl-request/index.js:39:19)
at /home/js2/Version2/routes/routes.js:3262:22
at /home/js2/Version2/node_modules/mongoose/lib/query.js:2323:18
at process._tickCallback (internal/process/next_tick.js:103:7)

how to pass setOpt `option?

`const curl = require('curl-request');
var param = {
'device_id': 2325, // Device ID
'module_id': 'dm_bandwidth', // Module ID or name
'period': 'week'
};
var opt = [];
opt = [{'httpheader': 'Content-type: application/json'},{'userpwd':'password'},
{'Curl.option.useragent': 'Ubersmith API Client PHP/1.0'}];
var url = 'https://support.privatelayer.com/api/2.0/?method=device.module_graph';
curl.setHeaders([
'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'Accept-Encoding: gzip',
'Expect:',
])
curl.setOpt(opt)
.setBody(param)
.get(url)
.then(({ statusCode, body, headers }) => {
console.log("curl", statusCode, "body", body, "header", headers)

                    res.json({ success: true, deviceDetail: getDeviceDetail[0], devicegraph: body });
                })
                .catch((e) => {
                    console.log(e);
                });`

curl -F "[email protected]"

I like to do this:

curl -F "[email protected]" https://file.io

With this code:

curl.default.verbose = true;
curl
.setHeaders([
    'Content-Type: multipart/form-data'
])
.setMultipartBody([{
    name: 'filename',
    contents: zip_fullpath
}, {
    name: 'file',
    file: zip_fullpath,
    type: 'zip'
}])
.get('https://file.io')
.then(({statusCode, body, headers}) => {
    console.log(statusCode, body, headers)
})
.catch((e) => {
    console.log('Error: ' + JSON.stringify(e) );
    console.log(e);
});

All I get is this error:

* Rebuilt URL to: https://file.io/
document sent to file.io
*   Trying 18.205.172.118...
* TCP_NODELAY set
* Connected to file.io (18.205.172.118) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 0
Error: {}
{}

How can i set proxy with password?

Hello @do-web
How can i send request with proxy that needs authentication?

curl.default.proxy = 'user:password@ip_addr:portno';
OR
curl.default.proxy = 'ip_addr:portno:portno@user:password';
OR
any other thing

Can anyone please guide?

Thanks,
Apoorva Shah

Error: Handle already running! at Error (native) at Curl.perform

i have error in google cloud function.
Error: Handle already running! at Error (native) at Curl.perform (/user_code/node_modules/curl-request/node_modules/node-libcurl/lib/Curl.js:1051:11) at e (/user_code/node_modules/curl-request/index.js:169:27) at _submit (/user_code/node_modules/curl-request/index.js:141:16) at post (/user_code/node_modules/curl-request/index.js:93:21) at /user_code/index.js:112:9 at f (/user_code/node_modules/@google-cloud/storage/node_modules/once/once.js:25:25) at ConcatStream. (/user_code/node_modules/@google-cloud/storage/node_modules/concat-stream/index.js:37:43) at emitNone (events.js:91:20) at ConcatStream.emit (events.js:185:7)

my code is
/**

  • Triggered from a change to a Cloud Storage bucket.
  • @param {!Object} event Event payload and metadata.
  • @param {!Function} callback Callback function to signal completion.
    */
    const storage = require("@google-cloud/storage")();
    const curl = new(require('curl-request'))();

exports.getEmail = (event, callback) => {
const file = event.data;
const eventAge = Date.now() - Date.parse(event.timestamp);
const eventMaxAge = 10000;

// Ignore events that are too old
if (eventAge > eventMaxAge) {
console.log(Dropping event ${event} with age ${eventAge} ms.);
callback();
return;
}

//console.log( Event: ${event.eventId});
//console.log( Event Type: ${event.eventType});
//console.log( Bucket: ${file.bucket});
// console.log( File: ${file.name});
//console.log( Metageneration: ${file.metageneration});
//console.log( Created: ${file.timeCreated});
//console.log( Updated: ${file.updated});

if (file.name.match('registerfolder/')) {
storage.
bucket(file.bucket).
file(file.name).
download(function(err, contents) {
var obj = JSON.parse(contents.toString());

  curl
   .setBody({
    'from' : obj.from,
    'fromName': obj.sender,
    'apikey': process.env.API_KEY,
    'subject': obj.subject,
    'to': obj.to,
    'bodyHtml': obj.text,
    'isTransactional': true
   })
   .post(process.env.API_URL + 'email/send')
   .then(({
    statusCode,
    body,
    headers
   }) => {
    console.log(statusCode, body, headers)
   })
   .catch((e) => {
    console.log(e);
   });

 });

}
callback();
};

Error: Cannot find module 'node-pre-gyp'

Got error while running npm install curl-request --save

node-libcurl ERR! Error: Command failed: node "/Users/dev/Documents/project/node_modules/curl-request/node_modules/node-libcurl/lib/Curl.js"
module.js:471
    throw err;
    ^

Error: Cannot find module 'node-pre-gyp'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/dev/Documents/project/node_modules/curl-request/node_modules/node-libcurl/lib/Curl.js:25:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Error: libcurl-gnutls.so.4: cannot open shared object file: No such file or directory

Please help why it happend ?

OS : Centos
NPM : 6.2.0
node : 6.11.3

node-libcurl WARN Could not finish postinstall
node-libcurl ERR! Error: Command failed: node "/home/apps/ardha/project/node_modules/node-libcurl/lib/Curl.js"
module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: libcurl-gnutls.so.4: cannot open shared object file: No such file or directory
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/apps/ardha/project/node_modules/node-libcurl/lib/Curl.js:28:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.