<commit_before># httpinvoke

HTTP client for JavaScript.

* Sends requests and receives responses.
* Lets you monitor upload and download progress, if supported by platform.
* Works on [web browser](http://en.wikipedia.org/wiki/Internet_Explorer_5) and [Node.js](http://nodejs.org) platforms.
* Detects the presence of [CommonJS](http://www.commonjs.org/) and [AMD](https://www.google.com/search?q=advanced+module+definition) script loaders.
* Available on [npm](https://npmjs.org/package/httpinvoke) and [GitHub](https://github.com/jakutis/httpinvoke).
* Supports [npm](https://npmjs.org/), [Bower](http://bower.io/) and [Component](http://component.io/) package managers.
* Tested on:
  * Opera 9.50.0 (Windows XP) and later
  * Firefox 3.0.0 (Windows XP) and later
  * IE 7.0.0 (Windows XP) and later
  * Mobile Safari 6.0.0 (iOS 6.1.3)
  * Android 2.3.7 (Android 2.3.7)
  * Chrome 1.0.154 (Windows XP)
  * Safari 4.0.3 (Windows XP)
  * Safari 5.0.4 (Windows XP)
  * Safari 5.1.7 (Windows XP)

# Usage

## Loading

Load using your package manager, or use directly in web browser by adding `<script src="/path_to_http_invoke/httpinvoke-browser.js"></script>` to your HTML file.

## Example

    httpinvoke('http://updates.html5rocks.com', 'POST', {
        input: JSON.stringify({foo:'bar'});
        headers: {
            'Content-Type': 'application/json'
        },
        uploading: function(min, current, max) {
            console.log('Uploading', arguments);
        },
        gotStatus: function(status, headers) {
            console.log('Got status', status, headers);
        },
        downloading: function(min, current, max) {
            console.log('Downloading', arguments);
        },
        finished: function(err, output) {
            if(err) {
                return console.log('Failure', err);
            }
            console.log('Success', output);
        }
    });

# API reference

    var abort = httpinvoke(url, [method="GET", [options={}]])

* **url** is a string for URL, e.g. `"http://example.org/"`.
* **method** is a string for HTTP method, e.g. `"GET"`, `"POST"`, etc.
* **options** is an object for various options (see the Options section below).
* **abort** is a function for aborting the HTTP request. It immediately calls the "finished" callback with an Error. If "finished" callback is already called before the "abort", nothing happens.<commit_msg>readme.markdown: update Example section for changed API<commit_after># httpinvoke

HTTP client for JavaScript.

* Sends requests and receives responses.
* Lets you monitor upload and download progress, if supported by platform.
* Works on [web browser](http://en.wikipedia.org/wiki/Internet_Explorer_5) and [Node.js](http://nodejs.org) platforms.
* Detects the presence of [CommonJS](http://www.commonjs.org/) and [AMD](https://www.google.com/search?q=advanced+module+definition) script loaders.
* Available on [npm](https://npmjs.org/package/httpinvoke) and [GitHub](https://github.com/jakutis/httpinvoke).
* Supports [npm](https://npmjs.org/), [Bower](http://bower.io/) and [Component](http://component.io/) package managers.
* Tested on:
  * Opera 9.50.0 (Windows XP) and later
  * Firefox 3.0.0 (Windows XP) and later
  * IE 7.0.0 (Windows XP) and later
  * Mobile Safari 6.0.0 (iOS 6.1.3)
  * Android 2.3.7 (Android 2.3.7)
  * Chrome 1.0.154 (Windows XP)
  * Safari 4.0.3 (Windows XP)
  * Safari 5.0.4 (Windows XP)
  * Safari 5.1.7 (Windows XP)

# Usage

## Loading

Load using your package manager, or use directly in web browser by adding `<script src="/path_to_http_invoke/httpinvoke-browser.js"></script>` to your HTML file.

## Example

    httpinvoke('http://updates.html5rocks.com', 'POST', {
        input: JSON.stringify({foo:'bar'});
        headers: {
            'Content-Type': 'application/json'
        },
        uploading: function(current, total) {
            console.log('Uploaded ', current, ' bytes of ', total, ' total');
        },
        gotStatus: function(status, headers) {
            console.log('Got status', status, headers);
        },
        downloading: function(current, total) {
            console.log('Downloaded ', current, ' bytes of ', total, ' total');
        },
        finished: function(err, output) {
            if(err) {
                return console.log('Failure', err);
            }
            console.log('Success', output);
        }
    });

# API reference

    var abort = httpinvoke(url, [method="GET", [options={}]])

* **url** is a string for URL, e.g. `"http://example.org/"`.
* **method** is a string for HTTP method, e.g. `"GET"`, `"POST"`, etc.
* **options** is an object for various options (see the Options section below).
* **abort** is a function for aborting the HTTP request. It immediately calls the "finished" callback with an Error. If "finished" callback is already called before the "abort", nothing happens.
{'fraction_non_alphanumeric': 0.151676206050695, 'fraction_numerical': 0.01553556827473426, 'mean_word_length': 3.0843071786310516, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5747710', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1473, 'n_words': 449}