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

Put headers in a map rather than an array. #3

Closed
pygy opened this issue Sep 7, 2013 · 2 comments
Closed

Put headers in a map rather than an array. #3

pygy opened this issue Sep 7, 2013 · 2 comments

Comments

@pygy
Copy link

pygy commented Sep 7, 2013

Having headers in a map makes them easier to work with for library users.

The order of headers is irrelevant, and, when the same header appears several times, the last one takes precedence.

As a consequence, you can populate the map on the go when you parse the headers, the parsing code remains very simple.

@jjeffery
Copy link
Owner

jjeffery commented Sep 8, 2013

Yes, this would be a good implementation if the STOMP specification was that the last header takes precedence. However it does not. Check out http://stomp.github.io/stomp-specification-1.2.html#Repeated_Header_Entries.

If a client or a server receives repeated frame header entries, only the first header entry SHOULD be used as the value of header entry. Subsequent values are only used to maintain a history of state changes of the header and MAY be ignored.
For example, if the client receives:

MESSAGE
foo:World
foo:Hello

^@

The value of the foo header is just World.

@jjeffery
Copy link
Owner

jjeffery commented Sep 8, 2013

If I were to implement this again, I would base it on the excellent code in the "net/textproto" package in the golang standard library. STOMP has a few differences (ie case-sensitive, white space sensitive) but the basics of the header handling would be similar to this package. See http://golang.org/src/pkg/net/textproto/

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

No branches or pull requests

2 participants