/// <summary>standard constructor</summary> 
 public AtomFeedParser(IVersionAware v)
     : base() {
     Tracing.TraceCall("constructing AtomFeedParser");
     this.nameTable = new AtomParserNameTable();
     this.nameTable.InitAtomParserNameTable();
     this.versionInfo = new VersionInformation(v);
 }
Beispiel #2
0
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>standard empty constructor</summary>
        //////////////////////////////////////////////////////////////////////
        public AtomFeedParser(IVersionAware v) : base()
        {
            Tracing.TraceCall("constructing AtomFeedParser");
            this.nameTable = new AtomParserNameTable();
            this.nameTable.InitAtomParserNameTable();
            this.versionInfo = new VersionInformation(v);
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>Executes the request and prepares the response stream. Also 
        /// does error checking</summary> 
        /// <param name="retryCounter">indicates the n-th time this is run</param>
        //////////////////////////////////////////////////////////////////////
        protected void Execute(int retryCounter)
        {
            Tracing.TraceCall("GoogleAuth: Execution called");
            try
            {
                CopyRequestData();
                base.Execute();
                if (this.Response is HttpWebResponse)
                {
                    HttpWebResponse response = this.Response as HttpWebResponse;
                    this.responseVersion = new VersionInformation(response.Headers[GDataGAuthRequestFactory.GDataVersion]);
                }
            }
            catch (GDataForbiddenException) 
            {
                Tracing.TraceMsg("need to reauthenticate, got a forbidden back");
                // do it again, once, reset AuthToken first and streams first
                Reset();
                this.factory.GAuthToken = null; 
                CopyRequestData();
                base.Execute();

            }
            catch (GDataRedirectException re)
            {
                // we got a redirect.
                Tracing.TraceMsg("Got a redirect to: " + re.Location);
                // only reset the base, the auth cookie is still valid
                // and cookies are stored in the factory
                if (this.factory.StrictRedirect == true)
                {
                    HttpWebRequest http = this.Request as HttpWebRequest; 
                    if (http != null)
                    {
                        // only redirect for GET, else throw
                        if (http.Method != HttpMethods.Get) 
                        {
                            throw; 
                        }
                    }
                }

                // verify that there is a non empty location string
                if (re.Location.Trim().Length == 0)
                {
                    throw;
                }

                Reset();
                this.TargetUri = new Uri(re.Location);
                CopyRequestData();
                base.Execute();
            }
            catch (GDataRequestException)
            {
                if (retryCounter > this.factory.NumberOfRetries)
                {
                    Tracing.TraceMsg("Got no response object");
                    throw;
                }
                Tracing.TraceMsg("Let's retry this"); 
                // only reset the base, the auth cookie is still valid
                // and cookies are stored in the factory
                Reset();
                this.Execute(retryCounter + 1); 
            }
            catch (Exception e)
            {
                Tracing.TraceCall("*** EXCEPTION " + e.GetType().Name + " CAUGTH ***");
                throw; 
            }
            finally
            {
                if (this.requestCopy != null)
                {
                    this.requestCopy.Close();
                    this.requestCopy = null;
                }
            }
        }
 /// <summary>Constructor.</summary>
 /// <param name="v">the versioninformation to pass </param>
 internal ChangeVersion(IVersionAware v)
 {
     this.v = new VersionInformation(v);
 }
Beispiel #5
0
       /// <summary>Executes the request and prepares the response stream. Also 
       /// does error checking</summary> 
       /// <param name="retryCounter">indicates the n-th time this is run</param>
       protected void Execute(int retryCounter) {
           Tracing.TraceCall("GoogleAuth: Execution called");
           try {n);
               CopyRequestData();
               base.Execute();
            if (this.Response is HttpWebResponse) {
                   HttpWebResponse response = this.Response as HttpWebResponse;
                   this.responseVersion = new VersionInformation(response.Headers[GDataGAuthRequestFactory.GDataVersion]);
               }
           } catch (GDataForbiddenException) {
               Tracing.TraceMsg("need to reauthenticate, got a forbidden back");
               // do it again, once, reset AuthToken first and streams first
               Reset();
               this.factory.GAuthToken = null;n);
               CopyRequestData();
               base.Execute();
          catch (GDataRedirectException re) {
               // we got a redirect.
               Tracing.TraceMsg("Got a redirect to: " + re.Location);
               // only reset the base, the auth cookie is still valid
               // and cookies are stored in the factory
               if (this.factory.StrictRedirect) {
                   HttpWebRequest http = this.Request as HttpWebRequest;
                   if (http != null) {
                       // only redirect for GET, else throw
                       if (http.Method != HttpMethods.Get) {
                           throw;e; 
                       }
                   }
               
               // verify that there is a non empty location string
               if (re.Location.Trim().Length == 0) {
                   throw;
               }
 }
            se.Reset();
               this.TargetUri = new Uri(re.Location);
               CopyRequestData();
               base.Execute();
          catch (GDataRequestException re) {
               HttpWebResponse webResponse = re.Response as HttpWebResponse;
               if (webResponse != null && webResponse.StatusCode != HttpStatusCode.InternalServerError) {
                   Tracing.TraceMsg("Not a server error. Possibly a Bad request or forbidden resource.");
                   Tracing.TraceMsg("We don't want to retry non 500 errors.");
                   throw;
               }  {
               iretryCountering > this.factory.NumberOfRetri    {
                   Tracing.TraceMsNumber of retries exceededect");
                   throw re;
               }
               Tracing.TraceMsg("Let's retry tis"); 
               // only reset the base, the auth cookie is still valid
               // and cookies are stored in the factory
          base.Reset();
               this.ExretryCountertrying
           } catch (Exception e)       {
               Tracing.TraceCall("*** EXCEPTION " + e.GetType().Name + HTCAUGTH ***");
               
           } finally {
               if (this.requestCopy != null) {
                   this.requestCopy.Close();
                   this.requestCopy = null;
               }
           }
       }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>Executes the request and prepares the response stream. Also
        /// does error checking</summary>
        /// <param name="retryCounter">indicates the n-th time this is run</param>
        //////////////////////////////////////////////////////////////////////
        protected void Execute(int retryCounter)
        {
            Tracing.TraceCall("GoogleAuth: Execution called");
            try
            {
                CopyRequestData();
                base.Execute();
                if (this.Response is HttpWebResponse)
                {
                    HttpWebResponse response = this.Response as HttpWebResponse;
                    this.responseVersion = new VersionInformation(response.Headers[GDataGAuthRequestFactory.GDataVersion]);
                }
            }
            catch (GDataForbiddenException)
            {
                Tracing.TraceMsg("need to reauthenticate, got a forbidden back");
                // do it again, once, reset AuthToken first and streams first
                Reset();
                this.factory.GAuthToken = null;
                CopyRequestData();
                base.Execute();
            }
            catch (GDataRedirectException re)
            {
                // we got a redirect.
                Tracing.TraceMsg("Got a redirect to: " + re.Location);
                // only reset the base, the auth cookie is still valid
                // and cookies are stored in the factory
                if (this.factory.StrictRedirect == true)
                {
                    HttpWebRequest http = this.Request as HttpWebRequest;
                    if (http != null)
                    {
                        // only redirect for GET, else throw
                        if (http.Method != HttpMethods.Get)
                        {
                            throw;
                        }
                    }
                }

                // verify that there is a non empty location string
                if (re.Location.Trim().Length == 0)
                {
                    throw;
                }

                Reset();
                this.TargetUri = new Uri(re.Location);
                CopyRequestData();
                base.Execute();
            }
            catch (GDataRequestException)
            {
                if (retryCounter > this.factory.NumberOfRetries)
                {
                    Tracing.TraceMsg("Number of retries exceeded");
                    throw;
                }
                Tracing.TraceMsg("Let's retry this");
                // only reset the base, the auth cookie is still valid
                // and cookies are stored in the factory
                Reset();
                this.Execute(retryCounter + 1);
            }
            catch (Exception e)
            {
                Tracing.TraceCall("*** EXCEPTION " + e.GetType().Name + " CAUGTH ***");
                throw;
            }
            finally
            {
                if (this.requestCopy != null)
                {
                    this.requestCopy.Close();
                    this.requestCopy = null;
                }
            }
        }