-
-
Notifications
You must be signed in to change notification settings - Fork 61
Trim leading zeros from chunk size, Varnish Cache problem #73
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
Trim leading zeros from chunk size, Varnish Cache problem #73
Conversation
WyriHaximus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍 !
| 'varnish-type-response-extra-line' => [ | ||
| ["006\r\nWi\r\nki\r\n005\r\npedia\r\n00e\r\n in\r\n\r\nchunks.\r\n0\r\n\r\n"], | ||
| "Wi\r\nkipedia in\r\n\r\nchunks." | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the ltrim will definitely handle multiple leading 0's, could you add examples with more and less leading 0's then two. Just to ensure we don't accidentally refactor it specifically to two in the future. (You could even add a test adding a random number of 0's.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
clue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! 👍 This actually appears to be valid according to the RFC: https://tools.ietf.org/html/rfc7230#section-4.1
May I ask you to test this also for the end chunk?
Also ping @legionth for the reference, who added a somewhat similar decoder for our Http component 👍
|
I added tests for end |
|
Thanks for your quick response! 👍 It's actually tempting to confuse ABNF syntax with PCRE modifiers, the RFC linked above uses an ABNF for this that is defined as |
|
Sorry about that, I didn't know about this ABNF. I took the code from @legionth and moved tests to valid ones. |
clue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks your quick response! 👍
|
Awesome and thank you 👍 . I'll tag a new release soon |
Varnish Cache returns data with chunk size lead by 2 zeros
00. Examples:00einstead ofe001instead of1001234instead of1234Leading zeros have no value so we can trim them. I'm not 100% sure that there are always 2 zeros, but as far as I observed, there was 2 (to be sure I trim them all). Last zero is passed normally, so
\r\n0\r\n\r\n.Tests added.