@@ -32,30 +32,38 @@ abstract class BaseResponse {
3232 /// The HTTP headers returned by the server.
3333 ///
3434 /// The header names are converted to lowercase and stored with their
35- /// associated header values.
35+ /// associated header values. Because header names are lower-cased, you should
36+ /// always use lowercase keys to access them (e.g.,
37+ /// `response.headers['content-type']` ).
3638 ///
3739 /// If the server returns multiple headers with the same name then the header
38- /// values will be associated with a single key and seperated by commas and
40+ /// values will be associated with a single key and separated by commas and
3941 /// possibly whitespace. For example:
4042 /// ```dart
4143 /// // HTTP/1.1 200 OK
4244 /// // Fruit: Apple
4345 /// // Fruit: Banana
4446 /// // Fruit: Grape
45- /// final values = response.headers['fruit']!.split(RegExp(r'\s*,\s*')) ;
46- /// // values = [ 'Apple', ' Banana', ' Grape']
47+ /// final values = response.headers['fruit']!;
48+ /// // values = 'Apple, Banana, Grape'
4749 /// ```
4850 ///
4951 /// To retrieve the header values as a `List<String>` , use
50- /// [HeadersWithSplitValues.headersSplitValues] .
52+ /// [HeadersWithSplitValues.headersSplitValues] . This is particularly
53+ /// important for the `Set-Cookie` header, as the values may contain commas
54+ /// that make manual splitting difficult.
5155 ///
5256 /// If a header value contains whitespace then that whitespace may be replaced
5357 /// by a single space. Leading and trailing whitespace in header values are
5458 /// always removed.
5559 ///
5660 /// Some headers may be excluded by the [Client] for security or privacy
5761 /// reasons. For example, browser-based clients can only return headers in the
58- /// CORS safelist or specifically allowed by the server.
62+ /// CORS safelist or specifically allowed by the server. The server can
63+ /// control which headers are exposed to clients running in the browser by
64+ /// setting the
65+ /// [`Access-Control-Expose-Headers`] (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)
66+ /// header.
5967 final Map <String , String > headers;
6068
6169 final bool isRedirect;
0 commit comments