Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions lib/twitter-node/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var https = require('https'),
var https = require('https'),
query = require('querystring'),
Parser = require('./parser'),
EventEmitter = require('events').EventEmitter,
Expand Down Expand Up @@ -45,7 +45,8 @@ var TwitterNode = exports.TwitterNode = function(options) {
this.params = options.params || {};
this.user = options.user;
this.password = options.password;
this.headers = { "User-Agent": 'Twitter-Node' };
this.headers = { 'User-Agent' : 'Twitter-Node' }
this.options = { port: this.port, host: this.host, method: 'GET', agent: false, headers: this.headers };
this.debug = false;
this.parser = new Parser();
this.parser.addListener('object', processJSONObject(this));
Expand Down Expand Up @@ -108,39 +109,31 @@ TwitterNode.prototype.stream = function stream() {

if (this.action === 'filter' && this.buildParams() === '') return;

var headers = extend({}, this.headers),
var options = extend(this.options, { headers: this.headers }),
twit = this,
request;

headers['Host'] = this.host;

options.path = this.requestUrl();
if (this.user) {
headers['Authorization'] = basicAuth(this.user, this.password);
options.headers["Authorization"] = basicAuth(this.user, this.password);
}

var requestOptions = {
host: this.host,
port: this.port,
path: this.requestUrl(),
method: 'POST',
headers: headers
};
request = https.request(options, function (response) {

twit._clientResponse = response;

response.on('data', function(chunk) {
twit._receive(chunk);
});

request = https.request(requestOptions, function(response) {
twit._clientResponse = response;

response.on('data', function(chunk){
twit._receive(chunk);
});

response.on('end', function() {
twit.emit('end', this);
twit.emit('close', this);
});
response.on('end', function() {
twit.emit('end', this);
twit.emit('close', this);
});

});

request.end();

return this;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/twitter-node/parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var sys = require('sys')
var sys = require('util')

// glorious streaming json parser, built specifically for the twitter streaming api
// assumptions:
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "twitter-node",
"description": "node.js stream API for the twitter streaming HTTP API",
"version": "0.0.2",
"version": "0.0.3",
"author": "technoweenie",
"contributors": [
{ "name": "Makis Tracend", "email": "makis.tracend@gmail.com" }
],
"repository": {
"type": "git",
"url": "http://github.com/technoweenie/twitter-node.git"
Expand Down