Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: sdk/lib/io/http_impl.dart

Issue 12378040: Add missing certificate getter on HttpClientResponse and add a regression test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix long line. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_client_certificate_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpIncoming 7 class _HttpIncoming extends Stream<List<int>> {
8 extends Stream<List<int>> implements StreamSink<List<int>> {
9 final int _transferLength; 8 final int _transferLength;
10 final Completer _dataCompleter = new Completer(); 9 final Completer _dataCompleter = new Completer();
11 Stream<List<int>> _stream; 10 Stream<List<int>> _stream;
12 11
13 bool fullBodyRead = false; 12 bool fullBodyRead = false;
14 13
15 // Common properties. 14 // Common properties.
16 final _HttpHeaders headers; 15 final _HttpHeaders headers;
17 bool upgraded = false; 16 bool upgraded = false;
18 17
(...skipping 28 matching lines...) Expand all
47 46
48 // Is completed once all data have been received. 47 // Is completed once all data have been received.
49 Future get dataDone => _dataCompleter.future; 48 Future get dataDone => _dataCompleter.future;
50 49
51 void close() { 50 void close() {
52 fullBodyRead = true; 51 fullBodyRead = true;
53 _dataCompleter.complete(); 52 _dataCompleter.complete();
54 } 53 }
55 } 54 }
56 55
57 class _HttpInboundMessage extends Stream<List<int>> { 56 abstract class _HttpInboundMessage extends Stream<List<int>> {
58 final _HttpIncoming _incoming; 57 final _HttpIncoming _incoming;
59 List<Cookie> _cookies; 58 List<Cookie> _cookies;
60 59
61 _HttpInboundMessage(_HttpIncoming this._incoming); 60 _HttpInboundMessage(_HttpIncoming this._incoming);
62 61
63 List<Cookie> get cookies { 62 List<Cookie> get cookies {
64 if (_cookies != null) return _cookies; 63 if (_cookies != null) return _cookies;
65 return _cookies = headers._parseCookies(); 64 return _cookies = headers._parseCookies();
66 } 65 }
67 66
68 HttpHeaders get headers => _incoming.headers; 67 _HttpHeaders get headers => _incoming.headers;
69 String get protocolVersion => headers.protocolVersion; 68 String get protocolVersion => headers.protocolVersion;
70 int get contentLength => headers.contentLength; 69 int get contentLength => headers.contentLength;
71 bool get persistentConnection => headers.persistentConnection; 70 bool get persistentConnection => headers.persistentConnection;
72 } 71 }
73 72
74 73
75 class _HttpRequest extends _HttpInboundMessage implements HttpRequest { 74 class _HttpRequest extends _HttpInboundMessage implements HttpRequest {
76 final HttpResponse response; 75 final HttpResponse response;
77 76
78 // Lazy initialized parsed query parameters. 77 // Lazy initialized parsed query parameters.
79 Map<String, String> _queryParameters; 78 Map<String, String> _queryParameters;
80 79
81 final _HttpServer _httpServer; 80 final _HttpServer _httpServer;
82 81
83 final _HttpConnection _httpConnection; 82 final _HttpConnection _httpConnection;
84 83
85 HttpSession _session; 84 _HttpSession _session;
86 85
87 _HttpRequest(_HttpResponse this.response, 86 _HttpRequest(_HttpResponse this.response,
88 _HttpIncoming _incoming, 87 _HttpIncoming _incoming,
89 _HttpServer this._httpServer, 88 _HttpServer this._httpServer,
90 _HttpConnection this._httpConnection) 89 _HttpConnection this._httpConnection)
91 : super(_incoming) { 90 : super(_incoming) {
92 response.headers.persistentConnection = headers.persistentConnection; 91 response.headers.persistentConnection = headers.persistentConnection;
93 92
94 if (_httpServer._sessionManagerInstance != null) { 93 if (_httpServer._sessionManagerInstance != null) {
95 // Map to session if exists. 94 // Map to session if exists.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 List<Cookie> _cookies; 159 List<Cookie> _cookies;
161 160
162 _HttpClientResponse(_HttpIncoming _incoming, 161 _HttpClientResponse(_HttpIncoming _incoming,
163 _HttpClientRequest this._httpRequest, 162 _HttpClientRequest this._httpRequest,
164 _HttpClient this._httpClient) 163 _HttpClient this._httpClient)
165 : super(_incoming); 164 : super(_incoming);
166 165
167 int get statusCode => _incoming.statusCode; 166 int get statusCode => _incoming.statusCode;
168 String get reasonPhrase => _incoming.reasonPhrase; 167 String get reasonPhrase => _incoming.reasonPhrase;
169 168
169 X509Certificate get certificate {
170 var socket = _httpRequest._httpClientConnection._socket;
171 return socket.peerCertificate;
172 }
173
170 List<Cookie> get cookies { 174 List<Cookie> get cookies {
171 if (_cookies != null) return _cookies; 175 if (_cookies != null) return _cookies;
172 _cookies = new List<Cookie>(); 176 _cookies = new List<Cookie>();
173 List<String> values = headers[HttpHeaders.SET_COOKIE]; 177 List<String> values = headers[HttpHeaders.SET_COOKIE];
174 if (values != null) { 178 if (values != null) {
175 values.forEach((value) { 179 values.forEach((value) {
176 _cookies.add(new Cookie.fromSetCookieValue(value)); 180 _cookies.add(new Cookie.fromSetCookieValue(value));
177 }); 181 });
178 } 182 }
179 return _cookies; 183 return _cookies;
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 1605
1602 1606
1603 class _RedirectInfo implements RedirectInfo { 1607 class _RedirectInfo implements RedirectInfo {
1604 const _RedirectInfo(int this.statusCode, 1608 const _RedirectInfo(int this.statusCode,
1605 String this.method, 1609 String this.method,
1606 Uri this.location); 1610 Uri this.location);
1607 final int statusCode; 1611 final int statusCode;
1608 final String method; 1612 final String method;
1609 final Uri location; 1613 final Uri location;
1610 } 1614 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/https_client_certificate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698