# http-sync

> A synchronous HTTP Client library for node.js

Latest version **0.1.2** (published 2015-05-22) · BSD license · 0 weekly downloads

## Install

```sh
npm install http-sync
pnpm add http-sync
yarn add http-sync
bun add http-sync
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-05-22 |
| First published | 2013-07-06 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 76 |
| Author | Dhruv Matani |
| Maintainers | dhruvbird |

## Links

- npm: https://www.npmjs.com/package/http-sync
- Repository: https://github.com/dhruvbird/http-sync
- Homepage: https://github.com/dhruvbird/http-sync#readme
- Issues: https://github.com/dhruvbird/http-sync/issues
- npm.io page: https://npm.io/package/http-sync

## Dependencies (2)

- [nan](https://npm.io/package/nan.md) ~1.8.0
- [caseless](https://npm.io/package/caseless.md) ~0.9.0

## Recent versions

- 0.1.2 (latest) — 2015-05-22
- 0.1.1 — 2015-03-05
- 0.1.0 — 2015-01-20
- 0.0.5 — 2014-08-04
- 0.0.4 — 2013-10-30
- 0.0.3 — 2013-10-12
- 0.0.2 — 2013-10-02
- 0.0.1 — 2013-07-06

## README

# http-sync

http-sync is a compiled Node.js extension that provides syncronous http calls.

# Installing

You must have libcurl installed in order to compile this extension.

On Ubuntu, you can run: `sudo apt-get install libcurl4-openssl-dev`
On CentOS, you can run: `sudo yum install libcurl libcurl-devel`

# Using

```javascript
// example with default options
httpSync = require('http-sync');

var request = httpSync.request({
    method: 'GET',
    headers: {},
    body: '',

    protocol: 'http',
    host: '127.0.0.1',
    port: 80, //443 if protocol = https
    path: '/'
});

var timedout = false;
req.setTimeout(10, function() {
    console.log("Request Timedout!");
    timedout = true;
});
var response = request.end();

if (!timedout) {
    console.log(response);
    console.log(response.body.toString());
}
```

# SSL/TLS Options

If you require the use of a private CA or client certificate authentication, the following options are available:

* pfx - Path to certificate, private key and CA certificates to use
* ca - Path to an authority certificate
* cert - Path to the public x509 client certificate to use
* key - Path to the private key used for SSL
* passphrase - A string of passphrase for the private key or pfx, if required

```javascript
// example with a private CA and client cert authentication
httpSync = require('http-sync');

var request = httpSync.request({
    method: 'GET',
    headers: {},
    body: '',

    protocol: 'https',
    host: '127.0.0.1',
    port: 443, // protocol = https
    path: '/',
    ca: '/path/to/CA',
    cert: '/path/to/crt',
    key: '/path/to/key',
    rejectUnauthorized: true
});

var timedout = false;
req.setTimeout(10, function() {
    console.log("Request Timedout!");
    timedout = true;
});
var response = request.end();

if (!timedout) {
    console.log(response);
    console.log(response.body.toString());
}
```

# Contributing

## node >= v0.8.0

`node-gyp configure && node-gyp build`

## node < v0.8.0

You will need:

* node.js source code
* v8 source code
* libcurl development package

Building:

    node-waf configure && node-waf build

## testing

Run the test.js file:

    node test.js

---
_Source: https://npm.io/package/http-sync · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
