fixed nil reference in request encoder
This commit is contained in:
parent
72ec31bc0b
commit
1249335763
19
reqest.go
19
reqest.go
|
@ -117,19 +117,19 @@ func NewRequestDecoder(r io.Reader) *RequestDecoder {
|
|||
func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
||||
req := new(Request)
|
||||
|
||||
if err := binary.Read(d.reader, binary.BigEndian, req.ProtocolVersionMajor); err != nil {
|
||||
if err := binary.Read(d.reader, binary.BigEndian, &req.ProtocolVersionMajor); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Read(d.reader, binary.BigEndian, req.ProtocolVersionMinor); err != nil {
|
||||
if err := binary.Read(d.reader, binary.BigEndian, &req.ProtocolVersionMinor); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Read(d.reader, binary.BigEndian, req.Operation); err != nil {
|
||||
if err := binary.Read(d.reader, binary.BigEndian, &req.Operation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := binary.Read(d.reader, binary.BigEndian, req.RequestId); err != nil {
|
||||
if err := binary.Read(d.reader, binary.BigEndian, &req.RequestId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -155,16 +155,27 @@ func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
|||
}
|
||||
|
||||
if startByte == TagOperation {
|
||||
if req.OperationAttributes == nil {
|
||||
req.OperationAttributes = make(map[string]interface{})
|
||||
}
|
||||
|
||||
tag = TagOperation
|
||||
tagSet = true
|
||||
|
||||
}
|
||||
|
||||
if startByte == TagJob {
|
||||
if req.JobAttributes == nil {
|
||||
req.JobAttributes = make(map[string]interface{})
|
||||
}
|
||||
tag = TagJob
|
||||
tagSet = true
|
||||
}
|
||||
|
||||
if startByte == TagPrinter {
|
||||
if req.PrinterAttributes == nil {
|
||||
req.PrinterAttributes = make(map[string]interface{})
|
||||
}
|
||||
tag = TagPrinter
|
||||
tagSet = true
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func (r *Response) Encode(data io.Writer) ([]byte, error) {
|
|||
}
|
||||
|
||||
values := make([]interface{}, len(r.OperationAttributes))
|
||||
for i, v := range attr {
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ func (r *Response) Encode(data io.Writer) ([]byte, error) {
|
|||
}
|
||||
|
||||
values := make([]interface{}, len(printerAttr))
|
||||
for i, v := range attr {
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ func (r *Response) Encode(data io.Writer) ([]byte, error) {
|
|||
}
|
||||
|
||||
values := make([]interface{}, len(jobAttr))
|
||||
for i, v := range attr {
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue