Promise版Request Get
@param url
181844
function pGetUrl(url, headers){
    //console.log(`\r\n发起远程请求(${Date()})：${url}\r\n`);
    if(!headers){
        headers = {};
    }
    headers['User-Agent'] = 'Request-Promise';
    return rp({
        uri: url,
        headers: headers,
        json: true // Automatically parses the JSON string in the response
    });
}
777497
function promisedRequest(url) {
	var taskId = this[0], req = Object.create(this[1]);
	var method = req.method || 'get';

	if ('args' in req) {
		req.url = url + taskId + find_separator(url) + req.args
	}
	else {
		req.url = url + taskId
	}

	return new Promise(function(resolve, reject) {
		return request[method](req, function(err, response, body) {
			return err ? reject({error: err, headers: response && response.headers})
				: resolve({body: body, headers: response.headers});
		});
	});
}
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;
  });
}
769807
function (template, templateUrl) {
                    var deferred = $q.defer();
                    if (template) {
                        deferred.resolve(template);
                    } else if (templateUrl) {
                        $templateRequest(templateUrl, true)
                            .then(function (template) {
                                deferred.resolve(template);
                            }, function (error) {
                                deferred.reject(error);
                            });
                    } else {
                        deferred.reject("No template or templateUrl has been specified.");
                    }
                    return deferred.promise;
                }
851841
function fetch( url, callback ) {
    request({ url: url, json: true }, function( err, resp, data ) {
        if (err) {
            return callback(err);
        }

        if ( 200 != resp.statusCode ) {
            return callback(new Error(resp.statusMessage));
        }

        callback(data);
    });
}
1127769
async function getSession (url) {
  const token = await loadToken(url)
  if (!token) return null
  const header = jwt.decode(token)
  if (!header) return null
  const now = Math.floor(Date.now() / 1000)
  if (header.exp <= now) return null
  return header
}
1285865
function download(url) {
  if (!validator.isURL(url)) return Promise.reject(error(400, 'Invalid URL: ' + url));
  // download in progress
  if (progress[sha]) return progress[sha];
  var sha = hash(url);
  return progress[sha] = cache.access(sha).then(function (filename) {
    if (filename) return filename;

    return request(url)
    .redirects(3)
    .agent(false)
    .then(function (response) {
      assert(response.status < 400, response.status, 'Got status code ' + response.status + ' from ' + url);
      assert(response.status === 200, 'Got status code ' + response.status + ' from ' + url);

      debug('Downloading %s -> %s', url, sha);

      return cache.copy(sha, response.response);
    });
  }).then(function (filename) {
    delete progress[sha];
    return filename;
  }, /* istanbul ignore next */ function (err) {
    delete progress[sha];
    throw err;
  });
}
851045
function get(url, opts){
	opts = opts || {};

	return requestp(_.extend(defaults, opts, {
		url: url
	}));
}
687318
function makeRequest(params) {
    var QPromiseFactory = function(resolver) {
      return q.Promise(resolver);
    };
    params.retryStrategy = loggingRetryStrategy;
    params.promiseFactory = QPromiseFactory;
    return request(params)
      .then(function (response) {
        if (response.statusCode !== 200) {
          throw new Error('HTTP error (' + response.statusCode + ')');
        }
        return response.body;
      })
      .fail(function (error) {
        throw new WrapperError([
          params.method,
          params.url,
          'failed.'
        ].join(' '), error);
      });
  }
550750
function(url, options, defaults) {
            var d = Q.defer();
            options = options || {};
            options = _.extend(options, defaults, {
                "url": url
            });
            var r = new Requests(options);
            r.on("done", function(content) {
                d.resolve(content);
            });
            r.on("error", function(err) {
                var e = new Error(err.textStatus+": "+err.content);
                e.textStatus = err.textStatus,
                e.httpRes = err.content;
                d.reject(e);
            });

            r.execute();
            return d.promise;
        }
639259
public final Promise get(String key) {
		byte[] binaryKey = key.getBytes(StandardCharsets.UTF_8);
		if (client != null) {
			return new Promise(client.get(binaryKey));
		}
		if (clusteredClient != null) {
			return new Promise(clusteredClient.get(binaryKey));
		}
		return Promise.resolve();
	}
1153007
function fetchResults (searchText) {
    var items = $scope.$parent.$eval(itemExpr),
        term  = searchText.toLowerCase(),
        isList = angular.isArray(items),
        isPromise = !!items.then; // Every promise should contain a `then` property

    if (isList) onResultsRetrieved(items);
    else if (isPromise) handleAsyncResults(items);

    function handleAsyncResults(items) {
      if (!items) return;

      items = $q.when(items);
      fetchesInProgress++;
      setLoading(true);

      $mdUtil.nextTick(function () {
          items
            .then(onResultsRetrieved)
            .finally(function(){
              if (--fetchesInProgress === 0) {
                setLoading(false);
              }
            });
      },true, $scope);
    }

    function onResultsRetrieved(matches) {
      cache[term] = matches;

      // Just cache the results if the request is now outdated.
      // The request becomes outdated, when the new searchText has changed during the result fetching.
      if ((searchText || '') !== ($scope.searchText || '')) {
        return;
      }

      handleResults(matches);
    }
  }
867230
public static JSONObject getJSONFromUrlViaGET(String url) {

        JSONObject jObj = null;

        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }

                jObj = new JSONObject(builder.toString());
            } else {
                // Log.e(ParseJSON.class.toString(), "Failed to download file");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jObj;
    }
637858
function makeHttpRequest(reqHeaders, expectedRes, cacheHitExpected, next) {
  reqHeaders.cookie = _.reduce(reqHeaders.cookie, function(memo, val, name) {
    memo.push(name + '=' + val);
    return memo;
  }, []).join('; ');

  var start = Date.now();

  request({
    url: 'http://localhost:1337',
    method: 'GET',
    headers: reqHeaders
  }, function(err, data, body) {
    var time = Date.now() - start;

    console.log('  status:', data.statusCode);
    console.log('  body  :', body);
    console.log('  time  :', time);

    common.verify(function() {
      JSON.parse(body).should.eql(expectedRes);
      common.shouldUseCache(cacheHitExpected, time);
    });

    next();
  });
}
421636
function downloadString(url, {userAgent}) {
	let deferred  = Q.defer()
	let startTime = Date.now()
	let data = ''
	request({
		method: 'GET',
		url: url,
		headers: {
			'User-Agent': userAgent
		}
	}, function(error, response, body) {
		if(error) {
			deferred.reject(new Error(error))
			return;
		}
		deferred.resolve({
			time: Date.now() - startTime,
			result: body,
			statusCode: response.statusCode
		})
	})
	return deferred.promise
}
927334
function handleGetRequest(request) {
  const objId = request.objectId;
  const className = request.className;
  if (objId) {
    // Object.fetch() query
    const collection = getCollection(className);
    const currentObject = collection[objId];
    if (!currentObject) {
      return Parse.Promise.as(respond(404, {
        code: 101,
        error: 'object not found for update',
      }));
    }
    let match = _.cloneDeep(currentObject);

    if (match) {
      const toOmit = Array.from(getMask(className));
      match = _.omit(match, toOmit);
    }

    return Parse.Promise.as(respond(200, match));
  }
  const data = request.data;
  indirect = data.redirectClassNameForKey;
  let matches = recursivelyMatch(className, data.where);
  let matchesClassName = '';
  if (indirect) {
    matches = outOfBandResults.matches;
    if (outOfBandResults.className) {
      matchesClassName = outOfBandResults.className;
    }
  }

  if (request.data.count) {
    return Parse.Promise.as(respond(200, { count: matches.length }));
  }

  matches = queryMatchesAfterIncluding(matches, data.include);

  const toOmit = Array.from(getMask(className));
  matches = matches.map((match) => _.omit(match, toOmit));

  // TODO: Can we just call toJSON() in order to avoid this?
  matches.forEach(match => {
    if (match.createdAt) {
      match.createdAt = match.createdAt.toJSON();
    }
    if (match.updatedAt) {
      match.updatedAt = match.updatedAt.toJSON();
    }
  });

  // sort results if necessary
  if (data.order && data.order.length > 0 && matches.length > 0) {
    matches = sortQueryresults(matches, data.order);
  }

  const limit = data.limit || DEFAULT_LIMIT;
  const startIndex = data.skip || 0;
  const endIndex = startIndex + limit;
  const response = { results: matches.slice(startIndex, endIndex) };

  // Add the class name for the outgoing objects to the response if sepcified
  if (matchesClassName.length > 0) {
    response.className = matchesClassName;
  }

  return Parse.Promise.as(respond(200, response));
}
1112904
function promiseResult (options, data) {
		log(`promiseResult: data ${data}`);
		return new Promise((resolve, reject) => {
			/* Check cache to avoid I/O. */
			const cacheHit = checkCache(config, pattern);
			if (cacheHit !== RESPONSE_UNKNOWN) {
				log(`Cache hit: ${cacheHit}`);
				return resolve(cacheHit);
			}

			const req = https.request(options, (res) => {
				res.setEncoding('utf8');

				let response = '';
				res.on('data', (chunk) => {
					log(`Got data`);
					response += chunk;
				});

				res.on('end', () => {
					log(`end: I got ${JSON.stringify(response)}`);

					const result = serverResponseToRESPONSE(response);
					log(`end: result ${result}`);
					updateCache(config, postObject.pattern, result);

					if (result === RESPONSE_INVALID) {
						return reject(result);
					} else {
						return resolve(result);
					}
				});
			});

			req.on('error', (e) => {
				log(`Error: ${e}`);
				return reject(RESPONSE_INVALID);
			});

			// Write data to request body.
			log(`Writing to req:\n${data}`);
			req.write(data);
			req.end();
		});
	}