• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

XMLHttpRequest emulator for node.js

XMLHttpRequest Emulation for node.js

This is an npm package that implements the W3C XMLHttpRequest specification on top of the node.js APIs.

Supported Platforms

This library is tested against the following platforms.

Keep in mind that the versions above are not hard requirements.

Installation and Usage

The preferred installation method is to add the library to the dependencies section in your package.json.

{
  "dependencies": {
    "xhr2": "*"
  }
}

Alternatively, npm can be used to install the library directly.

npm install xhr2

Once the library is installed, require-ing it returns the XMLHttpRequest constructor.

var XMLHttpRequest = require('xhr2');

The other objects that are usually defined in an XHR environment are hanging off of XMLHttpRequest.

var XMLHttpRequestUpload = XMLHttpRequest.XMLHttpRequestUpload;

MDN (the Mozilla Developer Network) has a great intro to XMLHttpRequest.

This library's CoffeeDocs can be used as quick reference to the XMLHttpRequest specification parts that were implemented.

Features

The following standard features are implemented.

  • http and https URI protocols
  • Basic authentication according to the XMLHttpRequest specification
  • request and response header management
  • send() accepts the following data types: String, ArrayBufferView, ArrayBuffer (deprecated in the standard)
  • responseType values: text, json, arraybuffer
  • readystatechange and download progress events
  • overrideMimeType()
  • abort()
  • timeout
  • automated redirection following

The following node.js extensions are implemented.

  • send() accepts a node.js Buffer
  • Setting responseType to buffer produces a node.js Buffer
  • nodejsSet does XHR network configuration that is not exposed in browsers, for security reasons

The following standard features are not implemented.

  • FormData
  • Blob
  • file:// URIs
  • data: URIs
  • upload progress events
  • synchronous operation
  • Same-origin policy checks and CORS
  • cookie processing

Versioning

The library aims to implement the W3C XMLHttpRequest specification, so the library's API will always be a (hopefully growing) subset of the API in the specification.

Development

The following commands will get the source tree in a node-xhr2/ directory and build the library.

git clone git://github.com/pwnall/node-xhr2.git
cd node-xhr2
npm install
npm pack

Installing CoffeeScript globally will let you type cake instead of node_modules/.bin/cake

npm install -g coffeescript

The library comes with unit tests that exercise the XMLHttpRequest API.

cake test

The tests themselves can be tested by running them in a browser environment, where a different XMLHttpRequest implementation is available. Both Google Chrome and Firefox deviate from the specification in small ways, so it's best to run the tests in both browsers and mentally compute an intersection of the failing tests.

cake webtest
BROWSER=firefox cake webtest

Copyright and License

The library is Copyright (c) 2013 Victor Costan, and distributed under the MIT License.

More Repositories

1

chromeview

Proof of concept Android WebView implementation based on Chromium code
Java
1,690
star
2

node-open

open a file or uri with the users preferred application (browser, editor, etc), cross platform
JavaScript
560
star
3

sanctum

Minimal RISC Extensions for Isolated Execution
C++
50
star
4

dropship-chrome

The source code for the "Download to Dropbox" Chrome extension, before it makes it to dropbox.js/samples
CoffeeScript
40
star
5

chromeview-src

Android WebView implementation that uses the latest Chromium code
Java
37
star
6

node-parse-database-url

Database configuration URL parser for node.js
JavaScript
22
star
7

gitty

Private git repository manager
Ruby
20
star
8

daemonz

Automatically starts and stops the daemons in a Rails application.
Ruby
19
star
9

vbox

Golang wrapper for VirtualBox's XPCOM API
Go
18
star
10

webkit_remote

Client for the Webkit Remote Debugging server
Ruby
17
star
11

sphero-notes

Notes on reverse-engineering sphero
16
star
12

igor

Course homework submission site
Ruby
14
star
13

virtual_box

VirtualBox API for Ruby
Ruby
14
star
14

tfrecord

Reader and writer for the TensorFlow Record file format
TypeScript
14
star
15

rbtree-pure

Pure-ruby implementation of the rbtree gem
Ruby
13
star
16

rtunnel

reverse tunnel server and client
Ruby
12
star
17

wenlin_db_scanner

Extracts the data from the Wenlin dictionary program
Assembly
11
star
18

html5-app-container

HTML5 application container for Android and iOS
Shell
8
star
19

sgx-explained

Source code for the "SGX Explained" paper
TeX
7
star
20

x_do

Ruby FFI bindings to libxdo
Ruby
7
star
21

node-sphero-pwn

Driver for Sphero robots
CoffeeScript
6
star
22

anki_importer

Importer for Anki deck databases
Ruby
6
star
23

fbgraph_rails

Rails plug-in integrating the fbgraph gem
Ruby
6
star
24

authpwn_rails

User authentication for Rails 3 applications.
Ruby
6
star
25

dropbox-chrome

Prototype Chrome extension for Dropbox
CoffeeScript
5
star
26

pwnalytics_js

Open-source Web analytics
JavaScript
4
star
27

pwnalytics

Open-source Web analytics
Ruby
4
star
28

zerg_support

Support libraries used by Zergling.Net deployment code.
Ruby
4
star
29

w3hear-js

Infrastructure for speech recognition in JavaScript
CoffeeScript
3
star
30

chromembed_rails

Rails Engine for applications that are strongly coupled to Chrome extensions.
Ruby
3
star
31

zhangmen

What does this button do?
Ruby
3
star
32

chatty

IM Web app using WebSockets, with a MongoDB backing store
CSS
3
star
33

configvars_rails

Global configuration variables for Rails 3 applications.
Ruby
3
star
34

w3gram-server

Push notifications (W3gram) server in node.js
CoffeeScript
3
star
35

xilinx-provision

Deploys bitfiles to Xilinx FPGAs
Ruby
2
star
36

file_blobs_rails

Database-backed file storage for Rails 5 applications
Ruby
2
star
37

vulkan_tutorial

C++
2
star
38

ether_shell

IRB shell tweaked for testing Ethernet devices
Ruby
2
star
39

mapreduced

Golang service for running Map-Reduce jobs using Docker containers
Go
2
star
40

julius4

Git mirror of julius4 in :pserver:[email protected]:/cvsroot/julius
C
2
star
41

sushi

Victor's programming language
C++
2
star
42

opinion_map

Rails application demo for MIT 6.470 2012 guest lecture
Ruby
2
star
43

cubox

Build setup for cubox-i
Shell
2
star
44

scancodes

Golang library that produces the keyboard scancodes needed to type in a string
Go
2
star
45

w3gram-js

Push Notifications (W3gram) JavaScript Client Library
CoffeeScript
2
star
46

battlecode-server

Java
2
star
47

rails_pwnerer

Rails deployment hack.
Ruby
2
star
48

pwnalytics_client

Ruby gem for pulling data from a Pwnalytics server
Ruby
2
star
49

pwnstyles_rails

Non-trivial default styling for Rails applications.
CSS
2
star
50

script-digest

W3C proposal for a <script> content integrity check
2
star
51

exec_sandbox

Run foreign binaries using POSIX sandboxing features
Ruby
2
star
52

codo-theme-yaml

YAML theme for the codo documentation generator
CoffeeScript
2
star
53

ql-config

My Quake Live configuration file
2
star
54

cudainfo

CLI tool that shows the properties of installed CUDA GPUs
Cuda
2
star
55

sphero_pwn

Wrapper around the Bluetooth RFCONN protocol used to program Sphero robots
Ruby
2
star
56

clh

CraigsList Housing Helper
Ruby
2
star
57

node-sphero-pwn-macros

Macro compiler for Sphero robots
CoffeeScript
2
star
58

stellar

Automated access to MIT's Stellar data
Ruby
2
star
59

mit_stalker

Fetches publicly available information about MIT students.
Ruby
2
star
60

feedtools_ram_cache

RAM-based cache for FeedTools.
Ruby
1
star
61

webkit_remote_unstable

Unstable features for the webkit_remote Webkit remote debugging client
Ruby
1
star
62

imageutil

Golang library containing a seemingly random collection of low-level image processing tools
Go
1
star
63

heroku-web-client

Heroku Platform API client for Web applications
TypeScript
1
star
64

ether_ping

Command-line ping equivalent for Ethernet frames
Ruby
1
star
65

playbox

Skeleton for Web UI experiments
Ruby
1
star
66

fallocate

Rubygem containing FFI bindings to the posix_fallocate libc call.
Ruby
1
star
67

filer

Ruby
1
star
68

mit_cert_auth

Source code for the MIT certificate authentication proxy service (Ruby on Rails).
Ruby
1
star
69

ddr

DDR :)
CoffeeScript
1
star
70

next_editor

Syntax-highlighting editor that supports IME (Input Method Editor) input for languages with complex scripts
JavaScript
1
star
71

pwnbus-configdb

Pure-ruby database for configuration variables.
Ruby
1
star
72

bcpm

MIT Battlecode (6.370) Program Manager
Ruby
1
star
73

markdpwn

HTML-formats text documents such as Markdown, textile, and source code
Ruby
1
star
74

gem-index-dumper

Spot-checks on the gem index.
Ruby
1
star
75

radeonhd-power.fc

Fedora packaging for radeon-power
1
star
76

tian_tian

Rails application that generates Chinese character practice sheets
Ruby
1
star
77

bitdiddle_sec

Web application for Bitdiddle's Encryption Standard breaking exercise in MIT 6.857
Ruby
1
star
78

usaco

C++
1
star
79

battlecode-client

Official Battlecode game client, 2D and 3D versions
Java
1
star
80

radeonhd-power

Configures the RadeonHD open-source driver's power management.
Shell
1
star
81

node-sphero-pwn-cli

Command-line tools for Sphero robots
CoffeeScript
1
star
82

rockbands_bot

Bot for the Rockbands Live game
Ruby
1
star
83

filer_js

JavaScript
1
star
84

pwnfx_js

Sprinkles of AJAX using UJS
1
star
85

topological_sort

Topological sorting in arbitrary directed graphs.
Ruby
1
star
86

inplacecontrols

The inplacecontrols Rails plug-in, hacked to work with for Rails 3.
Ruby
1
star
87

pwnpet_web

Ruby
1
star
88

pset_writeups

Write-ups for my MIT problem sets
Ruby
1
star
89

pdf_test

Rails application for playing with PDF security features
Ruby
1
star
90

hsreporter

Hearthstone logging output uploader in Golang
Go
1
star
91

hibaby

De-anonymizer for dating networks
TeX
1
star
92

coninference

Ruby
1
star