{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/34220","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/34220/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/34220/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/34220/events","html_url":"https://github.com/dart-lang/sdk/issues/34220","id":352825394,"node_id":"MDU6SXNzdWUzNTI4MjUzOTQ=","number":34220,"title":"Getting cookies from HttpClientResponse throws","user":{"login":"long1eu","id":9283414,"node_id":"MDQ6VXNlcjkyODM0MTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/9283414?v=4","gravatar_id":"","url":"https://api.github.com/users/long1eu","html_url":"https://github.com/long1eu","followers_url":"https://api.github.com/users/long1eu/followers","following_url":"https://api.github.com/users/long1eu/following{/other_user}","gists_url":"https://api.github.com/users/long1eu/gists{/gist_id}","starred_url":"https://api.github.com/users/long1eu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/long1eu/subscriptions","organizations_url":"https://api.github.com/users/long1eu/orgs","repos_url":"https://api.github.com/users/long1eu/repos","events_url":"https://api.github.com/users/long1eu/events{/privacy}","received_events_url":"https://api.github.com/users/long1eu/received_events","type":"User","site_admin":false},"labels":[{"id":219928184,"node_id":"MDU6TGFiZWwyMTk5MjgxODQ=","url":"https://api.github.com/repos/dart-lang/sdk/labels/area-library","name":"area-library","color":"c7def8","default":false},{"id":219928199,"node_id":"MDU6TGFiZWwyMTk5MjgxOTk=","url":"https://api.github.com/repos/dart-lang/sdk/labels/library-io","name":"library-io","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-08-22T06:57:07Z","updated_at":"2018-09-08T17:05:00Z","closed_at":null,"author_association":"NONE","body":"RangeError (index): Invalid value: Valid value range is empty: 0\r\n```\r\nI/flutter (26221): #1      _Cookie._validate (dart:_http/http_headers.dart:989:14)\r\nI/flutter (26221): #2      _Cookie._parseSetCookieValue (dart:_http/http_headers.dart:933:5)\r\nI/flutter (26221): #3      new _Cookie.fromSetCookieValue (dart:_http/http_headers.dart:849:5)\r\nI/flutter (26221): #4      new Cookie.fromSetCookieValue (dart:_http:1112:16)\r\nI/flutter (26221): #5      _HttpClientResponse.cookies.<anonymous closure> (dart:_http/http_impl.dart:317:26)\r\nI/flutter (26221): #6      List.forEach (dart:core/runtime/libgrowable_array.dart:275:8)\r\nI/flutter (26221): #7      _HttpClientResponse.cookies (dart:_http/http_impl.dart:316:14)\r\n```\r\n\r\nhttps://github.com/flutter/flutter/issues/20898"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/419658018","html_url":"https://github.com/dart-lang/sdk/issues/34220#issuecomment-419658018","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/34220","id":419658018,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTY1ODAxOA==","user":{"login":"slightfoot","id":906564,"node_id":"MDQ6VXNlcjkwNjU2NA==","avatar_url":"https://avatars0.githubusercontent.com/u/906564?v=4","gravatar_id":"","url":"https://api.github.com/users/slightfoot","html_url":"https://github.com/slightfoot","followers_url":"https://api.github.com/users/slightfoot/followers","following_url":"https://api.github.com/users/slightfoot/following{/other_user}","gists_url":"https://api.github.com/users/slightfoot/gists{/gist_id}","starred_url":"https://api.github.com/users/slightfoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slightfoot/subscriptions","organizations_url":"https://api.github.com/users/slightfoot/orgs","repos_url":"https://api.github.com/users/slightfoot/repos","events_url":"https://api.github.com/users/slightfoot/events{/privacy}","received_events_url":"https://api.github.com/users/slightfoot/received_events","type":"User","site_admin":false},"created_at":"2018-09-08T17:05:00Z","updated_at":"2018-09-08T17:05:00Z","author_association":"NONE","body":"Been looking into this with @gerryhigh and we've figured out the below. Was looking into where the exception is being raised `dart:_http/http_headers.dart:989:14` code looks like this.\r\n```\r\nif (value[0] == '\"' && value[value.length - 1] == '\"') {\r\n  value = value.substring(1, value.length - 1);\r\n}\r\n```\r\n\r\nSeems its two things, first the length of value should be tested before you try to index -1, and second the check could indicate there is only 1 speech mark in which case you try to get `substring(1, 0)` which is invalid. I believe testing with the following headers should replicate the issue.\r\n\r\n```\r\nset-cookie: lang=en; path=/\r\nset-cookie: _my_session=somereallylongstring; path=/; HttpOnly\r\nset-cookie: basic_auth=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT\r\nset-cookie: basic_auth_checked=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT\r\nset-cookie: password=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT\r\nset-cookie: visitor_session_id=someid; domain=.mydomain.com; path=/; expires=Sat, 08 Sep 2018 16:54:31 GMT;\r\n```\r\n"}}
{"actor":{"display_login":"slightfoot"}}