Load file and dispatch to response
778989
public function go() {
		if ($this->action == "options") {
			$file = "options" . $this->getExtension();
		} else {
			// Check if handler file exists
			if ($this->route->route == "/") {
				$file = $this->getAction() . $this->getExtension();
			} else {
				$file = $this->route->resource . "/" . $this->getAction() . $this->getExtension();
			}
		}

		$fullFilePath = stream_resolve_include_path($file);
		if ($fullFilePath) {
			include $fullFilePath;
		} else {
			throw new \Ginger\Exception("Not implemented", 501);
		}

		$this->getResponse()->send();
	}
510179
def _load(self):
        
        if self.is_exists():
            return open(self._ref, "rb").read()
        raise NotFoundError("File %s not found" % self._ref)
1109974
function (responseObject, next) {
    responseObject.fileResult = new FileResult(share, directory, file);
    if (!responseObject.error) {
      responseObject.fileResult.exists = true;
      responseObject.fileResult.getPropertiesFromHeaders(responseObject.response.headers);
      
    } else if (responseObject.error && responseObject.error.statusCode === Constants.HttpConstants.HttpResponseCodes.NotFound) {
      responseObject.error = null;
      responseObject.fileResult.exists = false;
      responseObject.response.isSuccessful = true;
    }

    var finalCallback = function (returnObject) {
      callback(returnObject.error, returnObject.fileResult, returnObject.response);
    };

    next(responseObject, finalCallback);
  }
388177
function respondWithFile(req, res, path, ifNoFile) {
  ifNoFile = ifNoFile || function() {};
  // We use `documentRoot` as the root wherein we seek files.
  var realpath = protectedPath(req.server.documentRoot, path);
  fs.stat(realpath, function(err, stats) {
    if (err) return ifNoFile();

    if (stats.isDirectory()) {
      realpath = p.join(realpath, 'index.html');
    }
    res.mime(p.extname(realpath).slice(1));

    // Cache management (compare timestamps at second-level precision).
    var lastModified = Math.floor(stats.mtime / 1000);
    var since = req.headers['if-modified-since'];
    if (since && (lastModified <= Math.floor(new Date(since) / 1000))) {
      res.statusCode = 304; // not modified.
      res.end();
      return;
    }
    res.setHeader('Last-Modified', stats.mtime.toUTCString());

    // Connect the output of the file to the network!
    var raw = fs.createReadStream(realpath);
    raw.on('error', function(err) {
      log(err.stack, 'error');
      res.statusCode = 404;
      res.end('Not Found\n');
    });
    raw.pipe(res.compressed());
  });
}
545266
def dispatch(self, request, *args, **kwargs):
        

        self.return_url = request.GET.get('return_url', None)
        referrer = request.META.get('HTTP_REFERER', None)

        # leave alone POST and ajax requests and if return_url is explicitly left empty
        if (request.method != "GET" or
                request.is_ajax() or
                self.return_url or
                referrer is None or
                self.return_url is None and 'return_url' in request.GET):
            return super().dispatch(request, *args, **kwargs)

        if not self.return_url:
            url = request.get_full_path()
            if url.find("?") < 0:
                url = "?return_url=".join((url, referrer))
            else:
                url = "&return_url=".join((url, referrer))
            return HttpResponseRedirect(url)
410473
function _load(source, callback) {
  fs.readFile(source, {encoding: 'utf8'}, _jsonLoaded.bind(null, callback));
}
1078748
def load(self, *args, **kwargs):
        
        response = self.http.send(self.url)
        if response.status_code == 200:
            _txt = response.content
            return self.parse_and_check_signature(_txt)
        else:
            logger.info("Response status: %s", response.status_code)
            raise SourceNotFound(self.url)
1172293
def download_file(response)
      tmp_file = Tempfile.new '', Configuration.temp_folder_path
      content_disposition = response.headers['Content-Disposition']
      if content_disposition
        filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
        path = File.join File.dirname(tmp_file), filename
      else
        path = tmp_file.path
      end
      # close and delete temp file
      tmp_file.close!

      File.open(path, 'w') { |file| file.write(response.body) }
      Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
                                "folder for further processing and delete the temp afterwards"
      File.new(path)
    end
275731
function _load()
    {
        $file = $this->_getFilePath();
        if (! file_exists($file) )
            ## nothing to import, no data written yet!
            return;

        ErrorStack::handleError(E_ALL);
        ##  \\\\\
        $data = include $file;
        $data = $this->getDataInterchange()->retrieveBackward($data);
        ##  /////
        if ( $exception = ErrorStack::handleDone() )
            throw new exReadError('Error While Read Data.', $exception->getCode(), $exception);


        if (! is_array($data) )
            throw new exDataMalformed('Error Data Structure, it must be array.');

        $this->data = $data;
    }
695850
def dispatch_request(self, *args, **kwargs):
        """"""
        method = getattr(self, request.method.lower(), None)
        if method is None and request.method == 'HEAD':
            method = getattr(self, 'get', None)
        assert method is not None, 'Unimplemented method {}'.format(request.method)

        headers = {'Content-Type': 'application/vnd.api+json'}

        response = method(*args, **kwargs)

        if isinstance(response, Response):
            response.headers.add('Content-Type', 'application/vnd.api+json')
            return response

        if not isinstance(response, tuple):
            if isinstance(response, dict):
                response.update({'jsonapi': {'version': '1.0'}})
            return make_response(json.dumps(response, cls=JSONEncoder), 200, headers)

        try:
            data, status_code, headers = response
            headers.update({'Content-Type': 'application/vnd.api+json'})
        except ValueError:
            pass

        try:
            data, status_code = response
        except ValueError:
            pass

        if isinstance(data, dict):
            data.update({'jsonapi': {'version': '1.0'}})

        return make_response(json.dumps(data, cls=JSONEncoder), status_code, headers)
786048
def load_file(file_name)
      File.open(file_name, "r") do |f|
        f.each_line.collect do |line|
          parse_json(line)
        end
      end
    end
792555
def run(self):
        ""
        # load files from source directory
        files = self.get_files()

        # loop through each middleware
        for func in self.middleware:

            # call each one, ignoring return value
            func(files, self)

        # store and return the result
        self.files.update(files)
        return files
727545
def call(self, **data):
        
        uri, body, headers = self.prepare(data)
        return self.dispatch(uri, body, headers)
1315873
function load(path, callback, errorCallback) {
  try {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", path, true);
    xhr.onreadystatechange = function() {
      if (xhr.readyState === 4) {
        if (xhr.status === 200 || xhr.status === 304) {
          try {
            var response = JSON.parse(xhr.responseText);
            callback(response);
          } catch (e) {
            errorCallback(e);
          }
        } else {
          errorCallback(xhr);
        }
      }
    };
    xhr.setRequestHeader("Content-Type", "application/json");
    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.send();
  } catch (e) {
    errorCallback(e);
  }
}
1175971
function processGithubFile (options, callback) {
  var item = options.item
  var key = options.key
  var json = options.json

  function respond (content) {
    if (isFeatureCollection(content)) {
      content.name = key
      content.updated_at = json.updated_at
      return content
    }
    return false
  }

  if (item.truncated) {
    return request({
      url: item.raw_url
    }, function (err, content) {
      if (err) return callback(err)

      callback(null, respond(content))
    })
  }

  try {
    var content = JSON.parse(item.content)
  } catch (e) {
    var msg = 'could not parse file contents of ' + key + ': ' + e.message
    return callback(new Error(msg))
  }

  callback(null, respond(content))
}
1171508
def file_response(data: Union[bytes, str],  # HttpResponse encodes str if req'd
                  content_type: str,
                  filename: str) -> HttpResponse:
    
    response = HttpResponse(data, content_type=content_type)
    add_download_filename(response, filename)
    return response
275626
protected void dispatch(String pathInContext,
                            HttpServletRequest request,
                            HttpServletResponse response,
                            ServletHolder servletHolder, 
                            int type)
        throws ServletException, UnavailableException, IOException
    {
        if (type == Dispatcher.__REQUEST)
        {
            // This is NOT a dispatched request (it it is an initial request)
            ServletHttpRequest servletHttpRequest= (ServletHttpRequest)request;
            ServletHttpResponse servletHttpResponse= (ServletHttpResponse)response;  
            
            // protect web-inf and meta-inf
            if (StringUtil.startsWithIgnoreCase(pathInContext, "/web-inf") || StringUtil.startsWithIgnoreCase(pathInContext, "/meta-inf"))
            {
                response.sendError(HttpResponse.__404_Not_Found);
                return;
            }
            
            // Security Check
            if (!getHttpContext().checkSecurityConstraints(
                            pathInContext,
                            servletHttpRequest.getHttpRequest(),
                            servletHttpResponse.getHttpResponse()))
                return;
        }
        else
        {
            // This is a dispatched request.
            
            // Handle dispatch to j_security_check
            HttpContext context= getHttpContext();
            if (context != null
                    && context instanceof ServletHttpContext
                    && pathInContext != null
                    && pathInContext.endsWith(FormAuthenticator.__J_SECURITY_CHECK))
            {
                ServletHttpRequest servletHttpRequest=
                    (ServletHttpRequest)context.getHttpConnection().getRequest().getWrapper();
                ServletHttpResponse servletHttpResponse= servletHttpRequest.getServletHttpResponse();
                ServletHttpContext servletContext= (ServletHttpContext)context;
                
                if (!servletContext.jSecurityCheck(pathInContext,servletHttpRequest.getHttpRequest(),servletHttpResponse.getHttpResponse()))
                    return;
            }
        }
        
        // Build and/or cache filter chain
        FilterChain chain=null;
        if (pathInContext != null) {
            chain = getChainForPath(type, pathInContext, servletHolder);
        } else {
            chain = getChainForName(type, servletHolder);
        }

        if (log.isDebugEnabled()) log.debug("chain="+chain);
        
        // Do the handling thang
        if (chain!=null)
            chain.doFilter(request, response);
        else if (servletHolder != null)
            servletHolder.handle(request, response);    
        else // Not found
            notFound(request, response);
    }