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

Allow user provided metadata to override default metadata #62

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dbhobbs
Copy link

@dbhobbs dbhobbs commented Nov 12, 2021

This PR introduces code that will join duplicate headers into a comma-separated list, if allowed. Otherwise, it will prefer the user supplied value in the case that a default value was provided. It also moves required pseudo-headers into a separate macro which can't be overridden.

Section 4.2 of RFC2616 lays out some rules around multiple message headers.

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded.

Allowing duplicate headers like Content-Type would change the semantic meaning of the request so, in this PR, only the first header processed is kept. This allows user supplied metadata/headers to override the defaults, but prevents duplicates from being sent.

Addresses issue #60.

I've tested this code in my company's backend system and can successfully publish messages to Google Cloud PubSub.

@codecov
Copy link

codecov bot commented Nov 13, 2021

Codecov Report

Merging #62 (6496cda) into main (0166760) will decrease coverage by 0.21%.
The diff coverage is 27.58%.

❗ Current head 6496cda differs from pull request most recent head 3c2ec9e. Consider uploading reports for the commit 3c2ec9e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #62      +/-   ##
==========================================
- Coverage   38.99%   38.78%   -0.22%     
==========================================
  Files          28       28              
  Lines        2090     2117      +27     
==========================================
+ Hits          815      821       +6     
- Misses       1275     1296      +21     
Impacted Files Coverage Δ
src/grpcbox_client_stream.erl 56.86% <27.58%> (-12.48%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0166760...3c2ec9e. Read the comment docs.

src/grpcbox_client_stream.erl Outdated Show resolved Hide resolved
@tsloughter
Copy link
Owner

Damn, its been years. I want to merge this functionality but the merge is now hairy. I may have to tweak it to get it working with the latest main and open a new PR.

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.

3 participants