/// <summary> /// Constructor for a RuralCafe Request. /// </summary> /// <param name="requestHandler">The handler for the request.</param> /// <param name="uri">URI requested.</param> /// <param name="anchorText">text of the anchor tag.</param> /// <param name="referrerUri">URI of the referer.</param> public RCRequest(RequestHandler requestHandler, string uri, string anchorText, string referrerUri) { _uri = uri.Trim(); _anchorText = anchorText; _refererUri = referrerUri.Trim(); _fileName = UriToFilePath(_uri); _hashPath = GetHashPath(_fileName); _itemId = _hashPath.Replace(Path.DirectorySeparatorChar.ToString(), ""); _cacheFileName = requestHandler.Proxy.CachePath + _hashPath + _fileName; /* if (IsCompressed()) { _cacheFileName = _cacheFileName + ".bz2"; }*/ _status = (int)RequestHandler.Status.Pending; _webRequest = (HttpWebRequest)WebRequest.Create(_uri); _webRequest.Timeout = RequestHandler.WEB_REQUEST_DEFAULT_TIMEOUT; _fileSize = 0; _requestHandler = requestHandler; _startTime = DateTime.Now; _finishTime = _startTime; }
/// <summary> /// Adds the request handler to the global queue. /// </summary> /// <param name="requestHandler">The request handler to queue.</param> /// <returns>The request handler in the queue. /// Either the parameter or an already exiting equivalent RH in the queue.</returns> protected RequestHandler AddRequestGlobalQueue(RequestHandler requestHandler) { // add the request to the global queue lock (_globalRequests) { // queue new request _globalRequests.Add(requestHandler); return requestHandler; } }
/// <summary> /// Constructor for a RuralCafe Request. /// </summary> /// <param name="requestHandler">The handler for the request.</param> /// <param name="itemId">requestId.</param> public RCRequest(RequestHandler requestHandler, string uri) : this(requestHandler, uri, "", "") { // do nothing }
/// <summary> /// Adds the request handler to the global queue, no dups. /// </summary> /// <param name="requestHandler">The request handler to queue.</param> /// <returns>The request handler in the queue. /// Either the parameter or an already exiting equivalent RH in the queue.</returns> protected RequestHandler AddRequestGlobalQueue(RequestHandler requestHandler) { // add the request to the global queue lock (_globalRequests) { if (_globalRequests.Contains(requestHandler)) { // get contained rh and return it return _globalRequests[_globalRequests.IndexOf(requestHandler)]; } else { // queue new request _globalRequests.Add(requestHandler); return requestHandler; } } }