Line | |
---|
1 | using System;
|
---|
2 | using System.Net;
|
---|
3 | using System.IO;
|
---|
4 |
|
---|
5 | namespace SharpVectors.Net
|
---|
6 | {
|
---|
7 | public class ExtendedHttpWebResponse : WebResponse
|
---|
8 | {
|
---|
9 | private WebResponse response;
|
---|
10 | private Uri responseUri;
|
---|
11 | private Stream responseStream;
|
---|
12 | private CacheInfo cacheInfo;
|
---|
13 |
|
---|
14 | public ExtendedHttpWebResponse(Uri responseUri, WebResponse response, Stream responseStream, CacheInfo cacheInfo)
|
---|
15 | {
|
---|
16 | this.responseUri = responseUri;
|
---|
17 | this.response = response;
|
---|
18 | this.responseStream = responseStream;
|
---|
19 | this.cacheInfo = cacheInfo;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override Stream GetResponseStream()
|
---|
23 | {
|
---|
24 | if(responseStream != null && responseStream.CanSeek)
|
---|
25 | {
|
---|
26 | responseStream.Position = 0;
|
---|
27 | return responseStream;
|
---|
28 | }
|
---|
29 | else
|
---|
30 | {
|
---|
31 | return response.GetResponseStream();
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public override string ContentType
|
---|
36 | {
|
---|
37 | get
|
---|
38 | {
|
---|
39 | if(!(response is HttpWebResponse) && cacheInfo != null)
|
---|
40 | {
|
---|
41 | return cacheInfo.ContentType;
|
---|
42 | }
|
---|
43 | else
|
---|
44 | {
|
---|
45 | return response.ContentType;
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public override Uri ResponseUri
|
---|
51 | {
|
---|
52 | get
|
---|
53 | {
|
---|
54 | if(!(response is HttpWebResponse) && cacheInfo != null)
|
---|
55 | {
|
---|
56 | return cacheInfo.CachedUri;
|
---|
57 | }
|
---|
58 | else
|
---|
59 | {
|
---|
60 | return response.ResponseUri;
|
---|
61 | }
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.