A working proxy exists.

This commit is contained in:
2021-02-27 22:25:50 +01:00
parent ce94bf0d89
commit 617d7834cc
29 changed files with 781 additions and 195 deletions

View File

@@ -4,41 +4,49 @@ import (
"io"
)
type uriValue struct {
// URIValue represents a ipp URI value attribute
type URIValue struct {
name string
value string
}
func NewURIValue(name, value string) *uriValue {
u := new(uriValue)
// NewURIValue creates a new URIValue attribute
func NewURIValue(name, value string) *URIValue {
u := new(URIValue)
u.name = name
u.value = value
return u
}
func (u uriValue) Name() string {
// Name returns the name of the attribute
func (u URIValue) Name() string {
return u.name
}
func (u uriValue) String() string {
// Value returns the value of the attribute
func (u URIValue) Value() string {
return u.value
}
func (u URIValue) String() string {
return u.name + ":" + u.value
}
func (u *uriValue) valueTag() tag {
func (u *URIValue) valueTag() tag {
return uriValueTag
}
func (u *uriValue) unmarshal(byteStream io.Reader) {
func (u *URIValue) unmarshal(byteStream io.Reader) {
u.name, u.value = unmarshalSingleValue(byteStream)
}
func (u *uriValue) marshal() []byte {
func (u *URIValue) marshal() []byte {
res := make([]byte, u.size())
res[0] = byte(uriValueTag)
marshalNameValue(u.name, u.value, res[1:])
return res
}
func (u *uriValue) size() int {
func (u *URIValue) size() int {
l := 1 + 4 // The attribute tag + 2 lengths
l += len(u.name)
l += len(u.value)