Signal-iOS/SignalServiceKit/tests/Network
Evan Hahn bf8fd72fba
Improve Accept-Language header value, fixing registration bug
Some users [are unable to register][1] because the server [returns a 400
error][2] if passed an invalid `Accept-Language` header.

This commit helps prevent two possible error modes:

- Filters out invalid language tags. Some users reported a "Workshopx"
  language, which the server would reject because it's syntactically
  invalid. Deleting this language (at the OS level) let them register.
- If no languages are valid, we should send `*` instead of the empty
  string. There's no evidence that this happened in practice.

In addition, this commit:

- Adds tests.
- Sends a maximum of 10 languages instead of 6.
- Omits the `q` value when it's 1 because [that's the default][3].
- Marginally improves performance by iterating lazily.

[1]: https://github.com/signalapp/Signal-iOS/issues/5261
[2]: bf6d3aa324/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java (L271-L275)
[3]: https://www.rfc-editor.org/rfc/rfc9110.html#section-12.4.2

Co-authored-by: Nora Trapp <nora@signal.org>
2022-07-11 12:20:24 -05:00
..
HTMLMetadataTests.swift IOS-823: Add description/date to link preview model 2020-09-03 18:19:20 -07:00
MessageSenderJobRecordTest.swift PR Feedback 2021-08-16 13:28:08 -07:00
MessageSendJobQueueTest.swift Deprecate REST, Part 1 2021-08-18 14:25:36 -03:00
OWSHttpHeadersTest.swift Improve Accept-Language header value, fixing registration bug 2022-07-11 12:20:24 -05:00
OWSRequestFactoryTest.swift Basic support for sending gift badges 2022-06-22 15:50:51 +00:00
OWSURLSessionTest.swift Simplify AFNetworking usage. 2021-10-15 10:50:37 -03:00