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]:
|
||
|---|---|---|
| .. | ||
| HTMLMetadataTests.swift | ||
| MessageSenderJobRecordTest.swift | ||
| MessageSendJobQueueTest.swift | ||
| OWSHttpHeadersTest.swift | ||
| OWSRequestFactoryTest.swift | ||
| OWSURLSessionTest.swift | ||