HttpResponse.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. //
  2. // System.Web.HttpResponse
  3. //
  4. // Authors:
  5. // Patrik Torstensson ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. // (c) 2002 Ximian, Inc. (http://www.ximian.com)
  9. //
  10. using System;
  11. using System.Collections;
  12. using System.Globalization;
  13. using System.IO;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Web.Util;
  17. namespace System.Web
  18. {
  19. public sealed class HttpResponse
  20. {
  21. // Chunked encoding static helpers
  22. static byte [] s_arrChunkSuffix = { 10, 13 };
  23. static byte [] s_arrChunkEnd = { 10 , 13 };
  24. static string s_sChunkedPrefix = "\r\n";
  25. ArrayList _Headers;
  26. bool _bClientDisconnected;
  27. bool _bSuppressHeaders;
  28. bool _bSuppressContent;
  29. bool _bChunked;
  30. bool _bEnded;
  31. bool _bBuffering;
  32. bool _bHeadersSent;
  33. bool _bFlushing;
  34. long _lContentLength;
  35. int _iStatusCode;
  36. bool _ClientDisconnected;
  37. string _sContentType;
  38. string _sCacheControl;
  39. string _sTransferEncoding;
  40. string _sCharset;
  41. string _sStatusDescription;
  42. HttpCookieCollection _Cookies;
  43. HttpCachePolicy _CachePolicy;
  44. Encoding _ContentEncoding;
  45. HttpContext _Context;
  46. HttpWriter _Writer;
  47. TextWriter _TextWriter;
  48. HttpWorkerRequest _WorkerRequest;
  49. ArrayList fileDependencies;
  50. public HttpResponse (TextWriter output)
  51. {
  52. _bBuffering = true;
  53. _bFlushing = false;
  54. _bHeadersSent = false;
  55. _Headers = new ArrayList ();
  56. _sContentType = "text/html";
  57. _iStatusCode = 200;
  58. _sCharset = null;
  59. _sCacheControl = null;
  60. _lContentLength = 0;
  61. _bSuppressContent = false;
  62. _bSuppressHeaders = false;
  63. _bClientDisconnected = false;
  64. _bChunked = false;
  65. _TextWriter = output;
  66. }
  67. internal HttpResponse (HttpWorkerRequest WorkerRequest, HttpContext Context)
  68. {
  69. _Context = Context;
  70. _WorkerRequest = WorkerRequest;
  71. _bBuffering = true;
  72. _bFlushing = false;
  73. _bHeadersSent = false;
  74. _Headers = new ArrayList ();
  75. _sContentType = "text/html";
  76. _iStatusCode = 200;
  77. _sCharset = null;
  78. _sCacheControl = null;
  79. _lContentLength = 0;
  80. _bSuppressContent = false;
  81. _bSuppressHeaders = false;
  82. _bClientDisconnected = false;
  83. _bChunked = false;
  84. _Writer = new HttpWriter (this);
  85. _TextWriter = _Writer;
  86. }
  87. internal Encoder ContentEncoder
  88. {
  89. get {
  90. return ContentEncoding.GetEncoder ();
  91. }
  92. }
  93. internal void FinalFlush ()
  94. {
  95. Flush (true);
  96. }
  97. internal void DoFilter ()
  98. {
  99. if (null != _Writer)
  100. _Writer.FilterData (true);
  101. }
  102. [MonoTODO("We need to add cache headers also")]
  103. private ArrayList GenerateHeaders ()
  104. {
  105. ArrayList oHeaders = new ArrayList (_Headers.ToArray ());
  106. oHeaders.Add (new HttpResponseHeader ("X-Powered-By", "Mono"));
  107. // save culture info, we need us info here
  108. CultureInfo oSavedInfo = Thread.CurrentThread.CurrentCulture;
  109. Thread.CurrentThread.CurrentCulture = new CultureInfo (0x0409);
  110. string date = DateTime.Now.ToUniversalTime ().ToString ("ddd, d MMM yyyy HH:mm:ss ");
  111. oHeaders.Add (new HttpResponseHeader ("Date", date + "GMT"));
  112. Thread.CurrentThread.CurrentCulture = oSavedInfo;
  113. if (_lContentLength > 0) {
  114. oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderContentLength,
  115. _lContentLength.ToString ()));
  116. }
  117. if (_sContentType != null) {
  118. if (_sContentType.IndexOf ("charset=") == -1) {
  119. if (Charset.Length == 0) {
  120. Charset = ContentEncoding.HeaderName;
  121. }
  122. // Time to build our string
  123. if (Charset.Length > 0) {
  124. _sContentType += "; charset=" + Charset;
  125. }
  126. }
  127. oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderContentType,
  128. _sContentType));
  129. }
  130. if (_sCacheControl != null) {
  131. oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderPragma,
  132. _sCacheControl));
  133. }
  134. if (_sTransferEncoding != null) {
  135. oHeaders.Add (new HttpResponseHeader (HttpWorkerRequest.HeaderTransferEncoding,
  136. _sTransferEncoding));
  137. }
  138. if (_Cookies != null) {
  139. int length = _Cookies.Count;
  140. for (int i = 0; i < length; i++) {
  141. oHeaders.Add (_Cookies.Get (i).GetCookieHeader ());
  142. }
  143. }
  144. return oHeaders;
  145. }
  146. private void SendHeaders ()
  147. {
  148. _WorkerRequest.SendStatus (StatusCode, StatusDescription);
  149. ArrayList oHeaders = GenerateHeaders ();
  150. foreach (HttpResponseHeader oHeader in oHeaders)
  151. oHeader.SendContent (_WorkerRequest);
  152. _bHeadersSent = true;
  153. }
  154. public string Status
  155. {
  156. get {
  157. return String.Format ("{0} {1}", StatusCode, StatusDescription);
  158. }
  159. set {
  160. string sMsg = "OK";
  161. int iCode = 200;
  162. try {
  163. iCode = Int32.Parse (value.Substring (0, value.IndexOf (' ')));
  164. sMsg = value.Substring (value.IndexOf (' ') + 1);
  165. } catch (Exception) {
  166. throw new HttpException ("Invalid status string");
  167. }
  168. StatusCode = iCode;
  169. StatusDescription = sMsg;
  170. }
  171. }
  172. [MonoTODO()]
  173. public void AddCacheItemDependencies (ArrayList cacheKeys)
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. [MonoTODO()]
  178. public void AddCacheItemDependency(string cacheKey)
  179. {
  180. throw new NotImplementedException ();
  181. }
  182. public void AddFileDependencies (ArrayList filenames)
  183. {
  184. if (filenames == null || filenames.Count == 0)
  185. return;
  186. if (fileDependencies == null) {
  187. fileDependencies = (ArrayList) filenames.Clone ();
  188. return;
  189. }
  190. foreach (string fn in filenames)
  191. AddFileDependency (fn);
  192. }
  193. public void AddFileDependency (string filename)
  194. {
  195. if (fileDependencies == null)
  196. fileDependencies = new ArrayList ();
  197. fileDependencies.Add (filename);
  198. }
  199. public void AddHeader (string name, string value)
  200. {
  201. AppendHeader(name, value);
  202. }
  203. public void AppendCookie (HttpCookie cookie)
  204. {
  205. if (_bHeadersSent)
  206. throw new HttpException ("Cannot append cookies after HTTP headers have been sent");
  207. Cookies.Add (cookie);
  208. }
  209. [MonoTODO()]
  210. public void AppendToLog (string param)
  211. {
  212. throw new NotImplementedException ();
  213. }
  214. public string ApplyAppPathModifier (string virtualPath)
  215. {
  216. if (virtualPath == null)
  217. return null;
  218. if (UrlUtils.IsRelativeUrl (virtualPath)) {
  219. virtualPath = UrlUtils.Combine (_Context.Request.RootVirtualDir, virtualPath);
  220. } else if (UrlUtils.IsRooted (virtualPath)) {
  221. virtualPath = UrlUtils.Reduce (virtualPath);
  222. }
  223. return virtualPath;
  224. }
  225. public bool Buffer
  226. {
  227. get {
  228. return BufferOutput;
  229. }
  230. set {
  231. BufferOutput = value;
  232. }
  233. }
  234. public bool BufferOutput
  235. {
  236. get {
  237. return _bBuffering;
  238. }
  239. set {
  240. if (_Writer != null)
  241. _Writer.Update ();
  242. _bBuffering = value;
  243. }
  244. }
  245. public HttpCachePolicy Cache
  246. {
  247. get {
  248. if (null == _CachePolicy)
  249. _CachePolicy = new HttpCachePolicy ();
  250. return _CachePolicy;
  251. }
  252. }
  253. [MonoTODO("Set status in the cache policy")]
  254. public string CacheControl
  255. {
  256. get {
  257. return _sCacheControl;
  258. }
  259. set {
  260. if (_bHeadersSent)
  261. throw new HttpException ("Headers has been sent to the client");
  262. _sCacheControl = value;
  263. }
  264. }
  265. public string Charset
  266. {
  267. get {
  268. if (null == _sCharset)
  269. _sCharset = ContentEncoding.WebName;
  270. return _sCharset;
  271. }
  272. set {
  273. if (_bHeadersSent)
  274. throw new HttpException ("Headers has been sent to the client");
  275. _sCharset = value;
  276. }
  277. }
  278. public Encoding ContentEncoding
  279. {
  280. get {
  281. if (_ContentEncoding == null)
  282. _ContentEncoding = WebEncoding.Encoding;
  283. return _ContentEncoding;
  284. }
  285. set {
  286. if (value == null)
  287. throw new ArgumentException ("Can't set a null as encoding");
  288. _ContentEncoding = value;
  289. if (_Writer != null)
  290. _Writer.Update ();
  291. }
  292. }
  293. public string ContentType
  294. {
  295. get {
  296. return _sContentType;
  297. }
  298. set {
  299. if (_bHeadersSent)
  300. throw new HttpException ("Headers has been sent to the client");
  301. _sContentType = value;
  302. }
  303. }
  304. public HttpCookieCollection Cookies
  305. {
  306. get {
  307. if (null == _Cookies)
  308. _Cookies = new HttpCookieCollection (this, false);
  309. return _Cookies;
  310. }
  311. }
  312. [MonoTODO("Set expires in the cache policy")]
  313. public int Expires
  314. {
  315. get {
  316. throw new NotImplementedException ();
  317. }
  318. set {
  319. throw new NotImplementedException ();
  320. }
  321. }
  322. [MonoTODO("Set expiresabsolute in the cache policy")]
  323. public DateTime ExpiresAbsolute
  324. {
  325. get {
  326. throw new NotImplementedException ();
  327. }
  328. set {
  329. throw new NotImplementedException ();
  330. }
  331. }
  332. public Stream Filter
  333. {
  334. get {
  335. if (_Writer != null)
  336. return _Writer.GetActiveFilter ();
  337. return null;
  338. }
  339. set {
  340. if (_Writer == null)
  341. throw new HttpException ("Filtering is not allowed");
  342. _Writer.ActivateFilter (value);
  343. }
  344. }
  345. public bool IsClientConnected
  346. {
  347. get {
  348. if (_ClientDisconnected)
  349. return false;
  350. if (null != _WorkerRequest && (!_WorkerRequest.IsClientConnected ())) {
  351. _ClientDisconnected = false;
  352. return false;
  353. }
  354. return true;
  355. }
  356. }
  357. public TextWriter Output
  358. {
  359. get {
  360. return _TextWriter;
  361. }
  362. }
  363. public Stream OutputStream
  364. {
  365. get {
  366. if (_Writer == null)
  367. throw new HttpException ("an Output stream not available when " +
  368. "running with custom text writer");
  369. return _Writer.OutputStream;
  370. }
  371. }
  372. public string StatusDescription
  373. {
  374. get {
  375. if (null == _sStatusDescription)
  376. _sStatusDescription =
  377. HttpWorkerRequest.GetStatusDescription (_iStatusCode);
  378. return _sStatusDescription;
  379. }
  380. set {
  381. if (_bHeadersSent)
  382. throw new HttpException ("Headers has been sent to the client");
  383. _sStatusDescription = value;
  384. }
  385. }
  386. public int StatusCode
  387. {
  388. get {
  389. return _iStatusCode;
  390. }
  391. set {
  392. if (_bHeadersSent)
  393. throw new HttpException ("Headers has been sent to the client");
  394. _sStatusDescription = null;
  395. _iStatusCode = value;
  396. }
  397. }
  398. public bool SuppressContent
  399. {
  400. get {
  401. return _bSuppressContent;
  402. }
  403. set {
  404. if (_bHeadersSent)
  405. throw new HttpException ("Headers has been sent to the client");
  406. _bSuppressContent = true;
  407. }
  408. }
  409. public HttpRequest Request
  410. {
  411. get {
  412. if (_Context == null)
  413. return null;
  414. return _Context.Request;
  415. }
  416. }
  417. internal void AppendHeader (int iIndex, string value)
  418. {
  419. if (_bHeadersSent)
  420. throw new HttpException ("Headers has been sent to the client");
  421. switch (iIndex) {
  422. case HttpWorkerRequest.HeaderContentLength:
  423. _lContentLength = Int64.Parse (value);
  424. break;
  425. case HttpWorkerRequest.HeaderContentEncoding:
  426. _sContentType = value;
  427. break;
  428. case HttpWorkerRequest.HeaderTransferEncoding:
  429. _sTransferEncoding = value;
  430. if (value.Equals ("chunked")) {
  431. _bChunked = true;
  432. } else {
  433. _bChunked = false;
  434. }
  435. break;
  436. case HttpWorkerRequest.HeaderPragma:
  437. _sCacheControl = value;
  438. break;
  439. default:
  440. _Headers.Add (new HttpResponseHeader (iIndex, value));
  441. break;
  442. }
  443. }
  444. public void AppendHeader (string name, string value)
  445. {
  446. if (_bHeadersSent)
  447. throw new HttpException ("Headers has been sent to the client");
  448. switch (name.ToLower ()) {
  449. case "content-length":
  450. _lContentLength = Int64.Parse (value);
  451. break;
  452. case "content-type":
  453. _sContentType = value;
  454. break;
  455. case "transfer-encoding":
  456. _sTransferEncoding = value;
  457. if (value.Equals ("chunked")) {
  458. _bChunked = true;
  459. } else {
  460. _bChunked = false;
  461. }
  462. break;
  463. case "pragma":
  464. _sCacheControl = value;
  465. break;
  466. default:
  467. _Headers.Add (new HttpResponseHeader (name, value));
  468. break;
  469. }
  470. }
  471. public void BinaryWrite (byte [] buffer)
  472. {
  473. OutputStream.Write (buffer, 0, buffer.Length);
  474. }
  475. public void Clear ()
  476. {
  477. if (_Writer != null)
  478. _Writer.Clear ();
  479. }
  480. public void ClearContent ()
  481. {
  482. Clear();
  483. }
  484. public void ClearHeaders ()
  485. {
  486. if (_bHeadersSent)
  487. throw new HttpException ("Headers has been sent to the client");
  488. _sContentType = "text/html";
  489. _iStatusCode = 200;
  490. _sCharset = null;
  491. _Headers = new ArrayList ();
  492. _sCacheControl = null;
  493. _sTransferEncoding = null;
  494. _lContentLength = 0;
  495. _bSuppressContent = false;
  496. _bSuppressHeaders = false;
  497. _bClientDisconnected = false;
  498. }
  499. public void Close ()
  500. {
  501. _bClientDisconnected = false;
  502. _WorkerRequest.CloseConnection ();
  503. _bClientDisconnected = true;
  504. }
  505. internal void Dispose ()
  506. {
  507. if (_Writer != null) {
  508. _Writer.Dispose ();
  509. _Writer = null;
  510. }
  511. }
  512. [MonoTODO("Handle callbacks into before done with session, needs to have a non ended flush here")]
  513. internal void FlushAtEndOfRequest ()
  514. {
  515. Flush (true);
  516. }
  517. public void End ()
  518. {
  519. if (_bEnded)
  520. return;
  521. Flush ();
  522. _bEnded = true;
  523. _Context.ApplicationInstance.CompleteRequest ();
  524. }
  525. public void Flush ()
  526. {
  527. Flush (false);
  528. }
  529. private void Flush (bool bFinish)
  530. {
  531. if (_bFlushing)
  532. return;
  533. _bFlushing = true;
  534. if (_Writer == null) {
  535. _TextWriter.Flush ();
  536. _bFlushing = false;
  537. return;
  538. }
  539. try {
  540. long length;
  541. if (!_bHeadersSent && !_bSuppressHeaders && !_bClientDisconnected) {
  542. if (bFinish) {
  543. length = _Writer.BufferSize;
  544. if (length == 0 && _lContentLength == 0)
  545. _sContentType = null;
  546. SendHeaders ();
  547. length = _Writer.BufferSize;
  548. if (length != 0)
  549. _WorkerRequest.SendCalculatedContentLength ((int) length);
  550. } else {
  551. if (_lContentLength == 0 && _iStatusCode == 200 &&
  552. _sTransferEncoding == null) {
  553. // Check we are going todo chunked encoding
  554. string sProto = Request.ServerVariables ["SERVER_PROTOCOL"];
  555. sProto = "HTTP/1.0"; // Remove this line when we support properly
  556. // chunked content
  557. if (sProto != null && sProto == "HTTP/1.1") {
  558. AppendHeader (
  559. HttpWorkerRequest.HeaderTransferEncoding,
  560. "chunked");
  561. } else {
  562. // Just in case, the old browsers send a HTTP/1.0
  563. // request with Connection: Keep-Alive
  564. AppendHeader (
  565. HttpWorkerRequest.HeaderConnection,
  566. "Close");
  567. }
  568. }
  569. SendHeaders ();
  570. }
  571. }
  572. if (!_bSuppressContent && Request.HttpMethod == "HEAD")
  573. _bSuppressContent = true;
  574. if (!_bSuppressContent) {
  575. _bClientDisconnected = false;
  576. if (_bChunked) {
  577. Encoding oASCII = Encoding.ASCII;
  578. string chunk = Convert.ToString(_Writer.BufferSize, 16);
  579. byte [] arrPrefix = oASCII.GetBytes (chunk + s_sChunkedPrefix);
  580. _WorkerRequest.SendResponseFromMemory (arrPrefix,
  581. arrPrefix.Length);
  582. _Writer.SendContent (_WorkerRequest);
  583. _WorkerRequest.SendResponseFromMemory (s_arrChunkSuffix,
  584. s_arrChunkSuffix.Length);
  585. if (bFinish)
  586. _WorkerRequest.SendResponseFromMemory (
  587. s_arrChunkEnd, s_arrChunkEnd.Length);
  588. } else {
  589. _Writer.SendContent (_WorkerRequest);
  590. }
  591. } else {
  592. _Writer.Clear ();
  593. }
  594. _WorkerRequest.FlushResponse (bFinish);
  595. if (!bFinish)
  596. _Writer.Clear ();
  597. } finally {
  598. _bFlushing = false;
  599. }
  600. }
  601. public void Pics (string value)
  602. {
  603. AppendHeader ("PICS-Label", value);
  604. }
  605. public void Redirect (string url)
  606. {
  607. Redirect (url, true);
  608. }
  609. public void Redirect (string url, bool endResponse)
  610. {
  611. if (_bHeadersSent)
  612. throw new HttpException ("Headers has been sent to the client");
  613. Clear ();
  614. url = ApplyAppPathModifier (url);
  615. StatusCode = 302;
  616. AppendHeader (HttpWorkerRequest.HeaderLocation, url);
  617. // Text for browsers that can't handle location header
  618. Write ("<html><head><title>Object moved</title></head><body>\r\n");
  619. Write ("<h2>Object moved to <a href='" + url + "'>here</a></h2>\r\n");
  620. Write ("</body><html>\r\n");
  621. if (endResponse)
  622. End ();
  623. }
  624. public void Write (char ch)
  625. {
  626. _TextWriter.Write(ch);
  627. }
  628. public void Write (object obj)
  629. {
  630. _TextWriter.Write(obj);
  631. }
  632. public void Write (string str)
  633. {
  634. _TextWriter.Write (str);
  635. }
  636. public void Write (char [] buffer, int index, int count)
  637. {
  638. _TextWriter.Write (buffer, index, count);
  639. }
  640. [MonoTODO()]
  641. public static void RemoveOutputCacheItem (string path)
  642. {
  643. throw new NotImplementedException ();
  644. }
  645. public void SetCookie (HttpCookie cookie)
  646. {
  647. if (_bHeadersSent)
  648. throw new HttpException ("Cannot append cookies after HTTP headers have been sent");
  649. Cookies.Add (cookie);
  650. }
  651. private void WriteFromStream (Stream stream, long offset, long length, long bufsize)
  652. {
  653. if (offset < 0 || length <= 0)
  654. return;
  655. long stLength = stream.Length;
  656. if (offset + length > stLength)
  657. length = stLength - offset;
  658. if (offset > 0)
  659. stream.Seek (offset, SeekOrigin.Begin);
  660. byte [] fileContent = new byte [bufsize];
  661. int count = (int) Math.Min (Int32.MaxValue, bufsize);
  662. while (length > 0 && (count = stream.Read (fileContent, 0, count)) != 0) {
  663. _Writer.WriteBytes (fileContent, 0, count);
  664. length -= count;
  665. count = (int) Math.Min (length, fileContent.Length);
  666. }
  667. }
  668. public void WriteFile (string filename)
  669. {
  670. WriteFile (filename, false);
  671. }
  672. public void WriteFile (string filename, bool readIntoMemory)
  673. {
  674. FileStream fs = null;
  675. try {
  676. fs = File.OpenRead (filename);
  677. long size = fs.Length;
  678. if (readIntoMemory) {
  679. WriteFromStream (fs, 0, size, size);
  680. } else {
  681. WriteFromStream (fs, 0, size, 8192);
  682. }
  683. } finally {
  684. if (fs != null)
  685. fs.Close ();
  686. }
  687. }
  688. public void WriteFile (string filename, long offset, long size)
  689. {
  690. FileStream fs = null;
  691. try {
  692. fs = File.OpenRead (filename);
  693. WriteFromStream (fs, offset, size, 8192);
  694. } finally {
  695. if (fs != null)
  696. fs.Close ();
  697. }
  698. }
  699. public void WriteFile (IntPtr fileHandle, long offset, long size)
  700. {
  701. FileStream fs = null;
  702. try {
  703. fs = new FileStream (fileHandle, FileAccess.Read);
  704. WriteFromStream (fs, offset, size, 8192);
  705. } finally {
  706. if (fs != null)
  707. fs.Close ();
  708. }
  709. }
  710. [MonoTODO()]
  711. internal void OnCookieAdd (HttpCookie cookie)
  712. {
  713. }
  714. [MonoTODO("Do we need this?")]
  715. internal void OnCookieChange (HttpCookie cookie)
  716. {
  717. }
  718. [MonoTODO()]
  719. internal void GoingToChangeCookieColl ()
  720. {
  721. }
  722. [MonoTODO()]
  723. internal void ChangedCookieColl ()
  724. {
  725. }
  726. }
  727. }