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

repeated :encoding-delimiter #29

Open
d-t-w opened this issue Oct 30, 2013 · 0 comments
Open

repeated :encoding-delimiter #29

d-t-w opened this issue Oct 30, 2013 · 0 comments

Comments

@d-t-w
Copy link

d-t-w commented Oct 30, 2013

Hi Zach,

I'm using Gloss to decode different types of repeated headers, often following the Internet Message (RFC-5322) style.

Given the simple case of a repeated header in the style "key:value\r\n" where the total section is delimited by "\r\n\r\n", I can decode fine with a codec like:

(defcodec basic-header
  [(string :utf-8 :delimiters [":"]) 
   (string :utf-8 :delimiters ["\r\n" "\r\n\r\n"])])

(defcodec basic-headers
  (repeated basic-header :delimiters ["\r\n\r\n"]
                         :strip-delimiters? false))

i.e. Leave the repeated section delimiter to be consumed by the inner codec.

Decoding is fine, the problem is when encoding Gloss will emit a delimiter for each inner header, "\r\n", then the delimiter for the repeated section "\r\n\r\n", leaving me with one too many "\r\n\r\n"

While I'm not actually encoding headers, I thought it might be a nice addition to be able to specify the encoding-delimiter for a repeated section:

(defcodec basic-headers
  (repeated basic-header :delimiters ["\r\n\r\n"]
                         :encoding-delimiter "\r\n"
                         :strip-delimiters? false))

If this is agreeable I'd be happy to supply a pull-request for you.

More information here:
http://derek.troywest.com/articles/by-example-gloss/#basic-limitations

Thanks,
Derek

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

1 participant