Skip to content
Browse files

Merge branch 'restler-removal'

  • Loading branch information...
2 parents 05031c5 + 9403e2f commit c41a5a99bd4466ee146adb73dad41980c639eb35 @xrd committed Jan 3, 2011
Showing with 16 additions and 6 deletions.
  1. +16 −6 lib/connect-rpx.js
View
22 lib/connect-rpx.js
@@ -1,8 +1,9 @@
var sys = require('sys');
-var restler = require( 'restler' );
+var http = require('http');
+var qs = require('querystring');
// Connect Middleware for integrating RPX Now into your application
-var RPX_HOST = 'http://rpxnow.com';
+var RPX_HOST = 'rpxnow.com';
var RPX_LOGIN_ROOT = "/api/v2/auth_info";
var RPX_LOGIN_URL = "https://rpxnow.com/api/v2/auth_info";
@@ -41,10 +42,19 @@ function getCredentials(req,res,next) {
function postWithCredentials( token, req, res, next ) {
var apiKey = options['apiKey'];
- var toPost = { token : token, apiKey : apiKey, format : 'json', extended : true };
- restler.post( RPX_LOGIN_URL, { data : toPost } ).
- addListener( 'complete', function credentialize(incoming) { onCredentialsReceived( incoming, req, res, next ); } ).
- addListener( 'error', onError );
+ var toPost = qs.stringify( { token : token, apiKey : apiKey } );
+ var toPostHeader = { 'Host' : RPX_HOST,
+ 'Content-Type' : 'application/x-www-form-urlencoded',
+ 'Content-Length' : toPost.length };
+ var postRequest = http.createClient( 443, RPX_HOST, true ).request( 'POST', RPX_LOGIN_ROOT, toPostHeader );
+ postRequest.write( toPost, 'utf8' );
+ postRequest.on( 'response', function(rpxResponse) {
+ var rpxResponseBody = '';
+ rpxResponse.on( 'data', function(chunk) { rpxResponseBody += chunk; } );
+ rpxResponse.on( 'end', onCredentialsReceived( rpxResponseBody, req, res, next ) );
+ rpxResponse.on( 'error', onError );
+ });
+ postRequest.end();
}
function onError(response) {

0 comments on commit c41a5a9

Please sign in to comment.
Something went wrong with that request. Please try again.