# xmlhttprequest-cookie

> Cookie-aware XMLHttpRequest Wrapper

Latest version **0.9.9** (published 2019-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install xmlhttprequest-cookie
pnpm add xmlhttprequest-cookie
yarn add xmlhttprequest-cookie
bun add xmlhttprequest-cookie
```

## 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.9.9 |
| Published | 2019-06-16 |
| First published | 2013-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Dr. Ralf S. Engelschall |
| Maintainers | rse |
| Keywords | xmlhttprequest, ajax, http, cookie |

## Links

- npm: https://www.npmjs.com/package/xmlhttprequest-cookie
- Repository: https://github.com/rse/node-xmlhttprequest-cookie
- Homepage: http://github.com/rse/node-xmlhttprequest-cookie
- Issues: http://github.com/rse/node-xmlhttprequest-cookie/issues
- npm.io page: https://npm.io/package/xmlhttprequest-cookie

## Dependencies (1)

- [xmlhttprequest](https://npm.io/package/xmlhttprequest.md) >=1.8.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.9.9 (latest) — 2019-06-16
- 0.9.8 — 2018-12-25
- 0.9.7 — 2018-06-23
- 0.9.6 — 2018-03-26
- 0.9.5 — 2017-12-03
- 0.9.4 — 2015-12-25
- 0.9.3 — 2015-12-25
- 0.9.2 — 2014-10-07
- 0.9.1 — 2013-12-14
- 0.9.0 — 2013-12-14

## README

Node XMLHttpRequest-Cookie
==========================

<p/>
<img src="https://nodei.co/npm/xmlhttprequest-cookie.png?downloads=true&stars=true" alt=""/>

<p/>
<img src="https://david-dm.org/rse/node-xmlhttprequest-cookie.png" alt=""/>

Abstract
--------

This is a [Node.js](http://nodejs.org/) extension module for wrapping
the [Node-XMLHttpRequest](https://github.com/driverdan/node-XMLHttpRequest)
module to allow it to handle HTTP Cookies, similar to what a browser
automatically does.

Installation
------------

Use the Node Package Manager (NPM) to install this module
locally (default) or globally (with option `-g`):

    $ npm install [-g] xmlhttprequest-cookie

API
---

The API is fully compatible to the API provided by the underlying
[Node-XMLHttpRequest Extension Module](https://github.com/driverdan/node-XMLHttpRequest),
module (which in turn is compatible to the API defined by the
[W3C XMLHttpRequest API Specification](http://www.w3.org/TR/XMLHttpRequest/).
In addition, the exposed `XMLHttpRequest` object also has a 
`debug` flag for controlling debug messages and there is a `CookieJar` object exposed by the module which
grants access to the cookie jar:

    var fs = require("fs");
    var xhrc = require("./xmlhttprequest-cookie");
    var XMLHttpRequest = xhrc.XMLHttpRequest;
    var CookieJar = xhrc.CookieJar;

    if (fs.existsSync("./sample.db"))
        CookieJar.load(fs.readFileSync("./sample.db", { encoding: "utf8" }));

    var get = function (url, complete) {
        var xhr = new XMLHttpRequest();
        xhr.debug = true;
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                console.log("body length: " + this.responseText.length);
                complete(xhr);
            }
        };
        xhr.open("GET", "https://github.com/rse/");
        xhr.send();
    };

    get("https://github.com/rse/", function (xhr) {
        console.log("body: " + xhr.responseText.substr(0, 100));
        get("https://github.com/rse/", function (xhr) {
            console.log("body: " + xhr.responseText.substr(0, 100));
            fs.writeFileSync("./sample.db", CookieJar.save(), { encoding: "utf8" });
        });
    });

See Also
--------

- [Node-XMLHttpRequest Extension Module](https://github.com/driverdan/node-XMLHttpRequest)
- [XMLHttpRequest Wikipedia Information](http://en.wikipedia.org/wiki/XMLHttpRequest)
- [XMLHttpRequest API Specification](http://www.w3.org/TR/XMLHttpRequest/)

License
-------

Copyright (c) 2013-2019 Dr. Ralf S. Engelschall (http://engelschall.com/)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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