2 // HttpResponseHeaders.cs
5 // Marek Safar <marek.safar@gmail.com>
7 // Copyright (C) 2011 Xamarin Inc (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
31 namespace System.Net.Http.Headers
33 public sealed class HttpResponseHeaders : HttpHeaders
35 bool? connectionclose, transferEncodingChunked;
37 internal HttpResponseHeaders ()
38 : base (HttpHeaderKind.Response)
42 public HttpHeaderValueCollection<string> AcceptRanges {
44 return GetValues<string> ("Accept-Ranges");
48 public TimeSpan? Age {
50 return GetValue<TimeSpan?> ("Age");
53 AddOrRemove ("Age", value);
57 public CacheControlHeaderValue CacheControl {
59 return GetValue<CacheControlHeaderValue> ("Cache-Control");
62 AddOrRemove ("Cache-Control", value);
66 public HttpHeaderValueCollection<string> Connection {
68 return GetValues<string> ("Connection");
72 public bool? ConnectionClose {
74 if (connectionclose == true || Connection.Contains ("close"))
77 return connectionclose;
80 if (connectionclose == value)
83 Connection.Remove ("close");
85 Connection.Add ("close");
87 connectionclose = value;
91 public DateTimeOffset? Date {
93 return GetValue<DateTimeOffset?> ("Date");
96 AddOrRemove ("Date", value);
100 public EntityTagHeaderValue ETag {
102 return GetValue<EntityTagHeaderValue> ("ETag");
105 AddOrRemove ("ETag", value);
109 public Uri Location {
111 return GetValue<Uri> ("Location");
114 AddOrRemove ("Location", value);
118 public HttpHeaderValueCollection<NameValueHeaderValue> Pragma {
120 return GetValues<NameValueHeaderValue> ("Pragma");
124 public HttpHeaderValueCollection<AuthenticationHeaderValue> ProxyAuthenticate {
126 return GetValues<AuthenticationHeaderValue> ("Proxy-Authenticate");
130 public RetryConditionHeaderValue RetryAfter {
132 return GetValue<RetryConditionHeaderValue> ("Retry-After");
135 AddOrRemove ("Retry-After", value);
139 public HttpHeaderValueCollection<ProductInfoHeaderValue> Server {
141 return GetValues<ProductInfoHeaderValue> ("Server");
145 public HttpHeaderValueCollection<string> Trailer {
147 return GetValues<string> ("Trailer");
151 public HttpHeaderValueCollection<TransferCodingHeaderValue> TransferEncoding {
153 return GetValues<TransferCodingHeaderValue> ("Transfer-Encoding");
157 public bool? TransferEncodingChunked {
159 if (transferEncodingChunked.HasValue)
160 return transferEncodingChunked;
162 var found = TransferEncoding.Find (l => StringComparer.OrdinalIgnoreCase.Equals (l.Value, "chunked"));
163 return found != null ? true : (bool?) null;
166 if (value == transferEncodingChunked)
169 TransferEncoding.Remove (l => l.Value == "chunked");
171 TransferEncoding.Add (new TransferCodingHeaderValue ("chunked"));
173 transferEncodingChunked = value;
177 public HttpHeaderValueCollection<ProductHeaderValue> Upgrade {
179 return GetValues<ProductHeaderValue> ("Upgrade");
183 public HttpHeaderValueCollection<string> Vary {
185 return GetValues<string> ("Vary");
189 public HttpHeaderValueCollection<ViaHeaderValue> Via {
191 return GetValues<ViaHeaderValue> ("Via");
195 public HttpHeaderValueCollection<WarningHeaderValue> Warning {
197 return GetValues<WarningHeaderValue> ("Warning");
201 public HttpHeaderValueCollection<AuthenticationHeaderValue> WwwAuthenticate {
203 return GetValues<AuthenticationHeaderValue> ("WWW-Authenticate");