var HttpError = require('../error/httperror.js');
var querystring = require('querystring');

var HttpAdapter = function(http) {

  if (!http || http === 'undefined') {
    http = require('http');
  }

  this.url = require('url');
  this.http = http;
  this.rateLimit = {
    limit: null,
    remaining: null,
    reset: null
  };
};

/**
* Geocode
* @param <string>   url      Webservice url
* @param <array>    params   array of query string parameters
* @param <function> callback Callback method
*/
HttpAdapter.prototype.get = function(url, params, callback) {

  var urlParsed = this.url.parse(url);
  var options = {
    host: urlParsed.host,
    path: urlParsed.path + '?' + querystring.stringify(params),
    headers: {
      'user-agent': 'Mozilla/5.0 (X11; Linux i586; rv:31.0) Gecko/20100101 Firefox/31.0'
    }

  };
  var self = this;

  this.http.request(options, function(response) {
    var str = '';
    var contentType = response.headers['content-type'];

    if (response.headers['X-RateLimit-Limit'])
      self.rateLimit.limit = response.headers['X-RateLimit-Limit'];
    if (response.headers['X-RateLimit-Remaining'])
      self.rateLimit.remaining = response.headers['X-RateLimit-Remaining'];
    if (response.headers['X-RateLimit-Reset'])
      self.rateLimit.reset = response.headers['X-RateLimit-Reset'];

    response.on('data', function(chunk) {
      str += chunk;
    });

    //the whole response has been recieved, so we just print it out here
    response.on('end', function() {

      if (response.statusCode !== 200) {
        return callback(new Error('Response status code is ' + response.statusCode), null);
      }

      if (contentType !== undefined && contentType.indexOf('application/json') >= 0) {
        callback(false, JSON.parse(str));
      } else {
        callback(false, str);
      }

    });
  })
    .on('error', function(err) {
      callback(new HttpError(err.message), null);
    })
    .end();
};

HttpAdapter.prototype.supportsHttps = function() {
  return false;
};

module.exports = HttpAdapter;

@@ -1008,25 +1008,27 @@
 mit-Limit'%5D)
+ %7B
 %0A
-
       self.r
@@ -1079,24 +1079,30 @@
 it-Limit'%5D;%0A
+    %7D%0A
     if (resp
@@ -1139,16 +1139,18 @@
 ining'%5D)
+ %7B
 %0A      s
@@ -1214,24 +1214,30 @@
 emaining'%5D;%0A
+    %7D%0A
     if (resp
@@ -1270,16 +1270,18 @@
 Reset'%5D)
+ %7B
 %0A      s
@@ -1340,16 +1340,22 @@
 Reset'%5D;
+%0A    %7D
 %0A%0A    re

Expected { after 'if' condition curly