Skip to content

Instantly share code, notes, and snippets.

console.log('foo');
@russellhaering
russellhaering / 0001-http-fix-missing-drain-events.patch
Created February 22, 2011 05:37
http: fix missing 'drain' events
From a0fec09da264671faa5be6d0ed0bbe3a716d08cd Mon Sep 17 00:00:00 2001
From: Russell Haering <russellhaering@gmail.com>
Date: Sat, 19 Feb 2011 16:00:05 -0800
Subject: [PATCH 1/2] http: fix missing 'drain' events
---
lib/http.js | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/http.js b/lib/http.js
@russellhaering
russellhaering / test-pump-file2http.js
Created February 10, 2011 08:17
Note that this depends on elipses-large.txt, which is just elipses.txt concatenated onto itself several (I used 6) times
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var http = require('http');
var util = require('util');
var path = require('path');
var fn = path.join(common.fixturesDir, 'elipses-large.txt');
var client_req_complete = false;
var expected = fs.readFileSync(fn, 'utf8');
@russellhaering
russellhaering / test-http-client-upload-bigbuf.js
Created February 4, 2011 20:25
Breaking Node.js HTTP Client
var common = require('../common');
var assert = require('assert');
var http = require('http');
var sent_body = '';
var server_req_complete = false;
var client_res_complete = false;
var server = http.createServer(function(req, res) {
assert.equal('POST', req.method);
@russellhaering
russellhaering / CloudkickAPI.java
Created November 14, 2010 01:46
Base API class
public class CloudkickAPI {
private static final String TAG = "CloudkickAPI";
private static String API_HOST = "api.cloudkick.com";
private static String API_VERSION = "1.0";
private final String key;
private final String secret;
private final HttpClient client;
private SharedPreferences prefs = null;
public CloudkickAPI(Context context) throws EmptyCredentialsException {
From a577a6fc0a83adba1b5ba5de28a1e656ef68a570 Mon Sep 17 00:00:00 2001
From: Russell Haering <russellhaering@gmail.com>
Date: Sat, 4 Sep 2010 01:48:40 -0700
Subject: [PATCH] Prevent ReadStream.resume from breaking if the file isn't yet open.
---
lib/fs.js | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/fs.js b/lib/fs.js
function TestAssert(testname) {
this.testname = testname;
}
TestAssert.prototype = assert;
TestAssert.prototype.fail = function() {
try {
assert.fail.call(this, arguments);
}
var http = require('http');
var client = http.createClient(8124);
var request;
for (var i = 0; i < 10; i++) {
request = client.request('GET', '/', {'host': 'localhost'});
request.end();
console.log("Request sent");
}
var sys = require('sys');
var incoming = [];
// Pre-build a giant array of buffers to simulate incoming data
for (i = 0; i < 500000; i++) {
incoming.push(new Buffer('12345678901234567890123456789012345678901234567890123456789012345678901234567890123468901234567890'));
}
function do_test(name, method) {
process.on('uncaughtException', function() {
console.log("JAY");
});
process.nextTick(function() {
throw new Error("JUHU");
});