[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System/Net HttpWebRequest.cs,1.7,1.8
From: |
Gopal.V <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System/Net HttpWebRequest.cs,1.7,1.8 HttpWebResponse.cs,1.2,1.3 WebHeaderCollection.cs,1.3,1.4 |
Date: |
Mon, 18 Nov 2002 16:44:49 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System/Net
In directory subversions:/tmp/cvs-serv23869/System/Net
Modified Files:
HttpWebRequest.cs HttpWebResponse.cs WebHeaderCollection.cs
Log Message:
Fill in HttpWebRespose and some minor bugs as well
Index: HttpWebRequest.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/HttpWebRequest.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** HttpWebRequest.cs 18 Nov 2002 18:58:04 -0000 1.7
--- HttpWebRequest.cs 18 Nov 2002 21:44:45 -0000 1.8
***************
*** 167,173 ****
}
! [TODO]
! //needs some clarification on the implementation
! //really need some doubts cleared
public override WebResponse GetResponse()
{
--- 167,171 ----
}
! //need some doubts cleared
public override WebResponse GetResponse()
{
***************
*** 176,184 ****
{
outStream=new HttpStream(this);
! /* which is the response stream as well */
}
this.response=new HttpWebResponse(this,this.outStream);
return this.response;
}
/*
* Implement the Checks for Setting values
--- 174,193 ----
{
outStream=new HttpStream(this);
! // which is the response stream as well
}
this.response=new HttpWebResponse(this,this.outStream);
+ this.haveResponse=true; // I hope this is correct
return this.response;
}
+
+ public void Close()
+ {
+ if(outStream!=null)
+ {
+ outStream.Close();
+ outStream=null;
+ }
+ }
+
/*
* Implement the Checks for Setting values
***************
*** 623,632 ****
/* 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();
--- 632,642 ----
/* 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());
+ /* FIXME: remove when headers work */
+ writer.Write("Host: localhost\r\n");
writer.Write("\r\n");// terminating CRLF
writer.Flush();
Index: HttpWebResponse.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/HttpWebResponse.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** HttpWebResponse.cs 18 Nov 2002 18:58:04 -0000 1.2
--- HttpWebResponse.cs 18 Nov 2002 21:44:45 -0000 1.3
***************
*** 24,35 ****
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)
{
--- 24,40 ----
using System;
using System.IO;
+ using System.Text;
+ using System.Globalization;
public class HttpWebResponse : WebResponse
{
! private HttpWebRequest req=null;
! private Stream stream=null;
! private WebHeaderCollection headers=new WebHeaderCollection();
! private Version version=null;
! private HttpStatusCode code=0;
! private String desc=null;
! private long contentLength; /* FIXME: Remove when headers work */
internal HttpWebResponse(HttpWebRequest request,Stream dataStream)
{
***************
*** 37,50 ****
stream=dataStream;
ProcessRequest();
}
private void ProcessRequest()
{
! String request=ReadLine();
}
private void ProcessHeaders()
{
! String s;
! if((s=ReadLine())!="\r\n")
{
}
}
--- 42,82 ----
stream=dataStream;
ProcessRequest();
+ headers.SetStrict(false); /* none of the restrictions of
Request */
+ ProcessHeaders();
}
private void ProcessRequest()
{
! String response=ReadLine();
! int i=response.IndexOfAny(new char[]{' ','\t'});
! if(i==-1) throw new WebException("Invalid Response");
! switch(response.Substring(0,i))
! {
! case "HTTP/1.0":
! version=HttpVersion.Version10;
! break;
! case "HTTP/1.1":
! version=HttpVersion.Version11;
! break;
! default:
! throw new WebException("Unknown Protocol
version");
! }
! response=response.Substring(i+1);
! i=response.IndexOfAny(new char[]{' ','\t'});
! if(i==-1) throw new WebException("Invalid Response");
! code=(HttpStatusCode) Int32.Parse(response.Substring(0,i));
! response=response.Substring(i+1);
! desc=response;
}
private void ProcessHeaders()
{
! /* sometimes servers tend to send plain "\n"s */
! for(String s=ReadLine();s.Trim()!="";s=ReadLine())
{
+ // headers.Add(s); // FIXME: after arraylist is fixed
+ if(s.StartsWith("Content-Length: "))
+ {
+ this.contentLength=
+ Int64.Parse((s.Substring("Content-Length:
".Length)).Trim());
+ }
}
}
***************
*** 90,98 ****
else return null;
}
- [TODO]
public override void Close()
{
! /*TODO*/
! throw new NotImplementedException();
}
--- 122,128 ----
else return null;
}
public override void Close()
{
! this.req.Close();
}
***************
*** 111,233 ****
}
- [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();
}
}
--- 141,255 ----
}
public string GetResponseHeader(string headerName)
{
! return headers[headerName];
}
public override Stream GetResponseStream()
{
! return stream;
}
public string CharacterSet
{
get
{
! return "ISO-8859-1";
! /*
! TODO: figure out how to get correct
CharacterSet,
! all headers don't have charsets
! */
}
}
public string ContentEncoding
{
get
{
! return headers["Content-Encoding"];
}
}
public override long ContentLength
{
get
{
! return contentLength;
! //return Int64.Parse(headers["Content-Length"]); //
FIXME
}
}
public override string ContentType
{
get
{
! return headers["Content-Type"];
}
}
public override WebHeaderCollection Headers
{
get
{
! return headers;
}
}
public DateTime LastModified
{
get
{
! String format="ddd, dd MMM yyyy HH*:mm:ss
GMTzz";//convert to GMT
! return
DateTime.ParseExact(headers["Last-Modified"],format,null,
! DateTimeStyles.None);
}
}
public string Method
{
get
{
! return req.Method;
}
}
public Version ProtocolVersion
{
get
{
! return version;
}
}
! /* TODO : clarify how redirects work */
public override Uri ResponseUri
{
get
{
! return req.Address;
}
}
public string Server
{
get
{
! return headers["Server"];
}
}
public HttpStatusCode StatusCode
{
get
{
! return code;
}
}
public string StatusDescription
{
get
{
! return desc;
}
}
Index: WebHeaderCollection.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/WebHeaderCollection.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** WebHeaderCollection.cs 18 Nov 2002 18:58:04 -0000 1.3
--- WebHeaderCollection.cs 18 Nov 2002 21:44:45 -0000 1.4
***************
*** 49,56 ****
--- 49,61 ----
'{', '}', ' ', '\t'};
+ private bool strict=true;
public WebHeaderCollection()
{
/* nothing here ? */
}
+ internal void SetStrict(bool strict)
+ {
+ this.strict=strict;
+ }
public void Add(string header)
***************
*** 74,78 ****
throw new ArgumentNullException("name");
}
! if(IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO: I18n */
--- 79,83 ----
throw new ArgumentNullException("name");
}
! if(strict && IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO: I18n */
***************
*** 124,128 ****
throw new ArgumentException("invalid header"); /* TODO:
I18n */
}
! if(IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO:I18N */
--- 129,133 ----
throw new ArgumentException("invalid header"); /* TODO:
I18n */
}
! if(strict && IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO:I18N */
***************
*** 146,150 ****
throw new ArgumentException("invalid header
name");/*TODO: I18n*/
}
! if(IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO: I18n */
--- 151,155 ----
throw new ArgumentException("invalid header
name");/*TODO: I18n*/
}
! if(strict && IsRestricted(name))
{
throw new ArgumentException("restricted header");/*
TODO: I18n */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System/Net HttpWebRequest.cs,1.7,1.8 HttpWebResponse.cs,1.2,1.3 WebHeaderCollection.cs,1.3,1.4,
Gopal.V <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/System Uri.cs,1.30,1.31 UriBuilder.cs,1.9,1.10 System.build,1.8,1.9
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_semantics.tc,1.9,1.10
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/System Uri.cs,1.30,1.31 UriBuilder.cs,1.9,1.10 System.build,1.8,1.9
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_semantics.tc,1.9,1.10
- Index(es):