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 internal HttpResponseHeaders ()
36 : base (HttpHeaderKind.Response)
40 public HttpHeaderValueCollection<string> AcceptRanges {
42 return GetValues<string> ("Accept-Ranges");
46 public TimeSpan? Age {
48 return GetValue<TimeSpan?> ("Age");
51 AddOrRemove ("Age", value, l => ((long)((TimeSpan)l).TotalSeconds).ToString ());
55 public CacheControlHeaderValue CacheControl {
57 return GetValue<CacheControlHeaderValue> ("Cache-Control");
60 AddOrRemove ("Cache-Control", value);
64 public HttpHeaderValueCollection<string> Connection {
66 return GetValues<string> ("Connection");
70 public bool? ConnectionClose {
72 if (connectionclose == true || Connection.Find (l => string.Equals (l, "close", StringComparison.OrdinalIgnoreCase)) != null)
75 return connectionclose;
78 if (connectionclose == value)
81 Connection.Remove ("close");
83 Connection.Add ("close");
85 connectionclose = value;
89 public DateTimeOffset? Date {
91 return GetValue<DateTimeOffset?> ("Date");
94 AddOrRemove ("Date", value, Parser.DateTime.ToString);
98 public EntityTagHeaderValue ETag {
100 return GetValue<EntityTagHeaderValue> ("ETag");
103 AddOrRemove ("ETag", value);
107 public Uri Location {
109 return GetValue<Uri> ("Location");
112 AddOrRemove ("Location", value);
116 public HttpHeaderValueCollection<NameValueHeaderValue> Pragma {
118 return GetValues<NameValueHeaderValue> ("Pragma");
122 public HttpHeaderValueCollection<AuthenticationHeaderValue> ProxyAuthenticate {
124 return GetValues<AuthenticationHeaderValue> ("Proxy-Authenticate");
128 public RetryConditionHeaderValue RetryAfter {
130 return GetValue<RetryConditionHeaderValue> ("Retry-After");
133 AddOrRemove ("Retry-After", value);
137 public HttpHeaderValueCollection<ProductInfoHeaderValue> Server {
139 return GetValues<ProductInfoHeaderValue> ("Server");
143 public HttpHeaderValueCollection<string> Trailer {
145 return GetValues<string> ("Trailer");
149 public HttpHeaderValueCollection<TransferCodingHeaderValue> TransferEncoding {
151 return GetValues<TransferCodingHeaderValue> ("Transfer-Encoding");
155 public bool? TransferEncodingChunked {
157 if (transferEncodingChunked.HasValue)
158 return transferEncodingChunked;
160 var found = TransferEncoding.Find (l => StringComparer.OrdinalIgnoreCase.Equals (l.Value, "chunked"));
161 return found != null ? true : (bool?) null;
164 if (value == transferEncodingChunked)
167 TransferEncoding.Remove (l => l.Value == "chunked");
169 TransferEncoding.Add (new TransferCodingHeaderValue ("chunked"));
171 transferEncodingChunked = value;
175 public HttpHeaderValueCollection<ProductHeaderValue> Upgrade {
177 return GetValues<ProductHeaderValue> ("Upgrade");
181 public HttpHeaderValueCollection<string> Vary {
183 return GetValues<string> ("Vary");
187 public HttpHeaderValueCollection<ViaHeaderValue> Via {
189 return GetValues<ViaHeaderValue> ("Via");
193 public HttpHeaderValueCollection<WarningHeaderValue> Warning {
195 return GetValues<WarningHeaderValue> ("Warning");
199 public HttpHeaderValueCollection<AuthenticationHeaderValue> WwwAuthenticate {
201 return GetValues<AuthenticationHeaderValue> ("WWW-Authenticate");