package main import ( "bytes" "fmt" "ippserver/packages/ipp" "net/http" log "github.com/sirupsen/logrus" ) func handleGetJobAttributes(r *ipp.Request, requestID uint32) *ipp.Response { request := ipp.NewRequest(ipp.GetJobAttributes, requestID) request.AddOperatonAttribute(ipp.NewCharSetValue("attributes-charset", "utf-8")) request.AddOperatonAttribute(ipp.NewNaturalLanguage("attributes-natural-language", "en")) request.AddOperatonAttribute(ipp.NewURIValue("printer-uri", "ipp://"+printerURI)) request.AddOperatonAttribute(r.GetAttribute("job-id")) request.AddOperatonAttribute(r.GetAttribute("requesting-user-name")) request.AddOperatonAttribute(r.GetAttribute("requested-attributes")) log.Infof("Downstream request\n%v\n", request) downStreamRequest := request.Marshal() b := bytes.NewBuffer(downStreamRequest) downStreamResponse, err := http.Post("http://"+"brn30055cb5e3ae.local:631/ipp/print", "application/ipp", b) if err != nil { fmt.Print(err) } rb := ipp.NewResponse(0, 0) rb.UnMarshal(downStreamResponse.Body) log.Infof("Downstream response\n%v\n", rb) response := ipp.NewResponse(ipp.SuccessfulOk, r.RequestID()) response.AddOperatonAttribute(ipp.NewCharSetValue("attributes-charset", "utf-8")) response.AddOperatonAttribute(ipp.NewNaturalLanguage("attributes-natural-language", "en")) response.AddJobAttribute(rb.GetAttribute("job-id")) response.AddJobAttribute(rb.GetAttribute("job-name")) response.AddJobAttribute(rb.GetAttribute("job-originating-user-name")) response.AddJobAttribute(rb.GetAttribute("job-state")) response.AddJobAttribute(rb.GetAttribute("job-state-reasons")) return response }