25 lines
598 B
Go
25 lines
598 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"ippserver/packages/ipp"
|
|
"os"
|
|
)
|
|
|
|
func handlePrintJob(r *ipp.Request, byteStream io.Reader) *ipp.Response {
|
|
|
|
a := r.GetAttribute("job-name")
|
|
//a.(nameWithoutLanguage).Value
|
|
f, err := os.Create(a.(*ipp.NameWithoutLanguage).Value())
|
|
if err != nil {
|
|
panic("fail")
|
|
}
|
|
defer f.Close()
|
|
io.Copy(f, byteStream)
|
|
response := ipp.NewResponse(ipp.SuccessfulOk, r.RequestID())
|
|
response.AddOperatonAttribute(ipp.NewCharSetValue("attributes-charset", "utf-8"))
|
|
response.AddOperatonAttribute(ipp.NewNaturalLanguage("attributes-natural-language", "en"))
|
|
|
|
return response
|
|
}
|