Skip to content

Conversation

SimonUnge
Copy link
Collaborator

Proposed Changes

Switch out the use of httpc in rabbitmq_aws in favor of gun.

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in the boxes that apply.
You can also fill these out after creating the PR.
This is simply a reminder of what we are going to look for before merging your code.

  • Mandatory: I (or my employer/client) have have signed the CA (see https://github.com/rabbitmq/cla)
  • I have read the CONTRIBUTING.md document
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally with my changes
  • If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
  • If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it

Further Comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc.

SimonUnge and others added 11 commits August 7, 2025 09:25
…he old one but curretly they will live side by side
There is `gun:stream_ref()` but not a custom type for the conn pid, so
dialyzer was unhappy.
Binaries are unnecessarily restrictive since gun allows sending iodata
bodies. This would be useful for larger requests where we want to
combine multiple lists or binaries without paying the cost of
concatenating them. Note that `crypto:hash/2` accepts an `iodata()` arg.

Also this commit avoids double-SHA256-hashing the request body in
`rabbitmq_aws_sign`. The `request_hash/5` function performed a second
`sha256/1` of the body to get the payload hash but this value already
exists at the top of `headers/1`.
In some cases we can compute this incrementally with the streaming hash
utilities from crypto:

    > Hash0 = crypto:hash_init(sha256),
    > Hash1 = crypto:hash_update(Hash0, Data0),
    %% ...
    > HashN = crypto:hash_update(HashN1, DataN),
    > Hash = crypto:hash_final(HashN).

Especially for large bodies this lets us skip a lot of double work.

Currently this is only added to the direct_request API, with the idea
that the other method that blocks the server is deprecated.
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