Giter VIP home page Giter VIP logo

node-xmlhttprequest's Introduction

node-XMLHttpRequest

node-XMLHttpRequest is a wrapper for the built-in http client to emulate the browser XMLHttpRequest object.

This can be used with JS designed for browsers to improve reuse of code and allow the use of existing libraries.

Note: This library currently conforms to XMLHttpRequest 1. Version 2.0 will target XMLHttpRequest Level 2.

Usage

Here's how to include the module in your project and use as the browser-based XHR object.

var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();

Note: use the lowercase string "xmlhttprequest" in your require(). On case-sensitive systems (eg Linux) using uppercase letters won't work.

Versions

Prior to 1.4.0 version numbers were arbitrary. From 1.4.0 on they conform to the standard major.minor.bugfix. 1.x shouldn't necessarily be considered stable just because it's above 0.x.

Since the XMLHttpRequest API is stable this library's API is stable as well. Major version numbers indicate significant core code changes. Minor versions indicate minor core code changes or better conformity to the W3C spec.

License

MIT license. See LICENSE for full details.

Supports

  • Async and synchronous requests
  • GET, POST, PUT, and DELETE requests
  • All spec methods (open, send, abort, getRequestHeader, getAllRequestHeaders, event methods)
  • Requests to all domains

Known Issues / Missing Features

For a list of open issues or to report your own visit the github issues page.

  • Local file access may have unexpected results for non-UTF8 files
  • Synchronous requests don't set headers properly
  • Synchronous requests freeze node while waiting for response (But that's what you want, right? Stick with async!).
  • Some events are missing, such as abort
  • Cookies aren't persisted between requests
  • Missing XML support

node-xmlhttprequest's People

Contributors

a2800276 avatar arthurblake avatar awinterman avatar brentlintner avatar chawco avatar driverdan avatar fjakobs avatar gordonsmith avatar haykokoryun avatar jacwright avatar jbpros avatar josephg avatar keverw avatar krisnye avatar kumavis avatar lfdoherty avatar maraujop avatar markandrus avatar matthewwithanm avatar max99x avatar mhansen avatar mixu avatar mrose17 avatar nishidayuya avatar ohar avatar pdehaan avatar pupeno avatar sebmaster avatar tomaash avatar tomhughes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-xmlhttprequest's Issues

Push to NPM

Could you push this latest version to npm?
Currently npm only has version 1.3.0.

Thanks

responseXML implementation using jsdom (htmlparser)

Hello,

Is is possible to include my implementation of responseXML into your
mainstream git ?

Related to
#8
#13

I implemented responseXML in my fork of node-XMLHttpRequest
using "jsdom" (using "htmlparser"). The benefit is that you can parse
non XML url like any HTML website and get a DOM.

I implemented it within an exception handler so node-XMLHttpRequest
should continue to work even if jsdom has not been installed. Of
course without those modules responseXML cannot be used but
responseText will continue to work.

The implementation :
https://github.com/lordbaco/node-XMLHttpRequest/commit/1303a2596ad7fad504a1e1d4c696ee76b78c6d9a

I am not sure my implementation will work with sync but async is working.

To use this feature you need to :
npm install jsdom
git clone https://[email protected]/lordbaco/node-XMLHttpRequest.git
then use it in your code

var sys = require('util');
var XMLHttpRequest = require("./node-XMLHttpRequest/XMLHttpRequest").XMLHttpRequest;
var url = 'https://github.com';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
var document = this.responseXML;
//sys.puts("XML:\n" + sys.inspect(document.innerHTML, false, null));
var nodes = document.body.getElementsByTagName('*');
for (var i=0; i<nodes.length; i++) {
// ...
sys.print(nodes[i].nodeName.toLowerCase() + "\n");
}
}
};
xhr.open("GET", url);
xhr.send();

Best Regards,
Guy (Lordbaco)

Add a browser specific entry point to work with browserify/webpack.

When having code that is shared with the browser, it would be great if we could have a browser specific entry point that just returned the window.XMLHttpRequest object.

Both browserify and webpack can read a "browser" field on the module's package.json that defines a new entry point to use when bundling, as described on this spec.

Otherwise, it's necessary to explicitly avoid bundling the module and add some conditional logic to use the browser's XMLHttpRequest instead.

I can create a pull request to add this improvement.

Regression 1.3.0 -> 1.4.0: "SYNTAX_ERR: This header is not allowed" on blocking request

Hi Dan,

It's been a long time, so you probably don't remember me. (I contributed the original blocking code.)

There's unfortunately been a regression in version 1.4.0 that didn't exist in 1.3.0 when I try to do a blocking request. (On the bright side, it's forced me to finally open source my JSON-RPC client and server code.)

My JSON-RPC client is setting only two HTTP headers: Content-Length and Content-Type. I can't believe that Content-Type is what's being banned, so I assume setting Content-Length is no longer allowed?

Is 1.4.0 setting this value, now? Even if so, I think it'd be nicer if the API was closer to the browser and just silently dropped on setting this header and then set it itself (so the same code can work on browsers that do this, and browsers that don't set that header at all and therefore cause problems for servers that expect to see it, and why I added that line in in the first place).

I haven't looked into what's different between 1.3.0 and 1.4.0, just giving you a heads up. I can re-fork and fix if you'd like.

David

Origin Header is missing

Hello,

I'm not sure why Origin is forbidden. But I don't see it's being set anywhere. I'm consuming a RPC service that requires an Origin to be present. So, I've simply added it to the default headers with a default value of null.

This works for me. Yet, I wanted confirm how this would affect others.

Remove 'User-Agent' from request header black list.

Forbid the user-agent header to be specified don't makes sense at server-side, setting the user-agent is needed for a lot of different use cases. W3 are forbidding the user-agent header due to protecting the brower's own implementation of such, however such restriction is not need at server-side.

XMLHttprequest imposes a hard limit on the maximum number of connections per host Edit

There is a hard cap on the connections per host in node-XmlHttpRequest, of 5 connections per host. The cap exists because of http://nodejs.org/api/http.html#http_http_request_options_callback where the default agents agent.maxSockets is 5.

This also affects engine.io-client when running in Node.

The fix is simple: https://github.com/driverdan/node-XMLHttpRequest/blob/master/lib/XMLHttpRequest.js#L358

add { agent: false } to disable the connection limit per host.

send call hangs indefinitely

I want to make a post request to a Tomcat server with some data. If the data has more than 100kb the send call hangs indefinitely, and the server doesn't receive the request. Otherwise it works fine. As far as I know, I made the configurations on the server to receive posts of up to 20 MB, explicitly the maxPostSize configuration. Did any of you encounter such problem?

Accept gzipped/deflated content

To reduce request size, it would be nice to 'Accept-Encoding': 'gzip,deflate' added. Obviously this means we would have to decode the response, too.

Custom agent

Since agent: false I've lost the ability to track the net sockets that correspond with each request. This is hugely important for testing what happens to polling requests when the underlying sockets close in engine.io/socket.io when running the clients from Node.

A couple things would help me:

  • As I suggested before, the ability to generate a custom XMLHttpRequest:

    var XMLHTTPRequest = require('xmlhttprequest')({ agent: myCustomAgent });
  • The ability to access the Node request object. This requires adding some private property to the XMLHttpRequest instances.

UNSENT, OPEN, HEADERS_RECEIVED, LOADING and DONE must be const

Hi, as described in the XMLHttpRequest 1 and XMLHttpRequest 2 specifications the INSENT, OPEN, HEADERS_RECEIVED, LOADING and DONE constants MUST BE const.

This implies we should be able to access those constants directly using :

XMLHttpRequest.UNSENT;
XMLHttpRequest.OPEN;
XMLHttpRequest.HEADERS_RECEIVED;
XMLHttpRequest.LOADING;
XMLHttpRequest.DONE;

But I think those constants are not really defined as constants because they are member of the XMLHttpRequest constuctor, so they are instance properties.

This is problematic because we often check the readyState attribute in our onreadystatechange callbacks using this peace of code :

onreadystatechange = function() {
    if(this.readyState === XMLHttpRequest.DONE) {
        // Do something     
    }
};

Also in all browsers (Firefox, Chrome, Opera, IE) accessign those constants directly is implemented so it should also work in node-XMLHttpRequest.

Need to define withCredentials

XHR objects are expected to have xhr.withCredentials == false. This is important for feature detection (primarily in code that distinguishes between IE's partial XHR implementations and modern, spec-compliant, implementations.

responseXML of fetched SVG file is ''

I am loading local SVG file, but response.responseXML is an empty string instead of an XML document. Also, r.getResponseHeader('Content-Type') (where r is a reference to request) seems to error out:

/Users/kangax/dev/node-canvas/node_modules/XMLHttpRequest/XMLHttpRequest.js:107
        if (this.readyState > this.OPENED && response.headers[header]) {
                                           ^
TypeError: Cannot read property 'headers' of undefined
    at [object Object].getResponseHeader (/Users/kangax/dev/node-canvas/node_modules/XMLHttpRequest/XMLHttpRequest.js:107:48)

global and local variables conflict

What is the correct way of passing variable values in an on 'data' method response ?

I haven't been able of replacing the value of globally defined variables with a response from the server.

thank you very much,

Diego

can I send an ArrayBuffer?

I don't have much experience with javascript. I want to make a POST using XMLHttpRequest. Can I send an ArrayBuffer or is there a similar way to send a buffer? I get an error that says the argument for "send" method must be a string.

test failures

$ node tests/test-headers.js
node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot read property 'headers' of undefined
    at [object Object].getAllResponseHeaders (/tp/node/node-XMLHttpRequest/XMLHttpRequest.js:125:25)
    at [object Object].onreadystatechange (/tp/node/node-XMLHttpRequest/tests/test-headers.js:27:30)
    at /tp/node/node-XMLHttpRequest/XMLHttpRequest.js:307:9
    at [object Object].handleError (/tp/node/node-XMLHttpRequest/XMLHttpRequest.js:286:3)
    at [object Object].send (/tp/node/node-XMLHttpRequest/XMLHttpRequest.js:272:10)
    at Object.<anonymous> (/tp/node/node-XMLHttpRequest/tests/test-headers.js:35:5)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)

$ node tests/test-request.js 
Testing GET

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
AssertionError: "undefined" == "Hello World"
    at [object Object].onreadystatechange (/tp/node/node-XMLHttpRequest/tests/test-request.js:43:12)
    at /tp/node/node-XMLHttpRequest/XMLHttpRequest.js:307:9
    at [object Object].handleError (/tp/node/node-XMLHttpRequest/XMLHttpRequest.js:286:3)
    at [object Object].send (/tp/node/node-XMLHttpRequest/XMLHttpRequest.js:272:10)
    at start (/tp/node/node-XMLHttpRequest/tests/test-request.js:56:6)
    at Object.<anonymous> (/tp/node/node-XMLHttpRequest/tests/test-request.js:61:2)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)

HTTPS requests fail for self-signed server certificates

Because of this issue in Node which changed rejectUnauthorized from default false to true (see nodejs/node-v0.x-archive#3949), the TLS negotiation fails for self-signed certificates. This is very important when testing and before any CA signed certificates are installed in production. Currently there is no way to pass HTTP/HTTPS options into this module. Please consider enhancing the agent issue (see #44) with a more generic option object (similar to the one used by HTTP/HTTPS requests) which also contains a custom Agent. This way users can set the "rejectUnauthorized" to false.

See examples for options format in http://nodejs.org/api/https.html.

I would however suggest passing the options in the Request function rather than constructor to be more in line with HTTP/HTTPS paradigm.

Parsing response text with "\n" in it

Hello, I tried to use XMLHttpRequest.js but I wasn't getting back the expected status code for my request, and it turned out it was failing at line 448:

self.status = self.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/, "$1");

The responseText contained an end-of-line marker (\n or \r\n I didn't check) right after "200," so "$1" wasn't capturing just "200" but the whole text.

When I changed .* to [\s\S]* it seemed to work fine:

self.status = self.responseText.replace(/NODE-XMLHTTPREQUEST-STATUS:([0-9]*),[\s\S]*/, "$1");

I'm not familiar with your library code or the HTTP spec itself so I'm not sure if this is the right place right fix but please take a look to this matter. Thanks.

Content-Length error with accentuation

Hello,

you got an error in your library, when you set the "Content-Length" header. This header should be the number of bytes of the body, but when you call "data.length" on line 184, and data is an utf8 string, data.length return the number of characters and not the number of bytes.

A simple example :

var test = "précédé d'un à";
console.log(test.length);
// output : 14
var b = new Buffer(test);
console.log(b.length);
// output : 22

Regaards,

Mickael

Error: listen EADDRINUSE

If I try to use XMLHttpRequest, after I created a server on port 80, then I get this error: Error: listen EADDRINUSE

Question

I'm Building an SDK for the BOX API, But I'd like to be able to use it both for node and for a browser plugin, my question is if I use your library, would I be able to switch to the browser based version with out any or very little in the way of code changes?

It's just I'm using 'request' for node but you can't use that in a browser so I'm wanting to switch to something that will work in both browsers and on node, if your library emulates the browser library, then I'm guessing it follows the same interface as well. would I have much trouble switching between the two? (browser version, your version for node)

setRequestHeader case sensitive modification

It's not really a bug, but I would suggest (and as far as I understand specs do suggest it too) to make a small modification in setRequestHeader function to match a bad formated header (case sensitive mistake for example) to a good one.

Example : receiving content-Type, setRequestHeader should understand and set Content-Type

when socket hang up, the XMLHttpRequest.js would throw < Cannot read property 'headers' of undefined>

Error: socket hang up
at CleartextStream. (http.js:1286:45)
at CleartextStream.emit (events.js:61:17)
at Array.1 (tls.js:617:22)
at EventEmitter._tickCallback (node.js:126:26)

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'headers' of undefined

the reason due to:
the response variable has not been initialized correctly and the Line 123 try to access it.

the fix could be:

/**
 * Gets all the response headers.
 *
 * @return string 
 */
this.getAllResponseHeaders = function() {
    if (this.readyState < this.HEADERS_RECEIVED) {
        throw "INVALID_STATE_ERR: Headers have not been received.";
    }
    var result = "";

// FIX: check whether the response is null
if (response) {
  for (var i in response.headers) {
    result += i + ": " + response.headers[i] + "\r\n";
  }
}
    return result.substr(0, result.length - 2);
};

Exceptions test

Due to the fact that console.warn is used for unacceptable headers (instead of throwing an exception), the test-exceptions.js fails in a number of places. Not sure how you wanted to resolve or I'd submit a PR.

user-agent also gives an error because it is currently allowed in code..

responseXML not being set?

Hello,

I am trying to use node-XMLHttpRequest to make AJAX calls from JavaScript code running in node.js. The JavaScript code calls a simple PHP-based server app, which returns some XML (see below). The code works fine when running in a browser, but it does not work properly when runing in node.js using node-XMLHttpRequest. The call to the server completes, but there does not seem to be any data in responseXML. Instead, node.js gives me the error:

        var timeValue = http.responseXML.getElementsByTagName("timenow")[0
                                         ^

TypeError: Object has no method 'getElementsByTagName'

The complete text returned by the server is contained in http.responseText. When/how can that text be parsed into XML so that I can grab the "timenow" field? Looking at the code for node-XMLHttpRequest, it looks like only the responseText variable is filled (on line 212) when a "data" response is received. I see almost no references to the responseXML variable.

Is there some other code required for filling/scanning the responseXML variable, which still has to be implemented in node-XMLHttpRequest? Or am I not calling the function properly to receive data in XML format?

The code is below. Thanks for any tips or pointers.

--IO


CLIENT CODE (JS):

var http = new XMLHttpRequest();

function getServerTime() {
var myurl = 'http://kundry/qrate.php';
myRand = parseInt(Math.random() * 999999999999999);
var modurl = myurl+"?rand="+myRand;
http.open("get", modurl, true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}

function useHttpResponse() {
if (http.readyState == 4) {
if (http.status == 200) {
var timeValue = http.responseXML.getElementsByTagName("timenow")[0];
console.log("timenow="+timeValue.childNodes[0].nodeValue);
}
}
}

Sync requests via jQuery fail

I tried making a sync request via jQuery through node-XMLHttpRequest. It threw a not-all-that-obvious error. I traced through the code, and found it was due to jQuery calling xhr.getAllResponseHeaders(). It appears that for the sync case node-xhr doesn't support getAllResponseHeaders. Specifically the current impl goes to the response object to get the headers, but the response object is defined because in the sync case there isn't one.

Synchronous requests: xhr.status corrupted with responseText

OS version: OS X 10.8.4
Node.js version: v.0.10.5 and v.0.10.17
XHR Module version: 1.5.0

When using XHR to do a synchronous request, the status field gets corrupted with the full responseText body.

xhr.open('GET', url, false);
xhr.send();

console.log("startsWith(xhr.status, 200)? " + startsWith(xhr.status, 200));
console.log("xhr.status == 200? " + (xhr.status ==  200));
console.log("Value of status: " + xhr.status);

Output:

startsWith(xhr.status, 200)? true
xhr.status == 200? false
Value of status: 200 "id": "index", "version": "1.0", [more JSON follows]

It would appear that the regex that does the text replacement in lines 463 and 464 of lib/XMLHttpRequest.js is broken.

support binary data via overrideMimeType() (or other means of not assuming the returned data is utf8)

https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers documents using:

req.overrideMimeType('text/plain; charset=x-user-defined');

as a way to force web browsers to not treat the returned data as utf-8. This is useful if you are doing something like trying to fetch an image in web browsers and also would like that same code to work in node.

Currently, this library forces the data stream to be interpreted as utf-8 which is potentially lossy, and definitely lossy in the case of png images. Specifically, the first byte 0x89 when round-tripped through utf-8 gets converted into the replacement character 0xffd and comes back (utf-8 encoded) as 0xef 0xbf 0xbd.

XHR calls stop somewhere around the 50 calls

Hi there,

I'm using you awesome XHR module to do a lot of ajax calls. I do this async using deferred. This works really well until the amount of requests passes somewhere around the 40 to 50 calls. Then it simply stops and does nothing indefinably.

My code is as followed:

    function getFile(url) {
        var def = deferred()
        ,xhr = new XMLHttpRequest(); 

        xhr.open("GET", url); 
        xhr.onreadystatechange = handler;
        //Callback
        function handler (){
            // If status is ready
            if (this.readyState == 4 && this.status >= 200 && this.status < 300 || this.status === 304) {
                try {
                    var result = eval(this.responseText);
                } catch (e) {
                    def.resolve(e);
                }
                def.resolve(result && result[0]);
            } else if (this.status === 401){
                console.log('Error 401')
                def.resolve(new Error('Error:' + this.responseText));
            };
        };
        xhr.send(null);
        return def.promise;
    };

If I console.log the status I keep getting a nice status 200.
Do you have any idea what I'm doing wrong?

Thanks a lot!

Please check the full code at:
https://github.com/jansmolders86/mediacenterjs/blob/master/apps/movies/index.js

event in onreadystatechange callback is undefined

This simple example

XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
xhr = new XMLHttpRequest();
xhr.open('GET', 'https://github.com');
xhr.onreadystatechange = function (event) {
  console.log(event);
};
xhr.send();

outputs

undefined
undefined
...
undefined

I tried this with both https and http urls. I am using node v0.12.7.

option to disable isAllowedHttpHeader check

Could we have a option to set a option that disables the isAllowedHttpHeader check? I know some people might want it, but some people may want to override it. For now I just commented out some of the code in my project(https://github.com/keverw/HTTPRequest) I was thinking about trying to add it myself. Also if persisted cookies are ever added, it would be nice to disable them. Other than that, this is a really great project! It lets me write code I can use on both the client/server, without them being so different!

Cannot read property 'headers' of undefined in XMLHttpRequest.js

I am trying to get the response headers from an httprequest, and no matter which function I use (getResponseHeader or getAllResponseHeaders), I get the error:
"TypeError: Cannot read property 'headers' of undefined' coming from /xmlhttprequest/lib/XMLHttpRequest.js

The code that I am executing is provided below.
--------------------------------------[Begin Code]--------------------------------------
var httpSessionID = new XMLHttpRequest();
httpSessionID.onreadystatechange = function() {
if (this.readyState == 4) {
console.log("Body:\n" + this.responseText);
}
};
httpSessionID.open("GET", "http://www.google.com/", false);
httpSessionID.send();
var something = JSON.parse(httpSessionID.getAllResponseHeaders());
(or)
var something = httpSessionID.getResponseHeader('set-cookie');
--------------------------------------[End Code]--------------------------------------

The complete error I get for when I call the second one (getResponseHeader) is:
--------------------------------------[Begin Error]--------------------------------------
.../node_modules/xmlhttprequest/lib/XMLHttpRequest.js:210
&& response.headers[header.toLowerCase()]
----------------^
TypeError: Cannot read property 'headers' of undefined
at exports.XMLHttpRequest.getResponseHeader (.../node_modules/xmlhttprequest/lib/XMLHttpRequest.js:210:18)
at .../node_modules/webrtc.io/lib/webrtc.io.js:358:35
at Object.rtc.fire (.../node_modules/webrtc.io/lib/webrtc.io.js:62:15)
at WebSocket. (.../node_modules/webrtc.io/lib/webrtc.io.js:91:11)
at WebSocket.EventEmitter.emit (events.js:96:17)
at Receiver.self._receiver.ontext (.../node_modules/ws/lib/WebSocket.js:539:10)
at Receiver.opcodes.1.finish (.../node_modules/ws/lib/Receiver.js:397:14)
at Receiver.opcodes.1.getData as expectHandler
at Receiver.add (.../node_modules/ws/lib/Receiver.js:93:24)
at Socket.firstHandler (.../node_modules/ws/lib/WebSocket.js:519:22)
--------------------------------------[End Error]--------------------------------------

How do you make a synchronous request?

I assume it is by adding changing the argument to 'true', but it doesn't seem to be working. Do you know why?

var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function() {

  if (this.readyState == 4) {                                           
    data[i] = JSON.parse(this.responseText);
  }
};

xhr.open("GET", URI, true);
xhr.send();

(This snippet is inside a for loop)

post with null or "" will got 411

Hi,
if I post with nothing, like:

xhr.open("POST", url, true);
xhr.send("");

the "Content-Length" will not set in the request head, so I will get "411 Length Required" from the server.

i found that this code runs well on browser.

thx!

Support HTTP State Management

The W3C specification says:

If the user agent supports HTTP State Management it should persist, discard and send cookies (as received in the Set-Cookie response header, and sent in the Cookie header) as applicable.

As far as I can see from sources, this is not implemented yet

FormData as argument in send method

today i try to call xmlhttprequest during that i send argument of type FormData but it is giving error as follow:

TypeError: Argument must be a string

support upload

In the browser, the api looks something like this:

$('#file').on('change', function (event) {
  var xhr = new XMLHttpRequest();
  xhr.upload.addEventListener('progress', onProgress, false);
  xhr.addEventListener('load', onSuccess, false);
  xhr.open('POST', '/upload/audio');
  fd = new FormData();
  fd.append('file', event.target.files[0]);
  xhr.send(fd);
});

I'd like to have this functionality with node.js so I can do testing.

persisted cookies idea

Hey. I seen persisted cookies were on the todo list. Just wanted to jot down a idea I had for this.

A option to disable them, also have a jar. So before making the request I can create a jar, empty, delete the jar when done? Similar to https://github.com/mikeal/request I guess. Not sure now this goes with the WC3 spec but this would most likey be similar to browser settings. For Example this would be useful if a app needed multiple jars for different users. Maybe a proxy server for example would have a random Id for the user and store cookies on it behalf on the server, then say they are inactive for 10 min or close out it would delete the jar.

getRequestHeader should be case-insensitive

Per spec headers should be case-insensitive as should any functions that access them. getRequestHeader currently assumes a case match.

Consider rewriting all response header related code to use a string to store headers instead of an array. A regex can then be used to retrieve headers and ignore case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.