Normalize line endings.
[mono.git] / mcs / class / System.Net / System.Net / HttpWebRequest_2_1.cs
1 //
2 // System.Net.HttpWebRequest (for 2.1 profile)
3 //
4 // Authors:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //  Jb Evain  <jbevain@novell.com>
7 //
8 // Copyright (C) 2007, 2009-2010 Novell, Inc (http://www.novell.com)
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 #if NET_2_1
33
34 using System.IO;
35
36 namespace System.Net { 
37
38         // note: the NotImplementedException are needed to match MS implementation
39
40         // note: MS documents a lot of thing for this type but, in truth, all happens
41         // in a type that derive from HttpWebRequest. In Moonlight case this is either
42         // * BrowserHttpWebRequest (browser stack) located in System.Windows.Browser.dll; or
43         // * System.Net.Browser.ClientHttpWebRequest (client stack) located in System.Windows.dll
44
45         public abstract class HttpWebRequest : WebRequest {
46
47                 private WebHeaderCollection headers;
48
49                 protected HttpWebRequest ()
50                 {
51                 }
52
53                 public string Accept {
54                         get { return Headers [HttpRequestHeader.Accept]; }
55                         // this header cannot be set directly inside the collection (hence the helper)
56                         set { Headers.SetHeader ("accept", value); }
57                 }
58
59                 public virtual bool AllowReadStreamBuffering {
60                         get { throw NotImplemented (); }
61                         set { throw NotImplemented (); }
62                 }
63
64                 // new in SL4 RC
65                 public virtual bool AllowWriteStreamBuffering {
66                         get { throw NotImplemented (); }
67                         set { throw NotImplemented (); }
68                 }
69
70                 public override string ContentType {
71                         get { return Headers [HttpRequestHeader.ContentType]; }
72                         // this header cannot be set directly inside the collection (hence the helper)
73                         set { Headers.SetHeader ("content-type", value); }
74                 }
75
76                 public virtual bool HaveResponse {
77                         get { throw NotImplemented (); }
78                 }
79
80                 public override WebHeaderCollection Headers {
81                         get {
82                                 if (headers == null)
83                                         headers = new WebHeaderCollection (true);
84                                 return headers;
85                         }
86                         set {
87                                 // note: this is not a field assignment but a copy (see unit tests)
88                                 // make sure everything we're supplied is valid...
89                                 string[] keys = value.AllKeys;
90                                 foreach (string header in keys) {
91                                         // anything bad will throw
92                                         WebHeaderCollection.ValidateHeader (header);
93                                 }
94                                 // ... before making those values our own
95                                 Headers.Clear ();
96                                 foreach (string header in keys) {
97                                         headers [header] = value [header];
98                                 }
99                         }
100                 }
101
102                 public virtual CookieContainer CookieContainer {
103                         get { throw NotImplemented (); }
104                         set { throw NotImplemented (); }
105                 }
106
107                 public override string Method {
108                         get { throw NotImplemented (); }
109                         set { throw NotImplemented (); }
110                 }
111
112                 public override Uri RequestUri {
113                         get { throw NotImplemented (); }
114                 }
115
116                 // new in SL4 RC
117                 public virtual bool SupportsCookieContainer {
118                         get { return false; }
119                 }
120
121                 public override void Abort ()
122                 {
123                         throw NotImplemented ();
124                 }
125
126                 public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state)
127                 {
128                         throw NotImplemented ();
129                 }
130
131                 public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
132                 {
133                         throw NotImplemented ();
134                 }
135
136                 public override Stream EndGetRequestStream (IAsyncResult asyncResult)
137                 {
138                         throw NotImplemented ();
139                 }
140
141                 public override WebResponse EndGetResponse (IAsyncResult asyncResult)
142                 {
143                         throw NotImplemented ();
144                 }
145
146                 static Exception NotImplemented ()
147                 {
148                         // a bit less IL and hide the "normal" NotImplementedException from corcompare-like tools
149                         return new NotImplementedException ();
150                 }
151         }
152 }
153
154 #endif
155