Пример #1
0
 /// <summary>
 /// Constructor for a internal proxy's request handler.
 /// </summary>
 /// <param name="proxy">Proxy this request handler belongs to.</param>
 /// <param name="context">The client http context,</param>
 /// <param name="routines">The routines, mapped to the URL that should trigger them.</param>
 /// <param name="defaultMethod">The default method.</param>
 protected InternalRequestHandler(RCProxy proxy, HttpListenerContext context, 
     Dictionary<String, RoutineMethod> routines, RoutineMethod defaultMethod)
     : base(proxy, context, LOCAL_REQUEST_PACKAGE_DEFAULT_TIMEOUT)
 {
     _routines = routines;
     _defaultMethod = defaultMethod;
 }
Пример #2
0
        /// <summary>
        /// Constructor for a RuralCafe Request.
        /// </summary>
        /// <param name="proxy">The proxy for the request.</param>
        /// <param name="request">The request.</param>
        /// <param name="anchorText">Text of the anchor tag.</param>
        /// <param name="referrerUri">URI of the referer.</param>
        /// <param name="body">The body for POSTs, ...</param>
        public RCRequest(RCProxy proxy, HttpWebRequest request, string anchorText,
            string referrerUri, byte[] body)
        {
            _anchorText = anchorText;
            _refererUri = referrerUri.Trim();

            _status = RequestHandler.Status.Pending;

            _webRequest = request;
            _webRequest.Timeout = RequestHandler.WEB_REQUEST_DEFAULT_TIMEOUT;
            _webRequest.Referer = _refererUri;
            _body = body;

            string fileName = CacheManager.UriToFilePath(_webRequest.RequestUri.ToString());
            string hashPath = CacheManager.GetHashPath(fileName);
            // Cache file name like ./GET/2876/627/...
            _relCacheFileName = request.Method + Path.DirectorySeparatorChar + hashPath + fileName;
            _requestId = _relCacheFileName.Replace(Path.DirectorySeparatorChar.ToString(), "");
            _cacheFileName = proxy.CachePath + _relCacheFileName;

            _packageFileName = proxy.PackagesPath + hashPath + fileName + ".gzip";
            _fileSize = 0;

            _proxy = proxy;
            // Root request is this, unless overridden.
            _rootRequest = this;

            _startTime = DateTime.Now;
            _finishTime = _startTime;
        }
Пример #3
0
 /// <summary>
 /// Constructor for a RuralCafe Request.
 /// </summary>
 /// <param name="proxy">The proxy for the request.</param>
 /// <param name="request">The request.</param>
 public RCRequest(RCProxy proxy, HttpWebRequest request)
     : this(proxy, request, "", "", null)
 {
     // do nothing
 }
Пример #4
0
 // benchmarking unused
 //protected DateTime requestReceived;
 //protected DateTime requestCompleted;
 /// <summary>
 /// Constructor for the request.
 /// </summary>
 /// <param name="proxy">Proxy that this request belongs to.</param>
 /// <param name="socket">Socket on which the request came in on.</param>
 public RequestHandler(RCProxy proxy, Socket socket)
 {
     _proxy = proxy;
     _clientSocket = socket;
     if (socket != null)
     {
         _clientAddress = ((IPEndPoint)(socket.RemoteEndPoint)).Address;
     }
 }
Пример #5
0
 /// <summary>
 /// Creates a new CacheManager with a clusters path.
 /// </summary>
 /// <param name="cachePath">The path to the cache.</param>
 /// <param name="clustersPath">The path to the clusters</param>
 /// <param name="proxy">The proxy.</param>
 /// <param name="maxCacheSize">The maximum cache size in bytes.</param>
 public CacheManager(RCProxy proxy, long maxCacheSize, string cachePath, string clustersPath)
     : this(proxy, maxCacheSize, cachePath)
 {
     this._clustersPath = clustersPath;
 }
Пример #6
0
 /// <summary>
 /// Creates a new CacheManager without a clusters path.
 /// </summary>
 /// <param name="cachePath">The path to the cache.</param>
 /// <param name="proxy">The proxy.</param>
 /// <param name="maxCacheSize">The maximum cache size in bytes.</param>
 public CacheManager(RCProxy proxy, long maxCacheSize, string cachePath)
 {
     this._proxy = proxy;
     this._maxCacheSize = maxCacheSize;
     this._cachePath = cachePath;
 }