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

fix: remove content-type hack #324

Merged
merged 1 commit into from
Mar 25, 2022
Merged

Conversation

typfel
Copy link
Member

@typfel typfel commented Mar 25, 2022


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

We are sending our messages as protobuf and the server requires the content type to be set to application/x-protobuf. Ktor however doesn't respect overriding the content-type on a request and will always send binary data as application/octet-stream.

We hacked around this on the Android/JVM by installing a http interceptor which re-writes the content type. This has some drawbacks:

  1. It only fixes the problem on Android,
  2. The moment we need to send another binary content type the hack doesn't work anymore.

And that moment is now because I need to send binary data with content type message/mls when I send MLS messages.

Solutions

Install the ContentNegotiation plugin which can be used to serialise/deserialise requests based on the content-type. We'll only use it to register our missing binary content-types with a dummy converter which simply passes the binary data through as is.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@typfel typfel requested a review from vitorhugods March 25, 2022 21:51
@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2022

Unit Test Results

  61 files    61 suites   25s ⏱️
293 tests 286 ✔️ 7 💤 0

Results for commit 2ae36d3.

♻️ This comment has been updated with latest results.

@typfel typfel requested a review from MohamadJaara March 25, 2022 21:58
Copy link
Member

@vitorhugods vitorhugods left a comment

Choose a reason for hiding this comment

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

A lot of people would like this one:
ktorio/ktor#1127

@typfel typfel merged commit e72c8eb into develop Mar 25, 2022
@typfel typfel deleted the fix/remove-content-type-hack branch March 25, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants