dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System/Net WebRequest.cs,1.4,1.5 WebH


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System/Net WebRequest.cs,1.4,1.5 WebHeaderCollection.cs,1.2,1.3 HttpWebRequest.cs,1.6,1.7 HttpWebResponse.cs,1.1,1.2
Date: Mon, 18 Nov 2002 13:58:08 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/System/Net
In directory subversions:/tmp/cvs-serv23492/System/Net

Modified Files:
        WebRequest.cs WebHeaderCollection.cs HttpWebRequest.cs 
        HttpWebResponse.cs 
Log Message:
start implementing http classes and fix some related bugs


Index: WebRequest.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/WebRequest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** WebRequest.cs       21 Apr 2002 03:24:53 -0000      1.4
--- WebRequest.cs       18 Nov 2002 18:58:04 -0000      1.5
***************
*** 38,42 ****
        private Uri                 requestUri;
        private Int32               timeout;
!       private static Hashtable    prefixes;
  
        protected WebRequest()
--- 38,42 ----
        private Uri                 requestUri;
        private Int32               timeout;
!       private static Hashtable    prefixes=new Hashtable();
  
        protected WebRequest()
***************
*** 115,120 ****
                // the URI that the request is redirected to.
                // throw new SecurityException("requestUriString");
! 
!               return null;
        }
  
--- 115,123 ----
                // the URI that the request is redirected to.
                // throw new SecurityException("requestUriString");
!               if(requestUri.Scheme=="http")
!               {
!                       return new HttpWebRequest(requestUri);
!               }
!               throw new NotSupportedException("CreateDefault");
        }
  

Index: WebHeaderCollection.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/WebHeaderCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** WebHeaderCollection.cs      21 Apr 2002 03:24:53 -0000      1.2
--- WebHeaderCollection.cs      18 Nov 2002 18:58:04 -0000      1.3
***************
*** 23,53 ****
  
  using System;
  using System.Collections.Specialized;
  
  public class WebHeaderCollection : NameValueCollection
  {
!       [TODO]
!       public WebHeaderCollection() {}
!       
!       [TODO]
!       public override void Add(string name, string value) {}
!       
!       [TODO]
!       public void Add(string header) {}
!       
!       [TODO]
!       protected void AddWithoutValidate(string headerName, string 
headerValue) {}
!       
!       [TODO]
!       public override String[] GetValues(string header) { return null; }
!       
!       [TODO]
!       public static bool IsRestricted(string headerName){ return false; }
  
-       [TODO]
-       public override void Remove(string name) {}     
        
!       [TODO]
!       public override void Set(string name, string value) {}
                
  }; //class WebHeaderCollection
--- 23,197 ----
  
  using System;
+ using System.Text;
+ using System.Collections;
  using System.Collections.Specialized;
  
  public class WebHeaderCollection : NameValueCollection
  {
!       private static int[] restrictedHeaders=
!       {
!               "accept".GetHashCode(),
!               "connection".GetHashCode(),
!               "content-length".GetHashCode(),
!               "content-type".GetHashCode(),
!               "date".GetHashCode(),
!               "expect".GetHashCode(),
!               "host".GetHashCode(),
!               "range".GetHashCode(),
!               "referrer".GetHashCode(),
!               "transfer-encoding".GetHashCode(),
!               "user-agent".GetHashCode()
!       };
!       private static char[] tspecials= new char [] 
!                                               {'(', ')', '<', '>', '@',
!                                            ',', ';', ':', '\\', '"',
!                                            '/', '[', ']', '?', '=',
!                                            '{', '}', ' ', '\t'};
!       
!       public WebHeaderCollection() 
!       {       
!               /* nothing here ? */    
!       }
!       
!       public void Add(string header) 
!       {
!               if(header==null)
!               {
!                       throw new ArgumentNullException("header");
!               }
!               int col=header.IndexOf(":");
!               if(col==-1)
!               {
!                       throw new ArgumentException("missing ':' in header"); 
/*TODO:I18n*/
!               }
!               Add(header.Substring(0,col),header.Substring(col+1));
!       }
! 
!       public override void Add(string name, string value) 
!       {
!               if(name==null)
!               {
!                       throw new ArgumentNullException("name");
!               }
!               if(IsRestricted(name))
!               {
!                       throw new ArgumentException("restricted header");/* 
TODO: I18n */
!               }
!               AddWithoutValidate(name,value);
!       }
!       
!       
!       protected void AddWithoutValidate(string headerName, string 
headerValue) 
!       {
!               headerName=headerName.Trim();
!               if(!IsValidHeaderName(headerName))
!               {
!                       throw new ArgumentException("invalid header 
name");/*TODO: I18n*/
!               }
!               if(headerValue==null)headerValue="";
!               else headerValue=headerValue.Trim(); /* remove excess LWS */
!               base.Add(headerName,headerValue); /* add to NameValueCollection 
*/
!       }
  
        
!       public override String[] GetValues(string header) 
!       { 
!               if(header==null)
!               {
!                       throw new ArgumentNullException("header");
!               }
!               return base.GetValues(header);
!       }
!       
!       public static bool IsRestricted(string headerName)
!       { 
!               int hash=headerName.ToLower().GetHashCode(); /* case 
insensitive ? */
!               for(int i=0;i<restrictedHeaders.Length;i++)
!               {
!                       if(restrictedHeaders[i]==hash)return true;
!               }
!               return false;
!       }
! 
!       public override void Remove(string name) 
!       {
!               if(name==null)
!               {
!                       throw new ArgumentNullException("name");
!               }
!               if(!IsValidHeaderName(name))
!               {
!                       throw new ArgumentException("invalid header"); /* TODO: 
I18n */
!               }
!               if(IsRestricted(name))
!               {
!                       throw new ArgumentException("restricted header");/* 
TODO:I18N */
!               }
!               RemoveInternal(name);
!       }       
! 
!       internal void RemoveInternal(String name)
!       {
!               base.Remove(name);
!       }
!       
!       public override void Set(string name, string value) 
!       {
!               if(name==null)
!               {
!                       throw new ArgumentNullException("name");
!               }
!               if(!IsValidHeaderName(name))
!               {
!                       throw new ArgumentException("invalid header 
name");/*TODO: I18n*/
!               }
!               if(IsRestricted(name))
!               {
!                       throw new ArgumentException("restricted header");/* 
TODO: I18n */
!               }
!               SetInternal(name,value);
!       }
! 
!       internal void SetInternal(String name,String value)
!       {
!               if(value==null)value="";
!               else value=value.Trim(); // LWS 
!               base.Set(name,value);
!       }
! 
!       public override String ToString()
!       {
!               StringBuilder builder=new StringBuilder(40*this.Count); 
!               /* an assumption :-) */
!               foreach(String key in this)
!               {
!                       builder.Append(key+": "+this[key]+"\r\n");
!               }
!               return builder.ToString();
!       }
! 
!       // private methods
!       private static bool IsValidHeaderName(String name)
!       {
! 
!         /*  token          = 1*<any CHAR except CTLs or tspecials> 
! 
!           tspecials      = "(" | ")" | "<" | ">" | "@"
!                          | "," | ";" | ":" | "\" | <">
!                          | "/" | "[" | "]" | "?" | "="
!                          | "{" | "}" | SP | HT
!               */
!               if(name == null || name.Length == 0) return false;
!               char[] chars=name.ToCharArray(); 
!               int len=chars.Length;
!               for(int i=0;i< len; i++)
!               {
!                       if(chars[i]< 0x20 || chars[i]>=0x7f) /* no Unicode here 
*/
!                       {
!                               return false;
!                       }
!               }
!               return name.IndexOfAny(tspecials) == -1; 
!       }
                
  }; //class WebHeaderCollection

Index: HttpWebRequest.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/HttpWebRequest.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** HttpWebRequest.cs   29 Oct 2002 18:02:10 -0000      1.6
--- HttpWebRequest.cs   18 Nov 2002 18:58:04 -0000      1.7
***************
*** 37,114 ****
  public class HttpWebRequest : WebRequest
  {
  
!       // Write a UTF-8 string to a stream.  This needs to be
!       // made a lot more efficient using real buffering.
!       private static void Write(Stream stream, String str)
!       {
!               byte[] bytes = Encoding.UTF8.GetBytes(str);
!               stream.Write(bytes, 0, bytes.Length);
!       }
  
!       //Call some sort of constructor from 
!       //System.Net.WebRequest.CreateDefault()
!       private void Connect(Uri address)
        {
!               this.address=address;
!               
!               IPAddress ip=Dns.Resolve(Address.Host).AddressList[0];
!               IPEndPoint ep = new IPEndPoint(ip,Address.Port);
!               server=new Socket(AddressFamily.InterNetwork,SocketType.Stream,
!                                                       ProtocolType.Tcp);
!               server.Connect(ep);
!               outStream=this.GetRequestStream();
!               HttpWebResponse retval=new HttpWebResponse();
!               Write(outStream, this.Method+" "+this.Address.PathAndQuery+" 
HTTP/"+
!                                       
this.protocolVersion.Major+"."+this.protocolVersion.Minor+"\r\n");
!               
!               /* Accept */
!               if(this.Accept!=null)
!                       Write(outStream, "Accept: "+this.Accept+"\r\n");
!               else
!                       Write(outStream, "Accept: */*\r\n");
!       
!               /* Connection */
!               if(this.Connection!=null && this.KeepAlive)
!                       Write(outStream, "Connection: "+this.Connection + " 
Keep-alive \r\n");
!               else if (this.KeepAlive)
!                       Write(outStream, "Connection: Keep-alive\r\n");
!               else
!                       Write(outStream, "Connection: Close\r\n");
!       
!               /* Content-Length */    
!               if(this.ContentLength!=-1)
!                       Write(outStream, "Content-Length: 
"+this.ContentLength+"\r\n");
!                       
!               /* Content-Type */
!               if(this.ContentType!=null)
!                       Write(outStream, "Content-Type: 
"+this.ContentType+"\r\n");
! 
!               if(this.Expect!=null)
!                       Write(outStream, "Expect: "+this.Expect+"\r\n");
! 
!               if(this.IfModifiedSince!=DateTime.MinValue)
!               {
!                       String format="ddd, dd MMM yyyy HH*:mm:ss 
GMTzz";//convert to GMT
!                       Write(outStream, "If-Modified-Since: 
"+this.IfModifiedSince.ToString
!                       (format)+"\r\n");                       
!               }
!               
!               /* Implement User-Auth here */
!               /* use PreAuthenticate & ICredentials to do the job */
!               
!               if(this.Referer!=null)
!                       Write(outStream, "Referer: "+this.Referer+"\r\n");
! 
!               if(this.TransferEncoding!=null)
!                       Write(outStream, "Transfer-Encoding: 
"+this.TransferEncoding+"\r\n");
! 
!               /* User Agent */
!               if(this.UserAgent!=null)
!                       Write(outStream, "User-Agent: "+this.UserAgent+"\r\n");
! 
!               headerSent=true;
!               outStream.Flush();
        }
!       
        [TODO]
        public override void Abort()
--- 37,78 ----
  public class HttpWebRequest : WebRequest
  {
+       private String accept="*/*";
+       private Uri address=null;
+       private Uri originalUri=null;
+       private bool allowAutoRedirect=true;
+       private bool allowWriteStreamBuffering=true;
+       private String connectionGroupName=null;
+       private long contentLength=-1;
+       private HttpContinueDelegate continueDelegate=null;
+       private ICredentials credentials=null;
+       private bool haveResponse=false;
+       private WebHeaderCollection headers=new WebHeaderCollection();
+       private DateTime ifModifiedSince=DateTime.Now;
+       private bool keepAlive=true;
+       private int maximumAutomaticRedirections=5;
+       private string method="GET";
+       private bool pipelined=true;
+       private bool preAuthenticate=false;
+       private Version protocolVersion=System.Net.HttpVersion.Version11;
+       private IWebProxy proxy;
+       private Uri requestUri;
+       private bool sendChunked=false;
+ //    private ServicePoint servicePoint=null;
+       private int timeout;
+       private string mediaType=null;
  
! // other useful variables
!       protected bool headerSent=false; 
!       // so that it is accessible to the nested classes
!       private Stream outStream=null;
!       private WebResponse response=null;
  
!       internal HttpWebRequest(Uri uri)
        {
!               this.address=uri;
!               this.originalUri=uri;
!               this.method="GET";
        }
! 
        [TODO]
        public override void Abort()
***************
*** 126,130 ****
        }
  
-       [TODO] 
        //need internationalisation
        public void AddRange(string rangeSpecifier,int from,int to)
--- 90,93 ----
***************
*** 191,202 ****
        }
        
-       [TODO]
        // put in exception handling 
        // and proxy support 
        public override Stream GetRequestStream()
        {
-               if(outStream==null)throw new WebException("not connected");
                if(!canGetRequestStream())
                        throw new WebException(" not allowed for " + 
this.Method);
                return outStream;
        }
--- 154,167 ----
        }
        
        // put in exception handling 
        // and proxy support 
        public override Stream GetRequestStream()
        {
                if(!canGetRequestStream())
                        throw new WebException(" not allowed for " + 
this.Method);
+               if(outStream==null)
+               {
+                       outStream=new HttpStream(this);
+               }
                return outStream;
        }
***************
*** 207,211 ****
        public override WebResponse GetResponse()
        {
!               return null;
        }
  /*
--- 172,183 ----
        public override WebResponse GetResponse()
        {
!               if(response!=null) return response;
!               if(outStream==null)
!               {
!                       outStream=new HttpStream(this);
!                       /* which is the response stream as well */
!               }
!               this.response=new HttpWebResponse(this,this.outStream);
!               return this.response; 
        }
  /*
***************
*** 216,225 ****
                get
                {
!                       return accept;
                }
                set
                {
!                       if(value !=null)
!                               this.accept=value;
                }
        }
--- 188,197 ----
                get
                {
!                       return headers["Accept"];
                }
                set
                {
!                       CheckHeadersSent();
!                       headers.SetInternal("Accept",value);
                }
        }
***************
*** 262,274 ****
                get
                {
!                       return this.connection;
                }
                set
                {
!                       if(value=="Keep-alive" || value=="Close")
                        {
!                               this.connection=value;
                        }
!                       else throw new ArgumentException("Value NOT keep alive 
or close");
                }
        }
--- 234,254 ----
                get
                {
!                       return headers["Connection"];
                }
                set
                {
!                       CheckHeadersSent();
!                       String str;
!                       if(value!=null)str=value.ToLower().Trim();
!                       if(str==null || str.Length==0)
!                       {
!                               headers.RemoveInternal("Connection");
!                               return;
!                       }
!                       if(str=="keep-alive" || str=="close")
                        {
!                               headers.SetInternal("Connecton",str);
                        }
!                       else throw new ArgumentException("Value NOT keep-alive 
or close");
                }
        }
***************
*** 296,302 ****
                        if(value<0) 
                                throw new 
ArgumentOutOfRangeException("Content-Length < 0");
!                       if(headerSent)
!                               throw new InvalidOperationException(" header 
already sent");
                        this.contentLength=value;
                }
        }
--- 276,282 ----
                        if(value<0) 
                                throw new 
ArgumentOutOfRangeException("Content-Length < 0");
!                       CheckHeadersSent();
                        this.contentLength=value;
+                       
this.headers.SetInternal("Content-Length",value.ToString());
                }
        }
***************
*** 306,314 ****
                get
                {
!                       return this.contentType;
                }
                set
                {
!                       this.contentType=value;
                        // I should really check for <type>/<subtype> in it ;)
                }
--- 286,295 ----
                get
                {
!                       return headers["Content-Type"];
                }
                set
                {
!                       CheckHeadersSent();
!                       this.headers.SetInternal("Content-Type",value);
                        // I should really check for <type>/<subtype> in it ;)
                }
***************
*** 343,353 ****
                get
                {
!                       return this.expect;
                } 
                set
                {
                        if(value.ToLower()=="100-continue") 
!                               throw new ArgumentException("cannot set 
"+value);
!                       this.expect=value;
                }
        }
--- 324,335 ----
                get
                {
!                       return headers["Expect"];
                } 
                set
                {
+                       CheckHeadersSent();
                        if(value.ToLower()=="100-continue") 
!                               throw new ArgumentException("cannot set 
100-continue");
!                       headers.SetInternal("Expect",value);
                }
        }
***************
*** 360,378 ****
                }
        }
! /*
        public override WebHeaderCollection Headers 
        {
                get
                {
!                       return this.
                } 
                set
                {
!                       this.=value;
                }
!       }*/
  
        public DateTime IfModifiedSince 
        {
                get
                {
--- 342,362 ----
                }
        }
! 
        public override WebHeaderCollection Headers 
        {
                get
                {
!                       return this.headers;
                } 
                set
                {
!                       CheckHeadersSent();
!                       this.headers=value;
                }
!       }
  
        public DateTime IfModifiedSince 
        {
+               /* avoid the thunk of Headers */
                get
                {
***************
*** 381,384 ****
--- 365,371 ----
                set
                {
+                       CheckHeadersSent();
+                       String format="ddd, dd MMM yyyy HH*:mm:ss 
GMTzz";//convert to GMT
+                       headers.SetInternal("IfModifiedSince", 
value.ToString(format));
                        this.ifModifiedSince=value;
                }
***************
*** 393,396 ****
--- 380,384 ----
                set
                {
+                       CheckHeadersSent();
                        this.keepAlive=value;
                }
***************
*** 419,422 ****
--- 407,411 ----
                set
                {
+                       CheckHeadersSent();
                        this.mediaType=value;
                }
***************
*** 431,434 ****
--- 420,424 ----
                set
                {
+                       CheckHeadersSent();
                        if(isHTTPMethod(value))
                                this.method=value;
***************
*** 446,449 ****
--- 436,440 ----
                set
                {
+                       CheckHeadersSent();
                        this.pipelined=value;
                }
***************
*** 470,473 ****
--- 461,465 ----
                set
                {
+                       CheckHeadersSent();
                        if(value.Major==1 && (value.Minor==0 || value.Minor==1))
                        {
***************
*** 489,493 ****
                {
                        if(value==null)throw new ArgumentNullException("Proxy 
null");
!                       if(headerSent)throw new 
InvalidOperationException("Header sent");
                        //TODO: implement SecurityException
                        this.proxy=value;
--- 481,485 ----
                {
                        if(value==null)throw new ArgumentNullException("Proxy 
null");
!                       CheckHeadersSent();
                        //TODO: implement SecurityException
                        this.proxy=value;
***************
*** 499,507 ****
                get
                {
!                       return this.referer;
                } 
                set
                {
!                       this.referer=value;
                }
        }
--- 491,500 ----
                get
                {
!                       return headers["Referer"];
                } 
                set
                {
!                       CheckHeadersSent();
!                       headers.SetInternal("Referer",value);
                }
        }
***************
*** 523,527 ****
                set
                {
!                       if(headerSent)throw new InvalidOperationException("data 
sent");
                        this.sendChunked=value;
                }
--- 516,520 ----
                set
                {
!                       CheckHeadersSent();
                        this.sendChunked=value;
                }
***************
*** 556,568 ****
                get
                {
!                       return this.transferEncoding;
                } 
                set
                {
                        if(!this.sendChunked)throw new 
                                InvalidOperationException(" send chunked set");
                        if(String.Compare("Chunked",value,true) == 0)
                                throw new ArgumentException(" cannot chunk it");
!                       this.transferEncoding=value;
                }
        }
--- 549,562 ----
                get
                {
!                       return headers["Transfer-Encoding"];
                } 
                set
                {
+                       CheckHeadersSent();
                        if(!this.sendChunked)throw new 
                                InvalidOperationException(" send chunked set");
                        if(String.Compare("Chunked",value,true) == 0)
                                throw new ArgumentException(" cannot chunk it");
!                       headers.SetInternal("Transfer-Encoding",value);
                }
        }
***************
*** 572,623 ****
                get
                {
!                       return this.userAgent;
                } 
                set
                {
!                       this.userAgent=value;
                }
        }
        
- // my private vars
- // I'm storing all my properties in fields and using properties
- // like I did with my javabean get , set methods
  
!       private String accept="*/*";
!       private Uri address=null;
!       private bool allowAutoRedirect=true;
!       private bool allowWriteStreamBuffering=true;
!       private String connection=null;
!       private String connectionGroupName=null;
!       private long contentLength=-1;
!       private string contentType=null;
!       private HttpContinueDelegate continueDelegate=null;
!       private ICredentials credentials=null;
!       private string expect=null;
!       private bool haveResponse=false;
! /*look manual*/       private WebHeaderCollection headers;
! /*look manual*/       private DateTime ifModifiedSince;
!       private bool keepAlive=true;
! /*look manual*/       private int maximumAutomaticRedirections;
!       private string method="GET";
!       private bool pipelined=true;
!       private bool preAuthenticate=false;
!       private Version protocolVersion=System.Net.HttpVersion.Version11;
! /*look manual*/       private IWebProxy proxy;
!       private string referer=null;
! /*look manual*/       private Uri requestUri;
!       private bool sendChunked=false;
! //    private ServicePoint servicePoint=null;
! /*look manual*/       private int timeout;
!       private string transferEncoding=null;
!       private string userAgent=null;
!       private string mediaType=null;
! 
! // my special vars & methods
!       private bool headerSent=false;
!       private Stream outStream=null;
!       private Stream inStream=null;
!       private Socket server;
!       
        private bool canGetRequestStream()
        {
--- 566,585 ----
                get
                {
!                       return headers["User-Agent"];
                } 
                set
                {
!                       headers.SetInternal("User-Agent",value);
                }
        }
        
  
!       private void CheckHeadersSent()
!       {
!               if(headerSent)
!               {
!                       throw new InvalidOperationException("Headers already 
sent");
!               }
!       }
        private bool canGetRequestStream()
        {
***************
*** 636,640 ****
                return false;
        }
! 
  }//class
  
--- 598,636 ----
                return false;
        }
!       private class HttpStream : NetworkStream
!       {       
!               private HttpWebRequest request;
!               public HttpStream(HttpWebRequest req) :
!                       base(HttpStream.OpenSocket(req),true)
!               {
!                       this.request=req;
!                       SendHeaders();
!               }
!               private static Socket OpenSocket(HttpWebRequest req)
!               {
!                       IPAddress 
ip=Dns.Resolve(req.Address.Host).AddressList[0];
!                       IPEndPoint ep = new IPEndPoint(ip,req.Address.Port);
!                       Socket server=new 
!                                       
Socket(AddressFamily.InterNetwork,SocketType.Stream,
!                                                       ProtocolType.Tcp);
!                       server.Connect(ep);
!                       return server;
!               }
!               private void SendHeaders()
!               {
!                       StreamWriter writer=new StreamWriter(this);
!                       request.headerSent=true; 
!                       /* fake it before sending to allow for atomicity */
!                       String requestString= request.Method+" "+
!                       //              request.Address.PathAndQuery+
!                                       "/"+
!                                       " HTTP/"+request.protocolVersion.Major+
!                                       
"."+request.protocolVersion.Minor+"\r\n";
!                       writer.Write(requestString);
!                       writer.Write(request.Headers.ToString());
!                       writer.Write("\r\n");// terminating CRLF
!                       writer.Flush();
!               }
!       } //internal class
  }//class
  

Index: HttpWebResponse.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/HttpWebResponse.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** HttpWebResponse.cs  21 Apr 2002 03:24:53 -0000      1.1
--- HttpWebResponse.cs  18 Nov 2002 18:58:04 -0000      1.2
***************
*** 24,34 ****
  
  using System;
  
  [TODO]
  public class HttpWebResponse : WebResponse
  {
  
!       // TODO
  
  }; // class HttpWebResponse
  
--- 24,235 ----
  
  using System;
+ using System.Text;
+ using System.IO;
  
  [TODO]
  public class HttpWebResponse : WebResponse
  {
+       HttpWebRequest req=null;
+       Stream stream=null;
+       internal HttpWebResponse(HttpWebRequest request,Stream dataStream)
+       {
+               req=request;
+               stream=dataStream;
+               ProcessRequest();
+       }
+       private void ProcessRequest()
+       {
+               String request=ReadLine();
+       }
+       private void ProcessHeaders()
+       {
+               String s;
+               if((s=ReadLine())!="\r\n")
+               {
+               }
+       }
+       private String ReadLine()
+       {
+               StringBuilder builder = new StringBuilder();
+               int ch;
+               for(;;)
+               {
+                       // Process characters until we reach a line terminator.
+                       ch=stream.ReadByte();
+                       if(ch==-1)
+                       {
+                               break;
+                       }
+                       else if(ch == 13)
+                       {
+                               if((ch=stream.ReadByte())==10)
+                               {
+                                       return builder.ToString();
+                               }
+                               else if(ch==-1)
+                               {
+                                       break;
+                               }
+                               else
+                               {
+                                       builder.Append("\r"+(byte)ch);
+                                       /* that "\r" is added to the stuff */
+                               }
+                       }
+                       else if(ch == 10)
+                       {
+                               // This is an LF line terminator.
+                               return builder.ToString();
+                       }
+                       else
+                       {
+                               builder.Append((char)ch);
+                       }
+               }
+               if(builder.Length!=0) return builder.ToString(); 
+               else return null;
+       }
+       [TODO]
+       public override void Close()
+       {
+       /*TODO*/
+               throw new NotImplementedException();
+       }
  
!       [TODO]
!       protected virtual void Dispose(bool disposing)
!       {
!       /*TODO*/
!               throw new NotImplementedException();
!       }
  
+       [TODO]
+       public override int GetHashCode()
+       {
+       /*TODO*/
+               throw new NotImplementedException();
+       }
+ 
+       [TODO]
+       public string GetResponseHeader(string headerName)
+       {
+       /*TODO*/
+               throw new NotImplementedException();
+       }
+ 
+       [TODO]
+       public override Stream GetResponseStream()
+       {
+       /*TODO*/
+               throw new NotImplementedException();
+       }
+ 
+       [TODO]
+       public string CharacterSet 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public string ContentEncoding 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public override long ContentLength 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public override string ContentType 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public override WebHeaderCollection Headers 
+       {
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public DateTime LastModified 
+       { 
+               get 
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public string Method 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public Version ProtocolVersion 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public override Uri ResponseUri 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public string Server 
+       {
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public HttpStatusCode StatusCode 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
+ 
+       [TODO]
+       public string StatusDescription 
+       { 
+               get
+               {
+                       throw new NotImplementedException();
+               }
+       }
  }; // class HttpWebResponse
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]