Наследование: FormElement
Пример #1
0
        /// <summary>
        /// Called by loadContents to load an input tag on the form.
        /// </summary>
        /// <param name="index">The index to begin loading at.</param>
        /// <param name="tag">The beginning tag.</param>
        protected void LoadInput(int index, Tag tag)
        {
            String type = tag.GetAttributeValue("type");
            String name = tag.GetAttributeValue("name");
            String value = tag.GetAttributeValue("value");

            var input = new Input(_page);
            input.Type = type;
            input.Name = name;
            input.Value = value;

            if (_lastForm != null)
            {
                _lastForm.AddElement(input);
            }
            else
            {
                _page.AddContent(input);
            }
        }
Пример #2
0
 protected void LoadInput(int index, Tag tag)
 {
     string str2;
     string str3;
     Input input;
     string attributeValue = tag.GetAttributeValue("type");
     goto Label_007E;
     Label_0043:
     if (this._xddf51e0bb7096df0 != null)
     {
         this._xddf51e0bb7096df0.AddElement(input);
         return;
     }
     if ((((uint) index) + ((uint) index)) <= uint.MaxValue)
     {
         this._xbbe2f7d7c86e0379.AddContent(input);
         if (((uint) index) >= 0)
         {
             return;
         }
         goto Label_007E;
     }
     Label_0067:
     input.Type = attributeValue;
     input.Name = str2;
     Label_0075:
     input.Value = str3;
     goto Label_0043;
     Label_007E:
     str2 = tag.GetAttributeValue("name");
     str3 = tag.GetAttributeValue("value");
     input = new Input(this._xbbe2f7d7c86e0379);
     if (8 == 0)
     {
         goto Label_0075;
     }
     if (0 == 0)
     {
         goto Label_0067;
     }
     goto Label_0043;
 }
Пример #3
0
        /// <summary>
        /// Navigate based on a form. Complete and post the form.
        /// </summary>
        /// <param name="form">The form to be posted.</param>
        /// <param name="submit">The submit button on the form to simulate clicking.</param>
        public void Navigate(Form form, Input submit)
        {
            try
            {
#if logging
                if (logger.IsInfoEnabled)
                {
                    logger.Info("Posting a form");
                }
#endif
                Stream istream;
                Stream ostream;
                Uri targetURL;
                WebRequest http = null;

                if (form.Method == Form.FormMethod.Get)
                {
                    ostream = new MemoryStream();
                }
                else
                {
                    http = WebRequest.Create(form.Action.Url);
                    http.Timeout = 30000;
                    http.ContentType = "application/x-www-form-urlencoded";
                    http.Method = "POST";
                    ostream = http.GetRequestStream();
                }

                // add the parameters if present
                var formData = new FormUtility(ostream, null);
                foreach (DocumentRange dr in form.Elements)
                {
                    if (dr is FormElement)
                    {
                        var element = (FormElement) dr;
                        if ((element == submit) || element.AutoSend)
                        {
                            String name = element.Name;
                            String value = element.Value;
                            if (name != null)
                            {
                                if (value == null)
                                {
                                    value = "";
                                }
                                formData.Add(name, value);
                            }
                        }
                    }
                }

                // now execute the command
                if (form.Method == Form.FormMethod.Get)
                {
                    String action = form.Action.Url.ToString();
                    ostream.Close();
                    action += "?";
                    action += ostream.ToString();
                    targetURL = new Uri(action);
                    http = WebRequest.Create(targetURL);
                    var response = (HttpWebResponse) http.GetResponse();
                    istream = response.GetResponseStream();
                }
                else
                {
                    targetURL = form.Action.Url;
                    ostream.Close();
                    var response = (HttpWebResponse) http.GetResponse();
                    istream = response.GetResponseStream();
                }

                Navigate(targetURL, istream);
                istream.Close();
            }
            catch (IOException e)
            {
                throw new BrowseError(e);
            }
        }
Пример #4
0
 public void Navigate(Form form, Input submit)
 {
     try
     {
         Stream requestStream;
         Uri url;
         FormUtility utility;
         string str3;
         HttpWebResponse response;
         WebRequest request = null;
         goto Label_01D3;
     Label_0007:
         requestStream.Close();
         Stream responseStream = ((HttpWebResponse) request.GetResponse()).GetResponseStream();
     Label_0022:
         this.Navigate(url, responseStream);
     Label_002A:
         responseStream.Close();
         if (0 == 0)
         {
             return;
         }
         if (0 == 0)
         {
             goto Label_0057;
         }
     Label_0036:
         responseStream = response.GetResponseStream();
         goto Label_0022;
     Label_0040:
         if (form.Method == Form.FormMethod.Get)
         {
             goto Label_0081;
         }
         url = form.Action.Url;
         goto Label_0007;
     Label_0057:
         response = (HttpWebResponse) WebRequest.Create(url).GetResponse();
         goto Label_0036;
     Label_0074:
         url = new Uri(str3);
         goto Label_0057;
     Label_0081:
         str3 = form.Action.Url.ToString();
         requestStream.Close();
         str3 = str3 + "?" + requestStream.ToString();
         goto Label_0074;
     Label_00BB:
         if (0x7fffffff == 0)
         {
             goto Label_0074;
         }
         goto Label_0040;
     Label_00C7:
         request.Method = "POST";
         requestStream = request.GetRequestStream();
     Label_00D9:
         utility = new FormUtility(requestStream, null);
         if (0 != 0)
         {
             goto Label_002A;
         }
         using (IEnumerator<DocumentRange> enumerator = form.Elements.GetEnumerator())
         {
             DocumentRange range;
             FormElement element;
             string str;
             string str2;
             goto Label_0109;
         Label_00F7:
             if (element.AutoSend)
             {
                 goto Label_0163;
             }
             goto Label_0109;
         Label_0105:
             if (str != null)
             {
                 goto Label_013B;
             }
         Label_0109:
             if (enumerator.MoveNext())
             {
                 goto Label_016E;
             }
             goto Label_0141;
         Label_0117:
             str2 = "";
             if (0 != 0)
             {
                 goto Label_0163;
             }
         Label_0121:
             utility.Add(str, str2);
             goto Label_0109;
         Label_012E:
             if (range is FormElement)
             {
                 goto Label_017D;
             }
             goto Label_0109;
         Label_013B:
             if (str2 != null)
             {
                 goto Label_0121;
             }
             goto Label_0117;
         Label_0141:
             if (0 == 0)
             {
                 goto Label_0040;
             }
             goto Label_016E;
         Label_0146:
             str2 = element.Value;
             if (0 == 0)
             {
                 goto Label_0105;
             }
             if (-2147483648 != 0)
             {
                 goto Label_016E;
             }
         Label_0159:
             if (element != submit)
             {
                 goto Label_00F7;
             }
         Label_0163:
             str = element.Name;
             goto Label_0146;
         Label_016E:
             range = enumerator.Current;
             if (0 != 0)
             {
                 goto Label_0109;
             }
             if (0 == 0)
             {
                 goto Label_012E;
             }
         Label_017D:
             element = (FormElement) range;
             goto Label_0159;
         }
         goto Label_00BB;
     Label_019F:
         requestStream = new MemoryStream();
         goto Label_00D9;
     Label_01AA:
         request = WebRequest.Create(form.Action.Url);
         request.Timeout = 0x7530;
         request.ContentType = "application/x-www-form-urlencoded";
         goto Label_00C7;
     Label_01D3:
         if (form.Method != Form.FormMethod.Get)
         {
             goto Label_01AA;
         }
         goto Label_019F;
     }
     catch (IOException exception)
     {
         throw new BrowseError(exception);
     }
 }