using System; using System.IO; using System.Runtime.Remoting.Messaging; using System.Runtime.Serialization; using System.Threading; namespace System.Net { /// Provides a file system implementation of the class. // Token: 0x02000219 RID: 537 [Serializable] public class FileWebRequest : WebRequest, ISerializable { // Token: 0x06001243 RID: 4675 RVA: 0x000372C4 File Offset: 0x000354C4 internal FileWebRequest(global::System.Uri uri) { this.uri = uri; this.webHeaders = new WebHeaderCollection(); } /// Initializes a new instance of the class from the specified instances of the and classes. /// A object that contains the information that is required to serialize the new object. /// A object that contains the source of the serialized stream that is associated with the new object. // Token: 0x06001244 RID: 4676 RVA: 0x000372FC File Offset: 0x000354FC [Obsolete("Serialization is obsoleted for this type", false)] protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) { this.webHeaders = (WebHeaderCollection)serializationInfo.GetValue("headers", typeof(WebHeaderCollection)); this.proxy = (IWebProxy)serializationInfo.GetValue("proxy", typeof(IWebProxy)); this.uri = (global::System.Uri)serializationInfo.GetValue("uri", typeof(global::System.Uri)); this.connectionGroup = serializationInfo.GetString("connectionGroupName"); this.method = serializationInfo.GetString("method"); this.contentLength = serializationInfo.GetInt64("contentLength"); this.timeout = serializationInfo.GetInt32("timeout"); this.fileAccess = (FileAccess)((int)serializationInfo.GetValue("fileAccess", typeof(FileAccess))); this.preAuthenticate = serializationInfo.GetBoolean("preauthenticate"); } /// Populates a object with the required data to serialize the . /// A that holds the serialized data for the . /// A that contains the destination of the serialized stream that is associated with the new . // Token: 0x06001245 RID: 4677 RVA: 0x00037404 File Offset: 0x00035604 void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { this.GetObjectData(serializationInfo, streamingContext); } /// Gets or sets the name of the connection group for the request. This property is reserved for future use. /// The name of the connection group for the request. // Token: 0x170005F0 RID: 1520 // (get) Token: 0x06001246 RID: 4678 RVA: 0x00037410 File Offset: 0x00035610 // (set) Token: 0x06001247 RID: 4679 RVA: 0x00037418 File Offset: 0x00035618 public override string ConnectionGroupName { get { return this.connectionGroup; } set { this.connectionGroup = value; } } /// Gets or sets the content length of the data being sent. /// The number of bytes of request data being sent. /// /// is less than 0. // Token: 0x170005F1 RID: 1521 // (get) Token: 0x06001248 RID: 4680 RVA: 0x00037424 File Offset: 0x00035624 // (set) Token: 0x06001249 RID: 4681 RVA: 0x0003742C File Offset: 0x0003562C public override long ContentLength { get { return this.contentLength; } set { if (value < 0L) { throw new ArgumentException("The Content-Length value must be greater than or equal to zero.", "value"); } this.contentLength = value; } } /// Gets or sets the content type of the data being sent. This property is reserved for future use. /// The content type of the data being sent. // Token: 0x170005F2 RID: 1522 // (get) Token: 0x0600124A RID: 4682 RVA: 0x00037450 File Offset: 0x00035650 // (set) Token: 0x0600124B RID: 4683 RVA: 0x00037464 File Offset: 0x00035664 public override string ContentType { get { return this.webHeaders["Content-Type"]; } set { this.webHeaders["Content-Type"] = value; } } /// Gets or sets the credentials that are associated with this request. This property is reserved for future use. /// An that contains the authentication credentials that are associated with this request. The default is null. // Token: 0x170005F3 RID: 1523 // (get) Token: 0x0600124C RID: 4684 RVA: 0x00037478 File Offset: 0x00035678 // (set) Token: 0x0600124D RID: 4685 RVA: 0x00037480 File Offset: 0x00035680 public override ICredentials Credentials { get { return this.credentials; } set { this.credentials = value; } } /// Gets a collection of the name/value pairs that are associated with the request. This property is reserved for future use. /// A that contains header name/value pairs associated with this request. // Token: 0x170005F4 RID: 1524 // (get) Token: 0x0600124E RID: 4686 RVA: 0x0003748C File Offset: 0x0003568C public override WebHeaderCollection Headers { get { return this.webHeaders; } } /// Gets or sets the protocol method used for the request. This property is reserved for future use. /// The protocol method to use in this request. // Token: 0x170005F5 RID: 1525 // (get) Token: 0x0600124F RID: 4687 RVA: 0x00037494 File Offset: 0x00035694 // (set) Token: 0x06001250 RID: 4688 RVA: 0x0003749C File Offset: 0x0003569C public override string Method { get { return this.method; } set { if (value == null || value.Length == 0) { throw new ArgumentException("Cannot set null or blank methods on request.", "value"); } this.method = value; } } /// Gets or sets a value that indicates whether to preauthenticate a request. This property is reserved for future use. /// true to preauthenticate; otherwise, false. // Token: 0x170005F6 RID: 1526 // (get) Token: 0x06001251 RID: 4689 RVA: 0x000374D4 File Offset: 0x000356D4 // (set) Token: 0x06001252 RID: 4690 RVA: 0x000374DC File Offset: 0x000356DC public override bool PreAuthenticate { get { return this.preAuthenticate; } set { this.preAuthenticate = value; } } /// Gets or sets the network proxy to use for this request. This property is reserved for future use. /// An that indicates the network proxy to use for this request. // Token: 0x170005F7 RID: 1527 // (get) Token: 0x06001253 RID: 4691 RVA: 0x000374E8 File Offset: 0x000356E8 // (set) Token: 0x06001254 RID: 4692 RVA: 0x000374F0 File Offset: 0x000356F0 public override IWebProxy Proxy { get { return this.proxy; } set { this.proxy = value; } } /// Gets the Uniform Resource Identifier (URI) of the request. /// A that contains the URI of the request. // Token: 0x170005F8 RID: 1528 // (get) Token: 0x06001255 RID: 4693 RVA: 0x000374FC File Offset: 0x000356FC public override global::System.Uri RequestUri { get { return this.uri; } } /// Gets or sets the length of time until the request times out. /// The time, in milliseconds, until the request times out, or the value to indicate that the request does not time out. /// The value specified is less than or equal to zero and is not . // Token: 0x170005F9 RID: 1529 // (get) Token: 0x06001256 RID: 4694 RVA: 0x00037504 File Offset: 0x00035704 // (set) Token: 0x06001257 RID: 4695 RVA: 0x0003750C File Offset: 0x0003570C public override int Timeout { get { return this.timeout; } set { if (value < -1) { throw new ArgumentOutOfRangeException("Timeout can be only set to 'System.Threading.Timeout.Infinite' or a value >= 0."); } this.timeout = value; } } /// Always throws a . /// Always throws a . /// Default credentials are not supported for file Uniform Resource Identifiers (URIs). // Token: 0x170005FA RID: 1530 // (get) Token: 0x06001258 RID: 4696 RVA: 0x00037528 File Offset: 0x00035728 // (set) Token: 0x06001259 RID: 4697 RVA: 0x00037530 File Offset: 0x00035730 public override bool UseDefaultCredentials { get { throw new NotSupportedException(); } set { throw new NotSupportedException(); } } // Token: 0x0600125A RID: 4698 RVA: 0x00037538 File Offset: 0x00035738 private static Exception GetMustImplement() { return new NotImplementedException(); } /// Cancels a request to an Internet resource. // Token: 0x0600125B RID: 4699 RVA: 0x00037540 File Offset: 0x00035740 [global::System.MonoTODO] public override void Abort() { throw FileWebRequest.GetMustImplement(); } /// Begins an asynchronous request for a object to use to write data. /// An that references the asynchronous request. /// The delegate. /// An object that contains state information for this request. /// The property is GET and the application writes to the stream. /// The stream is being used by a previous call to . /// No write stream is available. /// /// /// // Token: 0x0600125C RID: 4700 RVA: 0x00037548 File Offset: 0x00035748 public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state) { if (string.Compare("GET", this.method, true) == 0 || string.Compare("HEAD", this.method, true) == 0 || string.Compare("CONNECT", this.method, true) == 0) { throw new ProtocolViolationException("Cannot send a content-body with this verb-type."); } lock (this) { if (this.asyncResponding || this.webResponse != null) { throw new InvalidOperationException("This operation cannot be performed after the request has been submitted."); } if (this.requesting) { throw new InvalidOperationException("Cannot re-call start of asynchronous method while a previous call is still in progress."); } this.requesting = true; } FileWebRequest.GetRequestStreamCallback getRequestStreamCallback = new FileWebRequest.GetRequestStreamCallback(this.GetRequestStreamInternal); return getRequestStreamCallback.BeginInvoke(callback, state); } /// Ends an asynchronous request for a instance that the application uses to write data. /// A object that the application uses to write data. /// An that references the pending request for a stream. /// /// is null. // Token: 0x0600125D RID: 4701 RVA: 0x00037628 File Offset: 0x00035828 public override Stream EndGetRequestStream(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!asyncResult.IsCompleted) { asyncResult.AsyncWaitHandle.WaitOne(); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; FileWebRequest.GetRequestStreamCallback getRequestStreamCallback = (FileWebRequest.GetRequestStreamCallback)asyncResult2.AsyncDelegate; return getRequestStreamCallback.EndInvoke(asyncResult); } /// Returns a object for writing data to the file system resource. /// A for writing data to the file system resource. /// The request times out. /// /// /// // Token: 0x0600125E RID: 4702 RVA: 0x00037678 File Offset: 0x00035878 public override Stream GetRequestStream() { IAsyncResult asyncResult = this.BeginGetRequestStream(null, null); if (!asyncResult.AsyncWaitHandle.WaitOne(this.timeout, false)) { throw new WebException("The request timed out", WebExceptionStatus.Timeout); } return this.EndGetRequestStream(asyncResult); } // Token: 0x0600125F RID: 4703 RVA: 0x000376BC File Offset: 0x000358BC internal Stream GetRequestStreamInternal() { this.requestStream = new FileWebRequest.FileWebStream(this, FileMode.Create, FileAccess.Write, FileShare.Read); return this.requestStream; } /// Begins an asynchronous request for a file system resource. /// An that references the asynchronous request. /// The delegate. /// An object that contains state information for this request. /// The stream is already in use by a previous call to . /// /// /// // Token: 0x06001260 RID: 4704 RVA: 0x000376D4 File Offset: 0x000358D4 public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state) { lock (this) { if (this.asyncResponding) { throw new InvalidOperationException("Cannot re-call start of asynchronous method while a previous call is still in progress."); } this.asyncResponding = true; } FileWebRequest.GetResponseCallback getResponseCallback = new FileWebRequest.GetResponseCallback(this.GetResponseInternal); return getResponseCallback.BeginInvoke(callback, state); } /// Ends an asynchronous request for a file system resource. /// A that contains the response from the file system resource. /// An that references the pending request for a response. /// /// is null. // Token: 0x06001261 RID: 4705 RVA: 0x00037744 File Offset: 0x00035944 public override WebResponse EndGetResponse(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!asyncResult.IsCompleted) { asyncResult.AsyncWaitHandle.WaitOne(); } AsyncResult asyncResult2 = (AsyncResult)asyncResult; FileWebRequest.GetResponseCallback getResponseCallback = (FileWebRequest.GetResponseCallback)asyncResult2.AsyncDelegate; WebResponse webResponse = getResponseCallback.EndInvoke(asyncResult); this.asyncResponding = false; return webResponse; } /// Returns a response to a file system request. /// A that contains the response from the file system resource. /// The request timed out. /// /// /// // Token: 0x06001262 RID: 4706 RVA: 0x0003779C File Offset: 0x0003599C public override WebResponse GetResponse() { IAsyncResult asyncResult = this.BeginGetResponse(null, null); if (!asyncResult.AsyncWaitHandle.WaitOne(this.timeout, false)) { throw new WebException("The request timed out", WebExceptionStatus.Timeout); } return this.EndGetResponse(asyncResult); } // Token: 0x06001263 RID: 4707 RVA: 0x000377E0 File Offset: 0x000359E0 private WebResponse GetResponseInternal() { if (this.webResponse != null) { return this.webResponse; } lock (this) { if (this.requesting) { this.requestEndEvent = new AutoResetEvent(false); } } if (this.requestEndEvent != null) { this.requestEndEvent.WaitOne(); } FileStream fileStream = null; try { fileStream = new FileWebRequest.FileWebStream(this, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (Exception ex) { throw new WebException(ex.Message, ex); } this.webResponse = new FileWebResponse(this.uri, fileStream); return this.webResponse; } /// Populates a with the data needed to serialize the target object. /// The to populate with data. /// A that specifies the destination for this serialization. // Token: 0x06001264 RID: 4708 RVA: 0x000378B4 File Offset: 0x00035AB4 protected override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { serializationInfo.AddValue("headers", this.webHeaders, typeof(WebHeaderCollection)); serializationInfo.AddValue("proxy", this.proxy, typeof(IWebProxy)); serializationInfo.AddValue("uri", this.uri, typeof(global::System.Uri)); serializationInfo.AddValue("connectionGroupName", this.connectionGroup); serializationInfo.AddValue("method", this.method); serializationInfo.AddValue("contentLength", this.contentLength); serializationInfo.AddValue("timeout", this.timeout); serializationInfo.AddValue("fileAccess", this.fileAccess); serializationInfo.AddValue("preauthenticate", false); } // Token: 0x06001265 RID: 4709 RVA: 0x0003797C File Offset: 0x00035B7C internal void Close() { lock (this) { this.requesting = false; if (this.requestEndEvent != null) { this.requestEndEvent.Set(); } } } // Token: 0x04000FBD RID: 4029 private global::System.Uri uri; // Token: 0x04000FBE RID: 4030 private WebHeaderCollection webHeaders; // Token: 0x04000FBF RID: 4031 private ICredentials credentials; // Token: 0x04000FC0 RID: 4032 private string connectionGroup; // Token: 0x04000FC1 RID: 4033 private long contentLength; // Token: 0x04000FC2 RID: 4034 private FileAccess fileAccess = FileAccess.Read; // Token: 0x04000FC3 RID: 4035 private string method = "GET"; // Token: 0x04000FC4 RID: 4036 private IWebProxy proxy; // Token: 0x04000FC5 RID: 4037 private bool preAuthenticate; // Token: 0x04000FC6 RID: 4038 private int timeout = 100000; // Token: 0x04000FC7 RID: 4039 private Stream requestStream; // Token: 0x04000FC8 RID: 4040 private FileWebResponse webResponse; // Token: 0x04000FC9 RID: 4041 private AutoResetEvent requestEndEvent; // Token: 0x04000FCA RID: 4042 private bool requesting; // Token: 0x04000FCB RID: 4043 private bool asyncResponding; // Token: 0x0200021A RID: 538 internal class FileWebStream : FileStream { // Token: 0x06001266 RID: 4710 RVA: 0x000379D8 File Offset: 0x00035BD8 internal FileWebStream(FileWebRequest webRequest, FileMode mode, FileAccess access, FileShare share) : base(webRequest.RequestUri.LocalPath, mode, access, share) { this.webRequest = webRequest; } // Token: 0x06001267 RID: 4711 RVA: 0x00037A04 File Offset: 0x00035C04 public override void Close() { base.Close(); FileWebRequest fileWebRequest = this.webRequest; this.webRequest = null; if (fileWebRequest != null) { fileWebRequest.Close(); } } // Token: 0x04000FCC RID: 4044 private FileWebRequest webRequest; } // Token: 0x02000315 RID: 789 // (Invoke) Token: 0x06001C2D RID: 7213 private delegate Stream GetRequestStreamCallback(); // Token: 0x02000316 RID: 790 // (Invoke) Token: 0x06001C31 RID: 7217 private delegate WebResponse GetResponseCallback(); } }