Example #1
0
 public static PttWebRequest Create(HttpWebRequest webRequest)
 {
     var pttWebRequest = new PttWebRequest
     {
         Url = webRequest.Address.ToString(),
         Method = webRequest.Method,
         ContentType = webRequest.ContentType,
         Referer = webRequest.Referer,
         Host = webRequest.Host,
         UserAgent = webRequest.UserAgent,
         Accept = webRequest.Accept,
         KeepAlive = webRequest.KeepAlive,
         AllowAutoRedirect = webRequest.AllowAutoRedirect,
         ProtocolVersion = webRequest.ProtocolVersion,
         Timeout = webRequest.Timeout,
         ReadWriteTimeout = webRequest.ReadWriteTimeout,
         AutomaticDecompression = webRequest.AutomaticDecompression
     };
     if (webRequest.Headers != null)
     {
         pttWebRequest.Headers= new WebHeaderCollection();
         foreach (var headerKey in webRequest.Headers.AllKeys)
         {
             try
             {
                 pttWebRequest.Headers.Add(headerKey, webRequest.Headers[headerKey]);
             }
             catch (ArgumentException exception)
             {
                 //this is for the headers that should not be set thru here
             }
         }
     }
     pttWebRequest.CookieContainer = webRequest.CookieContainer;
     pttWebRequest.Proxy = webRequest.Proxy;
     return pttWebRequest;
 }
Example #2
0
 public IPttRequest Clone(PttWebRequest pttWebRequest)
 {
     var result = new PttRequest(Url);
     result.PostValue = PostValue;
     result.Chunked = Chunked;
     result.CookieContainer = CookieContainer;
     result.Proxy = Proxy;
     result.WrappedRequest = pttWebRequest.Convert();
     GC.Collect();//onceki request i memory den ucur
     result.RequestType = RequestType;
     result.EventValidationValue = EventValidationValue;
     result.ViewStateValue = ViewStateValue;
     result.SessionJar = SessionJar;
     return result;
 }