Skip to content

Set the HTTP user agent #406

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

Closed
gnprice opened this issue Nov 21, 2023 · 2 comments · Fixed by #471
Closed

Set the HTTP user agent #406

gnprice opened this issue Nov 21, 2023 · 2 comments · Fixed by #471
Assignees
Labels
a-api Implementing specific parts of the Zulip server API

Comments

@gnprice
Copy link
Member

gnprice commented Nov 21, 2023

Currently when we make an HTTP request, the User-Agent header we send is just whatever the default is that Dart's HTTP implementation gives us. This means e.g. that log lines on the server look like this, saying "via Dart":

2023-11-21 22:32:07.353 INFO [zr] 192.168.0.188   POST    200 113ms (db: 35ms/41q) /api/v1/register (11@zulip via Dart)

Instead we should set a user-agent string that identifies this app. Ideally it should include the app's version number.

There are at least two different kinds of HTTP requests the app makes, both of which should have the user agent set:

  • Zulip API calls, which go through ApiConnection.send;
  • fetching images, including avatars, image emoji, and images included in messages, all of which go through RealmContentNetworkImage.

It's likely those will need to be handled separately.

@gnprice gnprice added the a-api Implementing specific parts of the Zulip server API label Nov 21, 2023
@gnprice gnprice added this to the Beta 2 milestone Nov 21, 2023
@gnprice
Copy link
Member Author

gnprice commented Dec 19, 2023

The value should probably say "ZulipMobile" somewhere, because apparently (#453 (comment)) for send-message requests that will activate the server's heuristic for deciding we're a UI client and therefore the newly sent message should be marked as read for its author, solving #440.

For some discussion on how to implement this, see #453.

@gnprice
Copy link
Member Author

gnprice commented Dec 22, 2023

The value should probably say "ZulipMobile" somewhere

But this should be marked with a TODO(server-8) comment — once we're supporting only Zulip Server 8+, our use of read_by_sender (from #456) should always get respected, so we should no longer need to cater to that old heuristic and we can use a more transparent user-agent of our choice.

chrisbobbe pushed a commit to chrisbobbe/zulip-flutter that referenced this issue Dec 30, 2023
Fixes: zulip#406
Fixes: zulip#460

[chris: changed commit message; changed user-agent string; included
in image requests]
chrisbobbe pushed a commit to chrisbobbe/zulip-flutter that referenced this issue Jan 17, 2024
Fixes: zulip#406
Fixes: zulip#460

[chris: changed commit message; changed user-agent string; included
in image requests]
@chrisbobbe chrisbobbe self-assigned this Jan 24, 2024
@gnprice gnprice closed this as completed in 4d5b3e1 Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-api Implementing specific parts of the Zulip server API
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants