Request Allwrite Server.

@param {string} url The url to request.
@return {Promise}
198590
function request(remoteUrl) {
  return new Promise((resolve, reject) => {
    const get = adapters[url.parse(remoteUrl).protocol].get;
    get(remoteUrl, res => {
      const { statusCode } = res;
      const contentType = res.headers['content-type'];
      let rawData = '';

      // If it's not a 200 and not a 404 there's another issue. Allwrite will
      // only return these two statuses.
      if (statusCode !== 200 && statusCode !== 404) {
        const error = new Error('Allwrite: Request Failed.\n' +
                                `Status Code: ${statusCode}`);
        error.code = statusCode;
        return reject(error);
      } else if (!/^application\/json/.test(contentType)) {
        const error = new Error('Allwrite: Invalid content-type.\n' +
                          `Expected application/json but got ${contentType}`);
        return reject(error);
      }

      res.setEncoding("utf8");
      res.on("data", chunk => rawData += chunk);
      res.on("end", () => {
        try {
          resolve(JSON.parse(rawData));
        } catch (e) {
          reject(new Error("Allwrite response parsing error: " + e.message));
        }
      });
    });
  });
}
565523
function makeHttpRequests(options, fileHashes) {
    if (options.verbose) {
        _utils.logger.info('Performing HTTP requests...');
    }
    var promises = [];
    var _iteratorNormalCompletion4 = true;
    var _didIteratorError4 = false;
    var _iteratorError4 = undefined;

    try {
        for (var _iterator4 = fileHashes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
            var fileWithHash = _step4.value;

            if (fileWithHash.subtitlesPresent) continue;
            if (options.verbose) {
                _utils.logger.info('Downloading subtitles for file [%s] with hash [%s]', fileWithHash.file, fileWithHash.hash);
            }
            var httpRequest = new _utils.HttpRequest(options, fileWithHash);
            promises.push(httpRequest.request());
        }
    } catch (err) {
        _didIteratorError4 = true;
        _iteratorError4 = err;
    } finally {
        try {
            if (!_iteratorNormalCompletion4 && _iterator4.return) {
                _iterator4.return();
            }
        } finally {
            if (_didIteratorError4) {
                throw _iteratorError4;
            }
        }
    }

    return Promise.all(promises);
}
825745
function(url, callback) {
      if (!url) return callback('send(): url is empty.');
      console.log('send(): ' + url);
      request.get(url, function(err, res, body) {
        console.log(body);
	if (err) return callback(err);
        body = JSON.parse(body);
        if (body && body.query) {
          return callback('', body);
        } else {
          return callback('send(): No results returned.');
        }
      });
    }
1179640
function createExecutor(serverUrl) {
  let client = serverUrl.then(url => new http.HttpClient(url));
  let executor = new http.Executor(client);
  configureExecutor(executor);
  return executor;
}
775308
function Request(httpClient, url, method, headers, params, payload) {
    url = urlparse.parse(url, true); // query string parsing
    this.httpClient   = httpClient;
    this.scheme       = url.protocol.substr(0, url.protocol.length - 1);
    this.port         = url.port ? url.port : (this.scheme === 'http' ? 80 : 443);
    this.host         = url.hostname;
    this.method       = method;
    this.path_info    = url.pathname;
    this.query_string = url.query || {};
    this.headers      = headers || {},
    this.params       = params || {};
    this.payload      = payload || null;
    this.headers['host'] = url.hostname;
}
1067293
function httpRequest(path, req, options)
{
    return new Promise(function(resolve, reject) {
        req = extend({}, defaults, req, options);
        req.url += path;

        request(req, function(error, response, body) {
            if (error || !(/^2/.test('' + response.statusCode)) || /action=".?login.lua"/.test(body)) {
                if (/action=".?login.lua"/.test(body)) {
                    // fake failed login if redirected to login page without HTTP 403
                    response.statusCode = 403;
                }
                reject({
                    error: error,
                    response: response,
                    options: req
                });
            }
            else {
                resolve(body.trim());
            }
        });
    });
}
720827
function buildRequest(args) {
  const { browser, method } = args;
  const params  = args.params || new Map();
  const site    = /^(https?:|file:)/i.test(browser.site) ? browser.site : `http://${browser.site || 'locahost'}`;
  const url     = URL.resolve(site, URL.format(args.url));

  const headers = new Fetch.Headers(args.headers);

  // HTTP header Referer, but Document property referrer
  const referrer = args.referrer || browser.referrer || browser.referer || args.history.url;
  if (referrer && !headers.has('Referer'))
    headers.set('Referer', referrer);
  if (!headers.has('Accept'))
    headers.set('Accept', 'text/html,*/*');

  if (/^GET|HEAD|DELETE$/i.test(method)) {
    const uri = URL.parse(url, true);
    // These methods use query string parameters instead
    for (let [name, values] of params)
      uri.query[name] = values;
    return new Fetch.Request(URL.format(uri), { method, headers });
  }

  const mimeType = (args.encoding || '').split(';')[0].toLowerCase();
  // Default mime type, but can also be specified in form encoding
  if (mimeType === '' || mimeType === 'application/x-www-form-urlencoded') {
    const urlEncoded = [...params]
      .map(function([name, values]) {
        return values.map(value => `${QS.escape(name)}=${QS.escape(value)}`).join('&');
      })
      .join('&');

    headers.set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
    return new Fetch.Request(url, { method, headers, body: urlEncoded });
  }

  if (mimeType === 'multipart/form-data') {
    const form = new Fetch.FormData();
    for (let [name, values] of params)
      for (let value of values)
        form.append(name, value);
    return new Fetch.Request(url, { method, headers, body: form });
  }

  throw new TypeError(`Unsupported content type ${mimeType}`);
}
447270
function json(url, callback) {
    return request(url, function(req) {
      if (req.responseText) callback(JSON.parse(req.responseText));
    }, "application/json");
  }
586234
function rewrite(req, res) {

  /* istanbul ignore next: tough to mock fs write error */
  function onError(err) {
    this.conf.removeAllListeners('error');
    this.conf.removeAllListeners('write');
    res.send(err);
  }

  function onWrite() {
    this.conf.removeAllListeners('error');
    this.conf.removeAllListeners('write');
    res.send(null, Constants.OK);
  }

  this.conf.once('error', onError.bind(this));
  this.conf.write(this.conf.getFile(), onWrite.bind(this));
}
934169
function download(url) {
  return request('GET', url).then(function (res) {
    var out = {
      url: url,
      body: res.body,
      statusCode: res.statusCode,
      headers: res.headers,
      dependencies: []
    };

    try {
      if (out.statusCode === 302) {
        out.dependencies = [out.headers.location];
      } else if (!out.headers['content-type']) {
        out.dependencies = [];
      } else if (out.headers['content-type'].indexOf('text/html') !== -1) {
        out.dependencies = htmldeps(out.body.toString());
      } else if (out.headers['content-type'].indexOf('text/css') !== -1) {
        out.dependencies = cssdeps(out.body.toString());
      } else {
        out.dependencies = [];
      }
    } catch (ex) {
      ex.message = 'Error parsing deps for "' + url + '": ' + ex.message;
      throw ex;
    }
    return out;
  });
}
823784
public static String get(String url, String body) {
        return request(HttpRequest.get(replaceLocalHost(url)), body).body();
    }
1345297
function httpRequestPromise(method, urlObject) {
  if (method !== 'GET' && method !== 'HEAD') {
    return Promise.reject(new Error('We only support GET or HEAD requests'));
  }

  return new Promise(function (resolve, reject) {
    var httpsRequestOptions = {
      host: urlObject.host,
      method: method,
      path: urlObject.path
    };

    var req = https.request(httpsRequestOptions, function (res) {
      if (res.statusCode !== 200) {
        reject(new Error('Did not get 200 for ' + urlObject.href +
          ', instead got ' + res.statusCode));
        return;
      }

      resolve(res);
    })
    .on('error', function (e) {
      reject(new Error('Got error on ' + urlObject.href + ' - ' + e));
    });

    req.end();
  });
}
9572
function (url) {
        return new Promise(function (resolve, reject) {
            middleware(new MockReq(url), new MockRes(url, resolve), reject);
        });
    }
1282135
function request (url, options) {
  options = Object.assign({}, defaultOptions, options)
  let savedContent
  let savedResponse

  return new Promise((resolve, reject) => {
    fetch(url, options)
      .then(handleResponse)
      .then(handleBody)
      .catch(handleError)

    function handleResponse (response) {
      // Save the response for checking the status later
      savedResponse = response

      // Decode the response body
      switch (options.type) {
        case 'response':
          return response
        case 'json':
          return response.json()
        default:
          return response.text()
      }
    }

    function handleBody (content) {
      // Bubble an error if the response status is not okay
      if (savedResponse && savedResponse.status >= 400) {
        savedContent = content
        throw new Error(`Response status indicates error`)
      }

      // All is well!
      resolve(content)
    }

    function handleError (err) {
      // Overwrite potential decoding errors when the actual problem was the response
      if (savedResponse && savedResponse.status >= 400) {
        err = new Error(`Status ${savedResponse.status}`)
      }

      // Enrich the error message with the response and the content
      let error = new Error(err.message)
      error.response = savedResponse
      error.content = savedContent
      reject(error)
    }
  })
}
447972
function (req, res) {
        return function (err) {
            if (err) {
                res.writeHead(500);
                res.end(err.toString());
            } else {
                res.writeHead(404);
                res.end();
            }
        };
    }
1129622
function request(meth, url, headers, query, data, cb) {
    var req = SA(meth, url);
    if (headers) req.set(headers);
    if (query) req.query(query);
    if (data) req.send(data);
    return req.end(function(err, res) {
        if (err) return cb(err);
        return cb(null, res.text);
    });
}
649524
function(url){
    // this creates json object from url with querystring
    if((typeof url) == 'string'){
        var curURL = url;
        var queryStringIndex = curURL.indexOf("?");
        var qsString = curURL.substr(queryStringIndex + 1, curURL.length);
        return queryString.parse(qsString);
    }else if((typeof url)== 'object'){
        return url;
    }else{
        return {};
    }
}