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 #requestHeadersFor: on ZnZincServerAdaptor to combine field values for repeated field names #1387

Merged
merged 1 commit into from
Nov 4, 2023

Conversation

Rinzwind
Copy link
Member

@Rinzwind Rinzwind commented Nov 2, 2023

This pull request fixes #requestHeadersFor: on ZnZincServerAdaptor to combine field values for repeated header field names.

Section ‘5.2. Field Lines and Combined Field Value’ in RFC 9110 states:

When a field name is only present once in a section, the combined "field value" for that field consists of the corresponding field line value. When a field name is repeated within a section, its combined field value consists of the list of corresponding field line values within that section, concatenated in order, with each field line value separated by a comma.

See also section ‘6.3. Header Fields’.

Example:

request := String crlf join: #('GET / HTTP/1.1'
	'Accept: application/xml'
	'Accept: application/json'
	'' '').
(ZnZincServerAdaptor new requestFor: (ZnRequest readFromString: request))
	headerAt: 'accept'

Without this fix, the example returns 'application/json'.
With this fix, the example returns 'application/xml,application/json'.

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (80af760) 48.67% compared to head (ed0006f) 48.67%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1387   +/-   ##
=======================================
  Coverage   48.67%   48.67%           
=======================================
  Files        8948     8948           
  Lines       80512    80512           
=======================================
  Hits        39192    39192           
  Misses      41320    41320           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@theseion theseion left a comment

Choose a reason for hiding this comment

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

LGTM

@jbrichau
Copy link
Member

jbrichau commented Nov 4, 2023

This reminds me of #1211 which the exact same issue for responses... It does show how we need unit tests for these adaptors (#1213)

@jbrichau jbrichau merged commit 161e96f into master Nov 4, 2023
14 of 26 checks passed
@jbrichau jbrichau deleted the fix-zincadaptor-repeatedheaders branch November 4, 2023 12:19
@Rinzwind
Copy link
Member Author

Rinzwind commented Nov 6, 2023

Reading issue #1211 makes me wonder: shouldn’t ZnZincServerAdaptor’s #requestHeadersFor: return a WAHeaderFields instead of a Dictionary? Then the separate headers can be preserved. The methods in WARequest’s ‘accessing-headers’ protocol that answer a collection should then combine them.

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