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

Header is out of order #2253

Closed
vimaxwell opened this issue Jun 21, 2024 · 3 comments
Closed

Header is out of order #2253

vimaxwell opened this issue Jun 21, 2024 · 3 comments

Comments

@vimaxwell
Copy link

vimaxwell commented Jun 21, 2024

Package

dio

Version

5.4.3

Operating-System

Android

Adapter

Default Dio

Output of flutter doctor -v

No response

Dart Version

No response

Steps to Reproduce

I want to follow my backend rule of api header order. But I can't do that in dio

var headers = {
  'a':'a',
  'b':'b',
  'c':'c',
  'd':'d'
};

var dio = Dio();
var response = await dio.request(
  'https://example.com/api',
  options: Options(
    method: 'GET',
    headers: headers,
  ),
);

Expected Result

The server receives header in order as a,b,c,d

Actual Result

the header is out of order in the server as c,a,b,d

@vimaxwell vimaxwell added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jun 21, 2024
@AlexV525
Copy link
Member

We don't manipulate headers in any of our flows. Please check if there is an interceptor that touches your headers or provides a minimal reproducible example.

@AlexV525 AlexV525 added h: need more info Further information is requested i: cannot reproduce labels Jun 21, 2024
@vimaxwell
Copy link
Author

vimaxwell commented Jun 21, 2024

I debug the code and found the lib using http package and that package can't keep header order @AlexV525

I guess because it uses HashMap instead of LinkedHashMap
https://github.com/dart-lang/sdk/blob/51ecf21356df5043f42270915aa22b76857941cd/sdk/lib/_http/http_headers.dart#L29

@AlexV525
Copy link
Member

I debug the code and found the lib using http package and that package can't keep header order @AlexV525

This is the HTTP implementation inside dart:io, not the package:http.

I guess because it uses HashMap instead of LinkedHashMap https://github.com/dart-lang/sdk/blob/51ecf21356df5043f42270915aa22b76857941cd/sdk/lib/_http/http_headers.dart#L29

Cool. I guess you need a request to the Dart SDK then. Closing.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2024
@AlexV525 AlexV525 added i: out of support and removed h: need more info Further information is requested h: need triage This issue needs to be categorized i: cannot reproduce s: bug Something isn't working labels Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants