Start client implementation.
This commit is contained in:
39
client/main.go
Normal file
39
client/main.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"ippserver/packages/ipp"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
//application/ipp
|
||||||
|
// brn30055cb5e3ae.local:631/ipp/print
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
customFormatter := new(log.TextFormatter)
|
||||||
|
customFormatter.TimestampFormat = "2006-01-02 15:04:05"
|
||||||
|
log.SetFormatter(customFormatter)
|
||||||
|
customFormatter.FullTimestamp = true
|
||||||
|
log.SetLevel(log.DebugLevel)
|
||||||
|
|
||||||
|
const printerUri = "brn30055cb5e3ae.local:631/ipp/print"
|
||||||
|
|
||||||
|
request := ipp.NewRequest(ipp.GetPrinterAttributes, 10)
|
||||||
|
request.AddOperatonAttribute(ipp.NewCharSetValue("attributes-charset", "utf-8"))
|
||||||
|
request.AddOperatonAttribute(ipp.NewNaturalLanguage("attributes-natural-language", "en"))
|
||||||
|
request.AddOperatonAttribute(ipp.NewUriValue("printer-uri", "ipp://"+printerUri))
|
||||||
|
r := request.Marshal()
|
||||||
|
b := bytes.NewBuffer(r)
|
||||||
|
httpResponse, err := http.Post("http://"+"brn30055cb5e3ae.local:631/ipp/print", "application/ipp", b)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rb := ipp.NewResponse(0, 0)
|
||||||
|
rb.UnMarshal(httpResponse.Body)
|
||||||
|
fmt.Print(r)
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user