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

Response has unsupport header throw exception: Failed to parse header value.message #57117

Open
Nondirectional opened this issue Aug 1, 2024 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Nondirectional
Copy link

Question:

image

For this request, I can get the response header and status code information when using JavaScript.

However, when using http to send the request and parse the response, an exception is thrown, and I cannot get any information including the status code and response header except an error message.

Reproducible example:

void main() async {
  final client = HttpClient();
  final request = await client.postUrl(
    Uri.parse('http://memos.w-wbr.space/api/v1/auth/status'),
  );
  final response = await request.close();
  print(response);
}
@Nondirectional Nondirectional added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Aug 1, 2024
@mraleph mraleph transferred this issue from dart-lang/http Nov 18, 2024
@dart-github-bot
Copy link
Collaborator

Summary: Dart's HttpClient throws an exception when parsing a malformed response header from http://memos.w-wbr.space/api/v1/auth/status. JavaScript handles the same request successfully.

@dart-github-bot dart-github-bot added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Nov 18, 2024
@mraleph
Copy link
Member

mraleph commented Nov 18, 2024

The exception is thrown because user not found is not a valid value for WWW-Authenticate header, see RFC 7235 Appendix C for the correct format.

I am not sure if we should be more lax when parsing the header though.

cc @brianquinlan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants