iss41: notes on issues and undecodable response #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR solves the issue described in #41.
I want to try to keep this PR smallish in order to make it more manageable:
Response
, I assume there are symmetrical issues inRequest
( not sure if Req and Resp even need to be different structs...)OperationalAttributes
in Response a singleAttributes
, while theJob
- andPrinterAttributes
are arrays of Attributes. This doesn't seem necessary and adds a lot of code to check for nil and initialize maps and arrays.UnsupportedAttributes
to the response, but I am not sure if this is a complete list of AttributeGroups. BTW I added UnsupportedAttributes as an array, like Printer and Job Attributes (for no particular reason, just to stay consistant with existing code)Value
field ofAttribute
have aninterface{}
type. I'm not sure if it would be desirable to cast them into something more concrete by value tag (RFC 8010 3.5.1), but in that case, we could also consider using Generics here? Again, bigger change I didn't want to just go ahead with.SkipDecoding
tag set totrue
in the Response tests. The decoding routine I wrote seems to work fine and I have another test for it. But the samples inresponse_test.go
are a little wonky and I was too lazy to figure out how they are supposed to work. I think it's an issue with the Encoder adding default attributes even if they weren't explicitly set in the structs?It looks like some major refactoring might be in order. Maybe utilizing OpenPrinting's Go library for encoding and decoding. Again, this would be a major change in the architecture and I wanted to keep the changes to review manageable.
Anyway, thanks for helping out! Let me know if you have any questions.