Skip to content

Commit

Permalink
Add HTTPS.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro committed Feb 24, 2017
1 parent 573e506 commit fb1e271
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 10 additions & 3 deletions hitit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
hitit - v0.1.2
hitit - v0.2.0
Written by Federico Pereiro (fpereiro@gmail.com) and released into the public domain.
Expand All @@ -12,6 +12,7 @@ Please refer to readme.md to read the annotated source (but not yet!).

var fs = require ('fs');
var http = require ('http');
var https = require ('https');

var dale = require ('dale');
var teishi = require ('teishi');
Expand Down Expand Up @@ -39,14 +40,17 @@ Please refer to readme.md to read the annotated source (but not yet!).
['options.code', o.code, [undefined, 0, -1].concat (dale.do (http.STATUS_CODES, function (v, k) {return parseInt (k)})), teishi.test.equal, 'oneOf'],
['options.apres', o.apres, ['undefined', 'function'], 'oneOf'],
['options.apres', o.delay, ['undefined', 'integer'], 'oneOf'],
['options.https', o.https, ['undefined', 'boolean'], 'oneOf'],
['options.rejectUnauthorized', o.https, ['undefined', 'boolean'], 'oneOf'],
['state', state, 'object'],
]},
['cb', cb, 'function']
], function (error) {
cb ({
if (type (cb) === 'function') cb ({
code: -2,
error: error
});
else log (error);
})) return;

var resolve = function (w) {
Expand All @@ -70,9 +74,12 @@ Please refer to readme.md to read the annotated source (but not yet!).
method: resolve (o.method) || resolve (state.method),
headers: o.headers,
path: resolve (o.path),
rejectUnauthorized: ! o.rejectUnauthorized === false
};

var request = http.request (opt, function (response) {
var protocol = o.https ? https : http;

var request = protocol.request (opt, function (response) {
response.setEncoding ('utf8');
response.body = '';

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hitit",
"version": "0.1.2",
"version": "0.2.0",
"description": "Minimalistic tool for API testing.",
"dependencies": {
"dale": "4.1.0",
Expand Down
5 changes: 2 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ hitit is a minimalistic tool for testing an HTTP API.

## Current status of the project

The current version of hitit, v0.1.2, is considered to be *unstable* and *incomplete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are:
The current version of hitit, v0.2.0, is considered to be *unstable* and *incomplete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are:

- Support for `multipart` uploads and downloads.
- Support for concurrent testing (a.k.a stress testing).
- Basic profiling.
- HTTPS support.

## Installation

Expand All @@ -22,7 +21,7 @@ To install, type `npm i hitit`.

## Source code

The complete source code is contained in `hitit.js`. It is about 180 lines long.
The complete source code is contained in `hitit.js`. It is about 190 lines long.

Annotated source code will be forthcoming when the library stabilizes.

Expand Down

0 comments on commit fb1e271

Please sign in to comment.