Skip to content

Conversation

@alperozturk96
Copy link
Contributor

@alperozturk96 alperozturk96 commented Oct 13, 2025

Signed-off-by: alperozturk <[email protected]>
Copy link
Member

@korelstar korelstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm, that this fixes nextcloud/notes-android#2848. However, I'm not sure, if this could cause problems for other HTTP headers.

@NHellFire
Copy link

Hopefully this doesn't break anything elsewhere. FWIW, this PR is what RFC 2616 & 9110 say to do with duplicate headers.

https://www.rfc-editor.org/rfc/rfc9110#name-field-lines-and-combined-fi

@andrewille
Copy link

Hello,
I am the reporter of the issue nextcloud/notes-android#2848 and I can confirm this fixes the issue for me.

However, the code just joins any header values with a ", " separator in between. I don't know whether the app relies on any of these headers (or will do so in the future), but you might rather want to join distinct values only to avoid issues. In my case it was caused by two X-Robots-Tag headers and they both had the exact same value "noindex, nofollow". So the new code would make it "noindex, nofollow, noindex, nofollow". In this particular case it is probably not relevant but maybe other headers' values are more important for the App.

@alperozturk96 alperozturk96 marked this pull request as draft October 14, 2025 07:18
Signed-off-by: alperozturk <[email protected]>
@alperozturk96 alperozturk96 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 14, 2025
Signed-off-by: alperozturk <[email protected]>
@alperozturk96 alperozturk96 marked this pull request as ready for review October 14, 2025 09:03
Signed-off-by: alperozturk <[email protected]>
final String value = header.getValue();

// Create a unique key for name:value combination
final String key = name.toLowerCase() + ":" + value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This could fix downstream issues like e.g. nextcloud/notes-android#2531

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This could fix downstream issues like e.g. nextcloud/notes-android#2531

I don't think so. It doesn't actually store the headers with the lowercase key, only uses that for deduplicating them.

For that issue, I did comment on #796 with a likely solution, but I didn't manage to build Notes against my test version to find out.

@alperozturk96
Copy link
Contributor Author

alperozturk96 commented Oct 14, 2025

@andrewille @NHellFire

Hey.

Thank you for your messages. I’ve updated the PR with tests. Since I wasn’t able to reproduce the issue on my side, could you please test the latest version from here ?

As you can see from the tests, I think the expected values appear to be reasonable, but I’d appreciate your confirmation.

@NHellFire
Copy link

I've just tested that build, syncing works correctly again and newly created notes show up without a refresh (nextcloud/notes-android#2850)

Copy link
Member

@korelstar korelstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Latest updates still fix nextcloud/notes-android#2848. I would be happy to see this released soon :-)

Copy link

@andrewille andrewille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me and works well. :)

@alperozturk96 alperozturk96 merged commit 42cb74f into main Oct 14, 2025
6 checks passed
@alperozturk96 alperozturk96 deleted the fix/duplicate-key-exception branch October 14, 2025 13:33
@nextcloud nextcloud deleted a comment from backportbot bot Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle duplicate headers in Retrofit2Helper

7 participants