A working proxy exists.
This commit is contained in:
@@ -38,7 +38,7 @@ type AddValuer interface {
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
a *attributes
|
||||
a *Attributes
|
||||
header ippMessageHeader
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func NewRequest(op OperationID, requestID uint32) *Request {
|
||||
r.header.operationID = op
|
||||
r.header.requestID = requestID
|
||||
r.header.versionNumber = 0x0200
|
||||
r.a = new(attributes)
|
||||
r.a = new(Attributes)
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ func (r Request) String() string {
|
||||
func (r *Request) UnMarshal(body io.Reader) {
|
||||
buffbody := bufio.NewReader(body)
|
||||
r.header.unmarshal(buffbody)
|
||||
//log.Printf("Header %v", r.header)
|
||||
r.a = UnMarshalAttributes(buffbody)
|
||||
}
|
||||
|
||||
@@ -76,9 +75,25 @@ func (r *Request) GetAttribute(name string) Attribute {
|
||||
return a
|
||||
}
|
||||
}
|
||||
for _, a := range r.a.job {
|
||||
if a.Name() == name {
|
||||
return a
|
||||
}
|
||||
}
|
||||
for _, a := range r.a.printer {
|
||||
if a.Name() == name {
|
||||
return a
|
||||
}
|
||||
}
|
||||
for _, a := range r.a.unsupported {
|
||||
if a.Name() == name {
|
||||
return a
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Marshal converts the request object to a ipp request
|
||||
func (r *Request) Marshal() []byte {
|
||||
|
||||
var buf bytes.Buffer
|
||||
@@ -105,14 +120,29 @@ func (r *Request) Marshal() []byte {
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (r *Request) AddPrinterAttribute(a Attribute) {
|
||||
r.a.addAttribute(printerAttributes, a)
|
||||
// AddPrinterAttribute adds a printer attribute to the request object
|
||||
func (r *Request) AddPrinterAttribute(a Attribute) error {
|
||||
if a != nil {
|
||||
r.a.addAttribute(printerAttributes, a)
|
||||
return nil
|
||||
}
|
||||
return ErrNilAttribute
|
||||
}
|
||||
|
||||
func (r *Request) AddOperatonAttribute(a Attribute) {
|
||||
r.a.addAttribute(operationAttributes, a)
|
||||
// AddOperatonAttribute adds a operation attribute to the request object
|
||||
func (r *Request) AddOperatonAttribute(a Attribute) error {
|
||||
if a != nil {
|
||||
r.a.addAttribute(operationAttributes, a)
|
||||
return nil
|
||||
}
|
||||
return ErrNilAttribute
|
||||
}
|
||||
|
||||
func (r *Request) AddJobAttribute(a Attribute) {
|
||||
r.a.addAttribute(jobAttributes, a)
|
||||
// AddJobAttribute adds a job attribute to the request object
|
||||
func (r *Request) AddJobAttribute(a Attribute) error {
|
||||
if a != nil {
|
||||
r.a.addAttribute(jobAttributes, a)
|
||||
return nil
|
||||
}
|
||||
return ErrNilAttribute
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user