Comments (3)
If you use the Curl wrapper (async):
var Curl = require( 'node-libcurl' ).Curl,
curl = new Curl(),
url = 'http://www.google.com',
isAddressAvailable = false,
statusCode;
curl.setOpt( Curl.option.URL, url );
curl.setOpt( Curl.option.CONNECTTIMEOUT, 5 ); // max of 5 seconds timeout to connect
curl.setOpt( Curl.option.FOLLOWLOCATION, true ); // follow redirects
curl.setOpt( Curl.option.NOBODY, true ); // just check the headers, ignore the response body
curl.on( 'end', function ( statusCode ) {
isAddressAvailable = ( statusCode === 200 );
this.close();
});
curl.on( 'error', function () {
this.close();
});
curl.perform();
If you use the Easy handler (sync):
var Easy = require( 'node-libcurl' ).Easy,
Curl = require( 'node-libcurl' ).Curl,
url = 'http://www.google.com',
isAddressAvailable = false;
ch = new Easy();
ch.setOpt( Curl.option.URL, url );
ch.setOpt( Curl.option.CONNECTTIMEOUT, 5 ); // max of 5 seconds timeout to connect
ch.setOpt( Curl.option.FOLLOWLOCATION, true ); // follow redirects
ch.setOpt( Curl.option.NOBODY, true ); // just check the headers, ignore the response body
ret = ch.perform();
statusCode = ch.getInfo( Curl.info.RESPONSE_CODE );
ch.close();
isSiteAvailable = ( statusCode === 200 );
from node-libcurl.
Allready done it, but thanks for your responce. Nice module.
from node-libcurl.
No problem.
from node-libcurl.
Related Issues (20)
- How can I write a custom request asynchronously? HOT 1
- [feat] rewrite `node-libcurl` with, the **ONLY** isomorphic way, napi HOT 1
- Curl Easy segmentation fault with requests to external site HOT 3
- Expected npx node-libcurl $URL to work as curl $URL HOT 1
- TypeError: Class extends value #<Object> is not a constructor or null HOT 1
- HTTP_CONTENT_DECODING = false but still decodes the server's responses HOT 1
- How to make multiple curly instances maintain separate connections to same host? HOT 2
- unable to npm install HOT 3
- npm install issues. HOT 5
- libcurl vuln HOT 2
- Add prebuilt binaries for nodejs 20 LTS HOT 13
- read raw msg HOT 3
- Does node-libcurl support res_init? HOT 1
- Error after upgrade to Node 20.10 ...: ERR_DLOPEN_FAILED HOT 2
- SFTP / SSH stuck on login when using Curl/Multi and password auth HOT 2
- Curly - Close connection - Timeout Exception HOT 3
- Cannot install HOT 3
- Send binary data with HTTPPOST option HOT 1
- Hanging on PROTOCONNECTING
- Add prebuilt binaries for node 21(macOS) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-libcurl.