Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date header not parsed correctly #2269

Open
hampsterx opened this issue Jul 9, 2024 · 2 comments
Open

Date header not parsed correctly #2269

hampsterx opened this issue Jul 9, 2024 · 2 comments
Labels
p: web_adapter Targeting `web_adapter` package platform: web s: bug Something isn't working

Comments

@hampsterx
Copy link

Package

dio

Version

5.5

Operating-System

Web

Adapter

Default Dio

Output of flutter doctor -v

No response

Dart Version

No response

Steps to Reproduce

Date field is in RFC 2616 format, it includes a comma in the value. eg

Date => "Tue, 09 Jul 2024 19:39:05 GMT"

dio_web_adapter appears to be using

  headers: xhr.responseHeaders.map((k, v) => MapEntry(k, v.split(','))),

Expected Result

The full value not split.

Actual Result

"date" header as "Tue"

@hampsterx hampsterx added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jul 9, 2024
@AlexV525 AlexV525 added platform: web p: web_adapter Targeting `web_adapter` package and removed h: need triage This issue needs to be categorized labels Jul 31, 2024
@Reprevise
Copy link
Contributor

@AlexV525 Do your changes here fix this issue?

Map<String, List<String>> getResponseHeaders() {
final headersString = getAllResponseHeaders();
final headers = <String, List<String>>{};
if (headersString.isEmpty) {
return headers;
}
final headersList = headersString.split('\r\n');
for (final header in headersList) {
if (header.isEmpty) {
continue;
}
final splitIdx = header.indexOf(': ');
if (splitIdx == -1) {
continue;
}
final key = header.substring(0, splitIdx).toLowerCase();
final value = header.substring(splitIdx + 2);
(headers[key] ??= []).add(value);
}
return headers;
}

@AlexV525
Copy link
Member

AlexV525 commented Oct 5, 2024

Is there a working version for the implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: web_adapter Targeting `web_adapter` package platform: web s: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants