rewrite send to support flash xdr
487114
function () {
            var self = this, io = self.io, c = io.config, xdr = c.xdr || {};
            if (!xdr.src) {
                if (typeof KISSY !== 'undefined' && KISSY.DEV_MODE) {
                    xdr.src = require.toUrl('../../assets/io.swf');
                } else {
                    xdr.src = require.toUrl('./assets/io.swf');
                }
            }    // 不提供则使用 cdn 默认的 flash
            // 不提供则使用 cdn 默认的 flash
            _swf(xdr.src, 1, 1);    // 简便起见，用轮训
            // 简便起见，用轮训
            if (!flash) {
                setTimeout(function () {
                    self.send();
                }, 200);
                return;
            }
            self._uid = util.guid();
            maps[self._uid] = self;    // ie67 send 出错？
            // ie67 send 出错？
            flash.send(io._getUrlForSend(), {
                id: self._uid,
                uid: self._uid,
                method: c.type,
                data: c.hasContent && c.data || {}
            });
        }
183510
function (request, callback) {
            this.nbXdrRequests += 1;

            this.xdrRequests[request.id] = {
                callback : callback,
                transaction : request.id
            };

            var args = {
                xdr : true,
                method : request.method,
                data : request.data,
                headers : request.headers
            };

            // This might throw an error, propagate it and let the IO know that there was an exception
            this._transport.send(request.url, args, request.id);
        }
1029799
function rewriteDest(dest, src, opts) {
  dest = utils.resolve(dest);
  if (opts.destBase) {
    dest = path.join(opts.destBase, dest);
  }
  if (opts.extDot || opts.hasOwnProperty('ext')) {
    dest = rewriteExt(dest, opts);
  }
  if (typeof opts.rename === 'function') {
    return opts.rename(dest, src, opts);
  }
  return dest;
}
9591
def xdr(self):
        
        tx = Xdr.StellarXDRPacker()
        tx.pack_Transaction(self.to_xdr_object())
        return base64.b64encode(tx.get_buffer())
1195978
function serve(req, res, next) {
    if (req.method !== 'GET' && req.method !== 'HEAD') return next();

    // surprisingly (bug?) express does not auto-decode req.path
    var reqPath = decodeURI(req.path);

    var file$ = self.file$;

    // try straight match
    var spo = file$[reqPath];

    if (!spo && !/\/$|\.[^/]+$/.test(reqPath)) {

      // try adding trailing / and redirect if found
      if (self.trailingSlash) {
        var redir = reqPath + '/';
        spo = file$[redir];
        if (spo) {
          debug('static redirect %s %s', reqPath, redir);
          return res.redirect(302, redir); // use 302 to avoid browser redir caching
        }
      }

      // try extensions
      if (!spo && self.extensions) {
        for (var i=0; i<self.extensions.length; i++) {
          if ((spo = file$[reqPath + self.extensions[i]])) break;
        }
      }
    }

    if (!spo) return next(); // give up

    if (self.noHtmlExtensions && !path.extname(spo.file)) {
      res.setHeader('Content-Type', 'text/html; charset=utf-8');
    }

    debug('static %s%s', reqPath, (reqPath !== spo.file ? ' -> ' + spo.file : ''));

    var doit = function() { send(req, spo.file, spo.sp.sendOpts).pipe(res); };

    if (spo.sp.delay) return u.delay(doit, u.ms(spo.sp.delay));

    doit();
  }
878449
function (req, res, next) {
    var file = target(fss.source(req.path)) || '';
    var type = fss.filetype(file) || 'html';
    var mime = filter.get('mime', fss.filetype(file))();

    if (!fss.exists(file)) {
        res.status(404);
        res.send('404');
        return;
    }

    if (filter.has('compile', type)) {
        pacbot.compile(file, {}, function(content) {
            res.type(mime);
            res.send(content);
        });
    } else {
        next();
    }
}
405319
function replaceDirect(brstars, replacer) {
    replacer(['require'], function(node) {
      var caller = node.parent
      if (!node.arguments.length) return
      if (!caller.arguments) return
      if (!caller.arguments.length) return
      var value = evaluate(caller.arguments[0])
      if (!value) return
      var source = evaluate(node.arguments[0])
      if (!source) return

      source = resolve.sync(source, {
        basedir: dirname
      })

      var index = brstars.indexOf(source)
      if (index === -1) return

      value = require(source)(value)
      replaceCount += 1
      hijack(caller, value)
    })
  }
494381
function redirectToNext(req, res) {
  var redirectTo = req.session.next || '';
  req.session.next = null; // Null it so that we do not use it again.
  res.redirect(redirectTo);
}
727508
def sendp(x, inter=0, loop=0, iface=None, iface_hint=None, count=None, verbose=None, realtime=None, *args, **kargs):
    """"""
    if iface is None and iface_hint is not None:
        iface = conf.route.route(iface_hint)[0]
    __gen_send(conf.L2socket(iface=iface, *args, **kargs), x, inter=inter, loop=loop, count=count, verbose=verbose, realtime=realtime)
49836
function cmd_RETR($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $ftpsock = $this->getUserSock($user);
        if (($file = $this->getFile($user, $cmd[1])) != false)
        {
            $this->send($fd, "150 Connecting to client");
            if ($fp = fopen($file, "r"))
            {
                while (!feof($fp))
                {
                    $cont = fread($fp, 1024);
                    if (!fwrite($ftpsock, $cont)) break;
                }
                if (fclose($fp) and $this->closeUserSock($user))
                {
                    $this->send($fd, "226 File successfully transferred");
                }
                else
                {
                    $this->send($fd, "550 Error during file-transfer");
                }
            }
            else
            {
                $this->send($fd, "550 Can't open " . $cmd[1] . ": Permission denied");
            }
        }
        else
        {
            $this->send($fd, "550 Can't open " . $cmd[1] . ": No such file or directory");
        }
    }
1196441
def sendTo(self, dest, chunkSize):
        
        vol = self.toVol
        paths = self.sink.getPaths(vol)

        if self.sink == dest:
            logger.info("Keep: %s", self)
            self.sink.keep(self)
        else:
            # Log, but don't skip yet, so we can log more detailed skipped actions later
            skipDryRun(logger, dest.dryrun, 'INFO')("Xfer: %s", self)

            receiveContext = dest.receive(self, paths)

            sendContext = self.sink.send(self)

            # try:
            #     receiveContext.metadata['btrfsVersion'] = self.btrfsVersion
            # except AttributeError:
            #     pass

            transfer(sendContext, receiveContext, chunkSize)

        if vol.hasInfo():
            infoContext = dest.receiveVolumeInfo(paths)

            if infoContext is None:
                # vol.writeInfo(sys.stdout)
                pass
            else:
                with infoContext as stream:
                    vol.writeInfo(stream)
226353
def _RedirectToRemoteHelp(self, path):
    """"""
    allowed_chars = set(string.ascii_letters + string.digits + "._-/")
    if not set(path) <= allowed_chars:
      raise RuntimeError("Unusual chars in path %r - "
                         "possible exploit attempt." % path)

    target_path = os.path.join(config.CONFIG["AdminUI.docs_location"], path)

    # We have to redirect via JavaScript to have access to and to preserve the
    # URL hash. We don't know the hash part of the url on the server.
    return werkzeug_wrappers.Response(
        """
<script>
var friendly_hash = window.location.hash;
window.location = '%s' + friendly_hash;
</script>
""" % target_path,
        mimetype="text/html")
598905
function receive($func=NULL,$overwrite=FALSE,$slug=TRUE) {
		$fw=Base::instance();
		$dir=$fw->UPLOADS;
		if (!is_dir($dir))
			mkdir($dir,Base::MODE,TRUE);
		if ($fw->VERB=='PUT') {
			$tmp=$fw->TEMP.$fw->SEED.'.'.$fw->hash(uniqid());
			if (!$fw->RAW)
				$fw->write($tmp,$fw->BODY);
			else {
				$src=@fopen('php://input','r');
				$dst=@fopen($tmp,'w');
				if (!$src || !$dst)
					return FALSE;
				while (!feof($src) &&
					($info=stream_get_meta_data($src)) &&
					!$info['timed_out'] && $str=fgets($src,4096))
					fputs($dst,$str,strlen($str));
				fclose($dst);
				fclose($src);
			}
			$base=basename($fw->URI);
			$file=[
				'name'=>$dir.
					($slug && preg_match('/(.+?)(\.\w+)?$/',$base,$parts)?
						(is_callable($slug)?
							$slug($base):
							($this->slug($parts[1]).
								(isset($parts[2])?$parts[2]:''))):
						$base),
				'tmp_name'=>$tmp,
				'type'=>$this->mime($base),
				'size'=>filesize($tmp)
			];
			return (!file_exists($file['name']) || $overwrite) &&
				(!$func || $fw->call($func,[$file])!==FALSE) &&
				rename($tmp,$file['name']);
		}
		$fetch=function($arr) use(&$fetch) {
			if (!is_array($arr))
				return [$arr];
			$data=[];
			foreach($arr as $k=>$sub)
				$data=array_merge($data,$fetch($sub));
			return $data;
		};
		$out=[];
		foreach ($_FILES as $name=>$item) {
			$files=[];
			foreach ($item as $k=>$mix)
				foreach ($fetch($mix) as $i=>$val)
					$files[$i][$k]=$val;
			foreach ($files as $file) {
				if (empty($file['name']))
					continue;
				$base=basename($file['name']);
				$file['name']=$dir.
					($slug && preg_match('/(.+?)(\.\w+)?$/',$base,$parts)?
						(is_callable($slug)?
							$slug($base,$name):
							($this->slug($parts[1]).
								(isset($parts[2])?$parts[2]:''))):
						$base);
				$out[$file['name']]=!$file['error'] &&
					(!file_exists($file['name']) || $overwrite) &&
					(!$func || $fw->call($func,[$file,$name])!==FALSE) &&
					move_uploaded_file($file['tmp_name'],$file['name']);
			}
		}
		return $out;
	}
406255
public function send()
    {
        try {
            $this->requestParams = common_http_Request::currentRequest()->getParams();
            $this->launchData = LtiLaunchData::fromRequest(common_http_Request::currentRequest());
            $baseUrl = null;

            if ($this->requiresRedirect() && !empty($this->getReturnBaseUrl())) {
                $this->errorRedirectResponse();
            } else {
                echo $this->showLtiErrorPage();
            }
        } catch (\Exception $e) {
            $this->renderer->setTemplate(Template::getTemplate('error/error500.tpl', 'tao'));
            echo $this->renderer->render();
        }
    }
450286
def handle(self, sock, read_data, path, headers):
        ""
        if "://" not in self.redirect_to:
            destination = "http%s://%s" % (
                "s" if headers.get('X-Forwarded-Protocol', headers.get('X-Forwarded-Proto', "")).lower() in ("https", "ssl") else "",
                self.redirect_to
            )
        else:
            destination = self.redirect_to
        try:
            sock.sendall("HTTP/1.0 302 Found\r\nLocation: %s/%s\r\n\r\n" % (
                destination.rstrip("/"),
                path.lstrip("/"),
            ))
        except socket.error, e:
            if e.errno != errno.EPIPE:
                raise
626029
function rewriteFile(args, generator) {
    args.path = args.path || process.cwd();
    const fullPath = path.join(args.path, args.file);

    args.haystack = generator.fs.read(fullPath);
    const body = rewrite(args);
    generator.fs.write(fullPath, body);
}
1171713
function rewriteSeekHead() {
                var
                    seekHeadBuffer = new ArrayBufferDataStream(seekHead.size),
                    oldPos = blobBuffer.pos;
                
                // Write the rewritten SeekHead element's data payload to the stream (don't need to update the id or size)
                writeEBML(seekHeadBuffer, seekHead.dataOffset, seekHead.data);
                
                // And write that through to the file
                blobBuffer.seek(seekHead.dataOffset);
                blobBuffer.write(seekHeadBuffer.getAsDataArray());
    
                blobBuffer.seek(oldPos);
            }