[Mono.Security]: Add new MonoTlsProviderFactory.CreateHttpListener() API to create...
[mono.git] / mcs / class / System / System.Net / WebAsyncResult.cs
1 //
2 // System.Net.WebAsyncResult
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System.IO;
32 using System.Threading;
33
34 namespace System.Net
35 {
36         class WebAsyncResult : SimpleAsyncResult
37         {
38                 int nbytes;
39                 IAsyncResult innerAsyncResult;
40                 HttpWebResponse response;
41                 Stream writeStream;
42                 byte [] buffer;
43                 int offset;
44                 int size;
45                 public bool EndCalled;
46                 public bool AsyncWriteAll;
47                 public HttpWebRequest AsyncObject;
48
49                 public WebAsyncResult (AsyncCallback cb, object state)
50                         : base (cb, state)
51                 {
52                 }
53
54                 public WebAsyncResult (HttpWebRequest request, AsyncCallback cb, object state)
55                         : base (cb, state)
56                 {
57                         this.AsyncObject = request;
58                 }
59
60                 public WebAsyncResult (AsyncCallback cb, object state, byte [] buffer, int offset, int size)
61                         : base (cb, state)
62                 {
63                         this.buffer = buffer;
64                         this.offset = offset;
65                         this.size = size;
66                 }
67
68                 internal void Reset ()
69                 {
70                         this.nbytes = 0;
71                         this.response = null;
72                         this.buffer = null;
73                         this.offset = 0;
74                         this.size = 0;
75                         Reset_internal ();
76                 }
77
78                 internal void SetCompleted (bool synch, int nbytes)
79                 {
80                         this.nbytes = nbytes;
81                         SetCompleted_internal (synch);
82                 }
83                 
84                 internal void SetCompleted (bool synch, Stream writeStream)
85                 {
86                         this.writeStream = writeStream;
87                         SetCompleted_internal (synch);
88                 }
89                 
90                 internal void SetCompleted (bool synch, HttpWebResponse response)
91                 {
92                         this.response = response;
93                         SetCompleted_internal (synch);
94                 }
95
96                 internal void DoCallback ()
97                 {
98                         DoCallback_internal ();
99                 }
100                 
101                 internal int NBytes {
102                         get { return nbytes; }
103                         set { nbytes = value; }
104                 }
105
106                 internal IAsyncResult InnerAsyncResult {
107                         get { return innerAsyncResult; }
108                         set { innerAsyncResult = value; }
109                 }
110
111                 internal Stream WriteStream {
112                         get { return writeStream; }
113                 }
114
115                 internal HttpWebResponse Response {
116                         get { return response; }
117                 }
118
119                 internal byte [] Buffer {
120                         get { return buffer; }
121                 }
122
123                 internal int Offset {
124                         get { return offset; }
125                 }
126
127                 internal int Size {
128                         get { return size; }
129                 }
130         }
131 }
132