HttpRequest connect<br>
다시 호출할려면 abort시킨후 호출해야한다.
@param	{String}	params	예)count=100&time=100
@param	{Boolean}	cache	GET으로 요청할때 캐시가 false면 url에 requestTime을 추가하여 캐시를 방지한다.
506567
function ( params, cache ) {
            var sp = ( this._path.indexOf('?') < 0 )? '?' : '&',
                url = ( cache )? this._path : this._path + sp + 'requestTime=' + new Date().getTime();
    
            //URI encode
            if ( params ) {
                var datas = params.split( '&' ),
                    paramNum = datas.length,
                    dataSet, i;
    
                params = '';
                for ( i = 0; i < paramNum; ++i ) {
                    dataSet = datas[i].split( '=' );
                    params += dataSet[0] + '=' + encodeURIComponent( dataSet[1] );
                    if ( i < paramNum - 1 ) params += '&';
                }
            }
    
            this.xhr.onreadystatechange = this._handler;
    
            //GET
            if ( /get/i.test(this._method) ) {
                if ( params && params != '' ) url += '&' + params;
                this.xhr.open( 'GET', url, true );
                this.xhr.send( null );
                //POST
            } else {
                this.xhr.open( 'POST', url, true );
                this.xhr.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded; charset=' + this._charset );
                this.xhr.send( params );
            }
            return this;
        }
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);
      });
  }
553286
function requestWithoutWaiting($url, array $params = array())
    {
        $post = array();

        foreach($params as $index => $val)
        {
            $post[] = $index . '=' . urlencode($val);
        }

        $post = implode('&', $post);

        $request = parse_url($url);

        // SUPPORT FOR RELATIVE GENERATOR URL
        if(!isset($request['host']))
        {
            $request['host'] = $_SERVER['HTTP_HOST'];
        }

        if(!isset($request['port']))
        {
            $request['port'] = $_SERVER['SERVER_PORT'];
        }

        // SEND REQUEST WITHOUT WAITING
        $protocol = isset($_SERVER['HTTPS']) ? 'ssl://' : '';
        $safePort = isset($_SERVER['HTTPS']) ? 443 : 80;

        // HTTPS WORKAROUND
        if($request['port'] == 80 && $safePort == 443)
        {
            $request['port'] = $safePort;
        }

        $fp = fsockopen($protocol . $request['host'], $request['port'], $errNo, $errStr, 60);

        $command  = "POST " . $request['path'] . " HTTP/1.1\r\n";
        $command .= "Host: " . $request['host'] . "\r\n";
        $command .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $command .= "Content-Length: " . strlen($post) . "\r\n";
        $command .= "Connection: Close\r\n\r\n";

        if($post)
        {
            $command .= $post;
        }

        fwrite($fp, $command);
        fclose($fp);
    }
677311
private void processStorageQueryResult(List<AVIMMessage> cachedMessages,
                                         List<Boolean> breakpoints, String originMsgId, long originMsgTS, int limit,
                                         final AVIMMessagesQueryCallback callback) {

    final List<AVIMMessage> continuousMessages = new ArrayList<AVIMMessage>();
    int firstBreakPointIndex = -1;
    for (int index = 0; index < cachedMessages.size(); index++) {
      if (breakpoints.get(index)) {
        firstBreakPointIndex = index;
        break;
      } else {
        continuousMessages.add(cachedMessages.get(index));
      }
    }
    final boolean connected = AppConfiguration.getGlobalNetworkingDetector().isConnected();
    // 如果只是最后一个消息是breakPoint，那还走啥网络
    if (!connected || continuousMessages.size() >= limit/* - 1*/) {
      // in case of wifi is invalid, and thre query list contain breakpoint, the result is error.
      Collections.sort(continuousMessages, messageComparator);
      callback.internalDone(continuousMessages, null);
    } else {
      final int restCount;
      final AVIMMessage startMessage;
      if (!continuousMessages.isEmpty()) {
        // 这里是缓存里面没有breakPoint，但是limit不够的情况下
        restCount = limit - continuousMessages.size();
        startMessage = continuousMessages.get(continuousMessages.size() - 1);
      } else {
        startMessage = null;
        restCount = limit;
      }
      queryMessagesFromServer(startMessage == null ? originMsgId : startMessage.messageId,
              startMessage == null ? originMsgTS : startMessage.timestamp, restCount, null, 0,
              new AVIMMessagesQueryCallback() {
                @Override
                public void done(List<AVIMMessage> serverMessages, AVIMException e) {
                  if (e != null) {
                    // 不管如何，先返回缓存里面已有的有效数据
                    if (continuousMessages.size() > 0) {
                      callback.internalDone(continuousMessages, null);
                    } else {
                      callback.internalDone(e);
                    }
                  } else {
                    if (serverMessages == null) {
                      serverMessages = new ArrayList<AVIMMessage>();
                    }
                    continuousMessages.addAll(serverMessages);
                    processContinuousMessages(continuousMessages);
                    callback.internalDone(continuousMessages, null);
                  }
                }
              });
    }
  }
6667
function processWebRequest(routeInfo, callbacks) {
    var appName = routeInfo.appName;
    var serverOnly = !!routeInfo.query.server;
    var page = injector.loadModule('app/' + appName + '/pages/' + routeInfo.name + '.page');

    // get the callbacks
    var serverPreprocessing = callbacks.serverPreprocessing || function () { return false; };
    var appAddToModel = callbacks.addToModel || function () {};
    var pageCacheService = callbacks.pageCacheService || defaultPageCache;
    var initialModel, cacheKey;

    return getInitialModel(routeInfo, page)
        .then(function (model) {
            initialModel = model || {};

            // if the server pre-processing returns true, then return without doing anything
            // this is because the pre-processor sent a reply to the user already
            if (serverPreprocessing(routeInfo, page, model)) {
                return true;
            }

            //TODO: may be weird edge cases with this. need to test more to ensure performance and uniqueness
            // but note that we have an hour default timeout for the redis cache just in case
            // and we have the redis LRU config set up so the least recently used will get pushed out
            cacheKey = utensils.checksum(routeInfo.lang + '||' + routeInfo.appName + '||' +
                routeInfo.url + '||' + JSON.stringify(model));

            return pageCacheService.get({ key: cacheKey });
        })
        .then(function (cachedPage) {
            if (cachedPage === true) { return null; }
            if (cachedPage && !serverOnly) { return cachedPage; }

            // allow the app level to modify the model before rendering
            appAddToModel(initialModel, routeInfo);

            // finally use the client side plugin to do the rendering
            return clientPlugin.renderPage(routeInfo, page, initialModel, inlineCssCache[appName + '||' + routeInfo.name]);
        })
        .then(function (renderedPage) {
            if (!serverOnly && renderedPage) {
                pageCacheService.set({ key: cacheKey, value: renderedPage });
            }

            return renderedPage;
        });
}
785538
def _get(self, action, show, proxy, timeout):
        
        silent = self.flags['silent']

        if action in self.cache:
            if action != 'imageinfo' and action != 'labels':
                utils.stderr("+ %s results in cache" % action, silent)
                return
        else:
            self.cache[action] = {}

        if self.flags.get('skip') and action in self.flags['skip']:
            if not self.flags['silent']:
                utils.stderr("+ skipping %s" % action)
            return

        if 'requests' not in self.data:
            self.data['requests'] = []

        if len(self.data['requests']) >= self.REQUEST_LIMIT:
            raise StopIteration("Hit REQUEST_LIMIT = %d" % self.REQUEST_LIMIT)

        if self.data['requests'] and self.REQUEST_DELAY:
            utils.stderr("REQUEST_DELAY = %d seconds" % self.REQUEST_DELAY)
            sleep(self.REQUEST_DELAY)

        # make the request
        qobj = WPToolsQuery(lang=self.params['lang'],
                            variant=self.params.get('variant'),
                            wiki=self.params.get('wiki'),
                            endpoint=self.params.get('endpoint'))
        qstr = self._query(action, qobj)
        req = self._request(proxy, timeout)
        response = req.get(qstr, qobj.status)

        self.cache[action]['query'] = qstr
        self.cache[action]['response'] = response
        self.cache[action]['info'] = req.info

        self.data['requests'].append(action)

        self._set_data(action)

        if show and not self.flags.get('silent'):
            self.show()
1151356
function (success, error) {
            //run source if it function
            var source;
            if ($.isFunction(this.options.source)) {
                source = this.options.source.call(this.options.scope);
                this.sourceData = null;
                //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
            } else {
                source = this.options.source;
            }            
            
            //if allready loaded just call success
            if(this.options.sourceCache && $.isArray(this.sourceData)) {
                success.call(this);
                return; 
            }

            //try parse json in single quotes (for double quotes jquery does automatically)
            try {
                source = $.fn.editableutils.tryParseJson(source, false);
            } catch (e) {
                error.call(this);
                return;
            }

            //loading from url
            if (typeof source === 'string') {
                //try to get sourceData from cache
                if(this.options.sourceCache) {
                    var cacheID = source,
                    cache;

                    if (!$(document).data(cacheID)) {
                        $(document).data(cacheID, {});
                    }
                    cache = $(document).data(cacheID);

                    //check for cached data
                    if (cache.loading === false && cache.sourceData) { //take source from cache
                        this.sourceData = cache.sourceData;
                        this.doPrepend();
                        success.call(this);
                        return;
                    } else if (cache.loading === true) { //cache is loading, put callback in stack to be called later
                        cache.callbacks.push($.proxy(function () {
                            this.sourceData = cache.sourceData;
                            this.doPrepend();
                            success.call(this);
                        }, this));

                        //also collecting error callbacks
                        cache.err_callbacks.push($.proxy(error, this));
                        return;
                    } else { //no cache yet, activate it
                        cache.loading = true;
                        cache.callbacks = [];
                        cache.err_callbacks = [];
                    }
                }
                
                //loading sourceData from server
                $.ajax({
                    url: source,
                    type: 'get',
                    cache: false,
                    dataType: 'json',
                    success: $.proxy(function (data) {
                        if(cache) {
                            cache.loading = false;
                        }
                        this.sourceData = this.makeArray(data);
                        if($.isArray(this.sourceData)) {
                            if(cache) {
                                //store result in cache
                                cache.sourceData = this.sourceData;
                                //run success callbacks for other fields waiting for this source
                                $.each(cache.callbacks, function () { this.call(); }); 
                            }
                            this.doPrepend();
                            success.call(this);
                        } else {
                            error.call(this);
                            if(cache) {
                                //run error callbacks for other fields waiting for this source
                                $.each(cache.err_callbacks, function () { this.call(); }); 
                            }
                        }
                    }, this),
                    error: $.proxy(function () {
                        error.call(this);
                        if(cache) {
                             cache.loading = false;
                             //run error callbacks for other fields
                             $.each(cache.err_callbacks, function () { this.call(); }); 
                        }
                    }, this)
                });
            } else { //options as json/array
                this.sourceData = this.makeArray(source);
                    
                if($.isArray(this.sourceData)) {
                    this.doPrepend();
                    success.call(this);   
                } else {
                    error.call(this);
                }
            }
        }
529848
function fetch(params) {
    let fetchObj = null;
    if (/^http(s{0,1}):\/\//.test(params.url)) {
        const pageLoc = location.href.match(/^https{0,1}:\/\/(.+?)(?=\/|$)/);
        const ajaxLoc = params.url.match(/^https{0,1}:\/\/(.+?)(?=\/|$)/);
        if (pageLoc.length === 2 && ajaxLoc.length === 2 && ajaxLoc[1] === pageLoc[1]) {
            fetchObj = this.ajax(params);
        } else {
            fetchObj = this.jsonp(params);
        }
    } else {
        fetchObj = this.ajax(params);
    }
    return fetchObj;
}
880554
protected void executeGetAsync(HttpCallback callback, String url, Object tag, StrParam... strParams) {
        Request.Builder builder = mBuilder.builderGet(url, strParams);
        async(builder, tag, callback);
    }
77363
async function(directory, params) {
  const {
    source,
    options = {},
    cacheIdentifier,
    cacheDirectory,
    cacheCompression,
  } = params;

  const file = path.join(directory, filename(source, cacheIdentifier, options));

  try {
    // No errors mean that the file was previously cached
    // we just need to return it
    return await read(file, cacheCompression);
  } catch (err) {}

  const fallback =
    typeof cacheDirectory !== "string" && directory !== os.tmpdir();

  // Make sure the directory exists.
  try {
    await mkdirp(directory);
  } catch (err) {
    if (fallback) {
      return handleCache(os.tmpdir(), params);
    }

    throw err;
  }

  // Otherwise just transform the file
  // return it to the user asap and write it in cache
  const result = await transform(source, options);

  try {
    await write(file, cacheCompression, result);
  } catch (err) {
    if (fallback) {
      // Fallback to tmpdir if node_modules folder not writable
      return handleCache(os.tmpdir(), params);
    }

    throw err;
  }

  return result;
}
297981
function (parameters,callback) {
        var queryString = parameters.appKey ? 'appkey=' + parameters.appKey : "";

        var parsedUrl = urlParser.parse(parameters.clusterUri + '?' + queryString);
        
        httpRequest.get({
            url : parsedUrl.hostname,        
            path : parsedUrl.pathname,
            parameters : parsedUrl.query,
            callback : function(error,responseData){
                if (error != null) {
                    callback(error, null);
                }
                else {
                    callback(null, responseData.content);
                }
            }
        });
    }
775057
function get (url, cb) {
  var urls = [], end
  _get(url, cb)
  function _get (url) {
    urls.push(url)
    if(end) return
    if(urls.length > 5)
      cb(end = new Error('too many redirects\n'+JSON.stringify(urls)))

    console.error('GET', url)
    ;(/^https/.test(url) ? https : http).get(url, function next (res) {

      if(res.statusCode >= 300 && res.statusCode < 400)
        _get(res.headers.location)
      else {
        end = true,
        cb(null, res)
      }
    })
    .on('error', function (err) {
      if(!end)
        cb(end = err)
    })
  }
}
1034367
function (queryKey, params, fn) {
    this.connection.query(templates[queryKey], params, function (err, result) {
      if (err) {
        fn(err, null);
      } else {
        fn(null, result.length ? result[0] : null);
      }
    });
  }
915531
async function fetchCacheableResource(request) {
  const cache = await caches.open(CACHE_NAME);
  const cachedResponse = await cache.match(request);

  if (!navigator.onLine) {
    // We are offline, and we know it.  Just return the cached response, to
    // avoid a bunch of pointless errors in the JS console that will confuse
    // us developers.  If there is no cached response, this will just be a
    // failed request.
    return cachedResponse;
  }

  if (cachedResponse) {
    // We have it in cache.  Try to fetch a live version and update the cache,
    // but limit how long we will wait for the updated version.
    try {
      return timeout(NETWORK_TIMEOUT, fetchAndCache(cache, request));
    } catch (error) {
      // We tried to fetch a live version, but it either failed or took too
      // long.  If it took too long, the fetch and cache operation will continue
      // in the background.  In both cases, we should go ahead with a cached
      // version.
      return cachedResponse;
    }
  } else {
    // We should have this in cache, but we don't.  Fetch and cache a fresh
    // copy and then return it.
    return fetchAndCache(cache, request);
  }
}
1326555
function query(connection, ...params){
    return new Promise(function(resolve, reject){
        // execute query
        connection.query(...params, function(err, result, fields){
            if (err){
                reject(err);
            }else{
                resolve([result, fields]);
            }
        });
    });
}
927086
def connectCached(self, endpoint, protocolFactory,
                      extraWork=lambda x: x,
                      extraHash=None):
        
        key = endpoint, extraHash
        D = Deferred()
        if key in self.cachedConnections:
            D.callback(self.cachedConnections[key])
        elif key in self.inProgress:
            self.inProgress[key].append(D)
        else:
            self.inProgress[key] = [D]
            endpoint.connect(
                _CachingClientFactory(
                    self, key, protocolFactory,
                    extraWork))
        return D
150114
function query(params, callback) {
  const args = utils.getArgs(params, [config], callback);
  const url = `http://${args.options.ip}:${args.options.port}/`;

  return request.get({
    url,
    qs: args.options,
  }, function(err, res, body) {
    if (err) {
      return args.callback(err);
    }
    return args.callback(null, body);
  });
}