-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CompressAndTruncate #1216
Comments
Compression doesn’t affect the semantics of the message in anyway so I don’t see the problem. If someone really always wants compression, they can just set Compress to true unconditionally after calling Truncate. As for truncating without compressing, that seems a bit pointless given the purpose is to fit as much of the message into the given space as possible and compressing helps with that. I’m not sure any changes or API additions would be justified here. |
Sure one can do that, but the side-effect of the Truncate function is still counter-intuitive IMHO. If someone had set their intent to compress a message prior, why would calling The current documentation also does not reflect this behaviour, it does tell that it checks if it fits without compression, then with compression.... but never that if it fits without compression, it will reset the compression attribute. Actually, removing Lines 41 to 42 in 35023fa
I do agree, I just said that I could see someone willing to trade retry over TCP vs walking and compressing, but I honestly don't have any interest in the support and this would probably complicate things more than anything. |
Agreeing w/ Tom here. Actually rfc 1035 says something sane about this:
Programs are free to avoid using pointers in messages they generate,
although this will reduce datagram capacity, and may cause truncation.
However all programs are required to understand arriving messages that
contain pointers.
(TIL)
|
I am not saying that compression is compulsory and that the server must compress. What I am saying is that If you strongly believe this is the right thing to do, then I suppose the fix would be to make it clear in the documentation that if the uncompress message fits within I can provide either patch. |
I don't think changing behaviour is really possible as it has been in the library as is for just under two years now, and it's easily worked around. I also implemented I think documenting this behaviour is fine though, feel free to open a PR for that. |
ok, I will cut a PR with some wording about the behaviour then. |
This is a documentation update to highlight the behaviour of Truncate, which will reset dns.Compress to false when the message fits in the requested size without truncation, and make it the caller responsibility to set it back to true if they wish to compress, regardless of fitting, uncompressed, in the requested message size in the first place or not. Fixes miekg#1216
* Update Truncate doc with compress behaviour This is a documentation update to highlight the behaviour of Truncate, which will reset dns.Compress to false when the message fits in the requested size without truncation, and make it the caller responsibility to set it back to true if they wish to compress, regardless of fitting, uncompressed, in the requested message size in the first place or not. Fixes #1216 * address comments * d/Note that/ * s/reset/set/ * s/caller/caller's/ * removed backticks * regardless of size
* Update Truncate doc with compress behaviour This is a documentation update to highlight the behaviour of Truncate, which will reset dns.Compress to false when the message fits in the requested size without truncation, and make it the caller responsibility to set it back to true if they wish to compress, regardless of fitting, uncompressed, in the requested message size in the first place or not. Fixes miekg#1216 * address comments * d/Note that/ * s/reset/set/ * s/caller/caller's/ * removed backticks * regardless of size
Currently the Truncate function disables compression, unless the does not fit in
size
bytes.E.g after calling
msg.Truncate(1234)
,msg.Compress
will be false when returning if its uncompressed length is < 1234. Even though the caller may have set msg.Compress to true explicitly before.As much as I do understand the reasoning, I am not sure why this is forced on the user of the library.
What would be the right way to support both use cases? Would simply removing
dns/msg_truncate.go
Lines 41 to 42 in 35023fa
But this would change the current behaviour though, on the other hand, if someone had set msg.Compress before hand, they are probably not replying what they expect to reply.
Should another function be created to allow to Truncate without side effect on the dns.Compress attribute?
As much as I understand the attempt to compress before truncating, I can also see people that would rather truncate and not compress...
What would you see as the best middle ground here?
The text was updated successfully, but these errors were encountered: