@since 0.0.1
@author Igor Ivanovic
@method Favicon#onRequest

@description
On request handle favicon
@return {object}
190193
function Favicon_onRequest(api) {

        var url = api.parsedUrl.pathname,
            maxAge = 60 * 60 * 24 * 30 * 12,  // one year
            filePath,
            mimeType;

        if (this.config.skip) {
            url = url.replace(this.regex, '');
        }

        filePath = di.normalizePath(this.config.path + url);

        mimeType = this.mimeType(filePath);

        if (!mimeType) {
            logger.info('Assets.onRequest.mimeType: missing', {
                mimeType: mimeType,
                filePath: filePath
            });
            return this.handleError(function() {
                new error.HttpError(500, {path: filePath}, 'Invalid mime type');
            });
        }

        if (api.getMethod() !== 'GET') {
            return this.handleError(function() {
                new error.HttpError(500, {path: filePath}, 'Assets are accessible only via GET request');
            });
        }

        return new Promise(function (resolve, reject) {

            this.readFile(filePath, function (err, file) {

                if (err) {
                    try {
                        new error.HttpError(500, {path: filePath}, 'No file found', err);
                    } catch (e) {
                        return reject(e);
                    }
                }

                api.addHeader('Content-Type', mimeType);
                api.addHeader('Cache-Control', 'public, max-age=' + ~~(maxAge));
                api.addHeader('ETag', etag(file));


                if (api.isHeaderCacheUnModified()) {
                    return resolve(api.sendNoChange());
                }

                logger.info('Assets.onRequest.mimeType:', {
                    mimeType: mimeType,
                    filePath: filePath
                });
                resolve(file);
            });
        }.bind(this));

    }
1319952
function favicoIntegration(options = defaultFavicoOptions) {
  // Create a new Favico integration.
  // Initially this was going to be a singleton object, but I realized there
  // may be cases where you want several different types of notifications.
  // The middleware does not yet support multiple instances, but it should
  // be easy to add if there's demand :)
  //
  // Not using the constructor pattern, because it obfuscates JS' prototypal
  // nature, and there's no need for inheritance here, so this is equivalent.
  const favico = new Favico(options);

  return {
    currentVal: 0,

    update(value, callback) {
      if ( typeof value === 'number' ) {
        // Don't allow non-integer values
        if ( value % 1 !== 0 ) {
          return callback(`
            Warning: Favico not affected.
            You provided a floating-point value: ${value}.
            You need to provide an integer, or a keyword value.

            See https://github.com/joshwcomeau/redux-favicon#troubleshooting for more information.
          `);
        }

        this.currentVal = value;

      } else if ( typeof value === 'string' ) {
        switch ( value.toLowerCase() ) {
          case 'increment': this.currentVal++; break;
          case 'decrement': this.currentVal--; break;
          case 'reset':     this.currentVal=0; break;
          default:
            return callback(`
              Warning: Favico not affected.
              You provided a string value: ${value}.
              The only strings we accept are: ${favicoEnumValues.join(', ')}.

              See https://github.com/joshwcomeau/redux-favicon#troubleshooting for more information.
            `);
        }

      } else {
        // Annoyingly, istanbul won't give me 100% coverage unless all possible
        // typeof values are checked. It is not possible for all types to make
        // it to this check; `undefined` aborts earlier.
        /* istanbul ignore next */
        const provided_type = typeof value;

        return callback(`
          Warning: Favico provided an illegal type.
          You provided a a value of type: ${provided_type}.
          We only accept integers or strings.

          See https://github.com/joshwcomeau/redux-favicon#troubleshooting for more information.
        `);
      }

      // Don't allow negative numbers
      this.currentVal = ( this.currentVal < 0 ) ? 0 : this.currentVal;

      // Set the 'badge' to be our derived value.
      // The favico.js library will show it if it's truthy, hide it if falsy.
      favico.badge(this.currentVal);

      return callback();
    }
  };
}
1198280
function requestHandler(req, res, next) {
  const start = Date.now();
  let source;

  return Promise.try(() => {
    source = core.getPublicSource(req.params.src);
    return source.getHandler().getInfoAsync().then(info => [info, infoHeaders]);
  }).spread((data, dataHeaders) => {
    core.setResponseHeaders(res, source, dataHeaders);

    if (req.query && req.query.format) {
      const escapedText = JSON.stringify(data, null, ' ').replace(/&/g, '&amp;').replace(/</g, '&lt;');
      res.send(`<pre>${escapedText}</pre>`);
    } else {
      res.json(data);
    }

    const mx = util.format('req.%s.info', req.params.src);
    core.metrics.endTiming(mx, start);
  }).catch(err => core.reportRequestError(err, res)).catch(next);
}
924219
function() {
        return new ImageUrl({
            transformations: this.transformations.slice(0),
            baseUrl: this.rootUrl,
            user: this.user,
            publicKey: this.publicKey,
            privateKey: this.privateKey,
            imageIdentifier: this.imageIdentifier,
            extension: this.extension,
            queryString: this.queryString,
            path: this.path
        });
    }
266770
function get(src) {
      var defer = $q.defer();

      _checkImgCacheReady()
        .then(function() {
          ImgCache.isCached(src, function(path, success) {
            if (success) {
              defer.resolve(path);
            } else {
              defer.reject();
            }
          }, defer.reject);
        })
        .catch(defer.reject);

      return defer.promise;
    }
34395
def get(url)
      stdin, stdout, stderr, t = Open3.popen3(curl_get_cmd(url))
      output = encode_utf8(stdout.read).strip
      error = encode_utf8(stderr.read).strip
      if !error.nil? && !error.empty?
        if error.include? "SSL"
          raise FaviconParty::Curl::SSLError.new(error)
        elsif error.include? "Couldn't resolve host"
          raise FaviconParty::Curl::DNSError.new(error)
        else
          raise FaviconParty::CurlError.new(error)
        end
      end
      output
    end
235684
func FaviconHandler(favPath string) http.Handler {
	f, err := os.Open(favPath)
	if err != nil {
		panic(errFileOpen.Format(favPath, err.Error()))
	}
	defer f.Close()
	fi, _ := f.Stat()
	if fi.IsDir() { // if it's dir the try to get the favicon.ico
		fav := path.Join(favPath, "favicon.ico")
		f, err = os.Open(fav)
		if err != nil {
			//we try again with .png
			favPath = path.Join(favPath, "favicon.png")
			return FaviconHandler(favPath)
		}
		favPath = fav
		fi, _ = f.Stat()
	}

	cType := TypeByExtension(favPath)
	// copy the bytes here in order to cache and not read the ico on each request.
	cacheFav := make([]byte, fi.Size())
	if _, err = f.Read(cacheFav); err != nil {
		panic(errFileRead.Format(favPath, "Favicon: "+err.Error()))
	}

	return StaticContentHandler(cacheFav, cType)
}
753433
void setCurrentFavIcon(final byte[] imageData) {

        m_fieldFavIcon.setVisible(true);
        m_fieldUploadFavIcon.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SITE_FAVICON_CHANGE_0));
        m_fieldFavIcon.setSource(new StreamResource(new StreamResource.StreamSource() {

            private static final long serialVersionUID = -8868657402793427460L;

            public InputStream getStream() {

                return new ByteArrayInputStream(imageData);
            }
        }, ""));
    }
1260746
def get_favicon(self, article):
        
        kwargs = {'tag': 'link', 'attr': 'rel', 'value': 'icon'}
        meta = self.parser.getElementsByTag(article.doc, **kwargs)
        if meta:
            favicon = self.parser.getAttribute(meta[0], 'href')
            return favicon
        return ''
925913
public function handleRequest(): self
    {
        if ($this->params->getBotParam('webhook.url')) {
            return $this->handleWebhook();
        }

        if ($loop_time = $this->getLoopTime()) {
            return $this->handleGetUpdatesLoop($loop_time, $this->getLoopInterval());
        }

        return $this->handleGetUpdates();
    }
483629
public function get_favicon()
	{
		$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
		trigger_error('Favicon handling has been removed, please use your own handling', $level);

		if (($url = $this->get_link()) !== null)
		{
			return 'http://g.etfv.co/' . urlencode($url);
		}

		return false;
	}
570229
function serveFavicon() {
    let iconType;
    let filePath;

    return function serveFavicon(req, res, next) {
        if (req.path.match(/^\/favicon\.(ico|png)/i)) {
            // CASE: favicon is default
            // confusing: if you upload an icon, it's same logic as storing images
            // we store as /content/images, because this is the url path images get requested via the browser
            // we are using an express route to skip /content/images and the result is a image path
            // based on config.getContentPath('images') + req.path
            // in this case we don't use path rewrite, that's why we have to make it manually
            filePath = imageLib.blogIcon.getIconPath();

            let originalExtension = path.extname(filePath).toLowerCase();
            const requestedExtension = path.extname(req.path).toLowerCase();

            // CASE: custom favicon exists, load it from local file storage
            if (settingsCache.get('icon')) {
                // depends on the uploaded icon extension
                if (originalExtension !== requestedExtension) {
                    return res.redirect(302, urlService.utils.urlFor({relativeUrl: `/favicon${originalExtension}`}));
                }

                storage.getStorage()
                    .read({path: filePath})
                    .then((buf) => {
                        iconType = imageLib.blogIcon.getIconType();
                        content = buildContentResponse(iconType, buf);

                        res.writeHead(200, content.headers);
                        res.end(content.body);
                    })
                    .catch(next);
            } else {
                originalExtension = path.extname(filePath).toLowerCase();

                // CASE: always redirect to .ico for default icon
                if (originalExtension !== requestedExtension) {
                    return res.redirect(302, urlService.utils.urlFor({relativeUrl: '/favicon.ico'}));
                }

                fs.readFile(filePath, (err, buf) => {
                    if (err) {
                        return next(err);
                    }

                    content = buildContentResponse('x-icon', buf);

                    res.writeHead(200, content.headers);
                    res.end(content.body);
                });
            }
        } else {
            return next();
        }
    };
}
323080
function() {
      inputEx.UrlField.superclass.render.call(this);
      this.el.size = this.options.size;

      if(!this.options.favicon) {
         YAHOO.util.Dom.addClass(this.el, 'nofavicon');
      }

      // Create the favicon image tag
      if(this.options.favicon) {
         this.favicon = inputEx.cn('img', {src: inputEx.spacerUrl});
         this.fieldContainer.insertBefore(this.favicon,this.fieldContainer.childNodes[0]);

         // focus field when clicking on favicon
         YAHOO.util.Event.addListener(this.favicon,"click",function(){this.focus();},this,true);
      }
   }
318736
def find_favicon_urls_in_html(html)
      doc = Nokogiri.parse html
      candidate_urls = doc.css(ICON_SELECTORS.join(",")).map {|e| e.attr('href') }.compact
      candidate_urls.sort_by! {|href|
        if href =~ /\.ico/
          0
        elsif href =~ /\.png/
          1
        else
          2
        end
      }
      uri = URI final_url
      candidate_urls.map! do |href|
        href = URI.encode(URI.decode(href.strip))
        if href =~ /\A\/\//
          href = "#{uri.scheme}:#{href}"
        elsif href !~ /\Ahttp/
          # Ignore invalid URLS - ex. {http://i50.tinypic.com/wbuzcn.png}
          href = URI.join(url_root, href).to_s rescue nil
        end
        href
      end.compact.uniq
    end
466013
function Request_parse() {
        var that = this, url = this.url;
        if (this.isForwarded) {
            return this._process()
                .then(function destroy() {
                    logger.info('Request.destroy', {
                        url: that.url,
                        status: that.statusCode,
                        id: that.id,
                        isRendered: that.isRendered,
                        content_type: that.getHeader('content-type')
                    });
                    that._destroy();
                })
                .catch(function error(e) {
                    logger.error('Request.destroy', {error: e, url: url});
                });
        }
        // receive body as buffer
        this.request.on('data', this.body.push.bind(this.body));

        return new Promise(this.request.on.bind(this.request, 'end'))
            .then(this._process.bind(this))
            .then(function destroy() {
                logger.info('Request.destroy', {
                    url: that.url,
                    status: that.statusCode,
                    id: that.id,
                    isRendered: that.isRendered,
                    content_type: that.getHeader('content-type')
                });
                that._destroy();
            })
            .catch(function error(e) {
                logger.error('Request.destroy', {error: e, url: url});
            });

    }
61464
function request() {
                return ajax.request(url, {
                    success: function () {
                        var retryAfter,
                            req;

                        if (!aborted) {
                            req = this.rawRequest;
                            // check status code for 202
                            if (this.status === 202 && util.isFn(req.getResponseHeader)) {
                                // retry the request
                                retryAfter = parseInt(req.getResponseHeader('retry-after'));
                                if (retryAfter > 0) {
                                    setTimeout(request, retryAfter * 1000);
                                    return;
                                }
                            }
                            if (this.responseText) {
                                $deferred.resolve(this.responseText);
                            } else {
                                // the response was empty, so consider this a
                                // failed request
                                retryOrFail({
                                    error: 'empty response',
                                    status: this.status,
                                    resource: url
                                });
                            }
                        }
                    },
                    fail: function () {
                        if (!aborted) {
                            retryOrFail({
                                error: this.statusText,
                                status: this.status,
                                resource: url
                            });
                        }
                    }
                });
            }
705176
function handler(req, res) {
    // Support both the ?url= mode and the X-WTF-URL header.
    var targetUrl;
    if (req.headers['x-wtf-url']) {
      targetUrl = req.headers['x-wtf-url'];
    } else {
      var parsedUrl = url.parse(req.url, true);
      var query = parsedUrl.query;
      targetUrl = query.url;
    }
    if (!targetUrl || targetUrl.indexOf('http') != 0) {
      res.writeHead(404, ['Content-Type', 'text/plain']);
      res.end();
      return;
    }

    res.on('error', function(e) {
      console.log('ERROR (source): ' + e);
    });

    var targetModule = targetUrl.indexOf('https') == 0 ? https : http;
    targetModule.get(targetUrl, function(originalRes) {
      // Eat errors, otherwise the app will die.
      originalRes.on('error', function(e) {
        console.log('ERROR (target): ' + e);
      });

      // Pull out content type to see if we are interested in it.
      var supportedContentType = false;
      var contentType = originalRes.headers['content-type'];
      if (contentType && contentType.indexOf(';') != 0) {
        contentType = contentType.substr(0, contentType.indexOf(';'));
      }
      switch (contentType) {
        case 'text/javascript':
        case 'application/javascript':
          supportedContentType = true;
          break;
      }

      // Also parse the URL - some servers don't return content type for some
      // reason.
      var supportedPath = false;
      var contentUrl = url.parse(targetUrl);
      if (path.extname(contentUrl.pathname) == '.js') {
        supportedPath = true;
      }

      if (supportedContentType || supportedPath) {
        var headers = [];
        for (var key in originalRes.headers) {
          if (key == 'content-length') {
            continue;
          }
          headers.push([key, originalRes.headers[key]]);
        }
        res.writeHead(originalRes.statusCode, headers);
        injectStream(targetUrl, originalRes, res);
      } else {
        console.log('Pass-through: ' + targetUrl, contentType);
        res.writeHead(originalRes.statusCode, originalRes.headers);
        originalRes.pipe(res);
      }
    }).on('error', function(e) {
      console.log(e);
      res.writeHead(404, ['Content-Type', 'text/plain']);
      res.end(e.message);
    });
  }