Do not encode data, keep as buffer
I'm using the ipp module to download print documents. This is one of the seldom cases where the module fills obj.data.
Unfortunately the data was corrupted and eg. a PDF file couldn't be downloaded correctly.
Keeping the data in a buffer solves the problem. Instead of encode the data with the encoding for the IPP header I just slice the buffer at the position after the IPP header.
Interesting.
This change will break someone that was depending on it returning the decoded string though. We will need to do a major version bump.
The relevant definitions from the spec:
data = OCTET-STRING
BYTE = %x00-FF
OCTET-STRING = *BYTE
https://tools.ietf.org/html/rfc2910#section-3.2
So, hmm. I guess that looks like a Buffer. 🤔
Does it throw an error when it tries to decode?
@williamkapke FWIW, the more recent/relevant reference is in RFC 8010 now: https://tools.ietf.org/html/rfc8010#section-3.2
:)
@michaelrsweet ah right! Thanks- it's worth a lot!
No error is thrown during the decode. The data (eg. PDF) was corrupt.