Debian Codegraph @

doc.go

raw symbols SCIP
1 /* Go IPP - IPP core protocol implementation in pure Go
2 /*
3 * Copyright (C) 2020 and up by Alexander Pevzner ([email protected])
4 * See LICENSE for license terms and conditions
5 *
6 * Package documentation
7 */
8
9 /*
10 Package goipp implements IPP core protocol, as defined by RFC 8010
11
12 It doesn't implement high-level operations, such as "print a document",
13 "cancel print job" and so on. It's scope is limited to proper generation
14 and parsing of IPP requests and responses.
15
16 IPP protocol uses the following simple model:
17 1. Send a request
18 2. Receive a response
19
20 Request and response both has a similar format, represented here
21 by type Message, with the only difference, that Code field of
22 that Message is the Operation code in request and Status code
23 in response. So most of operations are common for request and
24 response messages
25
26 Example:
27 package main
28
29 import (
30 "bytes"
31 "net/http"
32 "os"
33
34 "github.com/OpenPrinting/goipp"
35 )
36
37 const uri = "http://192.168.1.102:631"
38
39 // Build IPP OpGetPrinterAttributes request
40 func makeRequest() ([]byte, error) {
41 m := goipp.NewRequest(goipp.DefaultVersion, goipp.OpGetPrinterAttributes, 1)
42 m.Operation.Add(goipp.MakeAttribute("attributes-charset",
43 goipp.TagCharset, goipp.String("utf-8")))
44 m.Operation.Add(goipp.MakeAttribute("attributes-natural-language",
45 goipp.TagLanguage, goipp.String("en-US")))
46 m.Operation.Add(goipp.MakeAttribute("printer-uri",
47 goipp.TagURI, goipp.String(uri)))
48 m.Operation.Add(goipp.MakeAttribute("requested-attributes",
49 goipp.TagKeyword, goipp.String("all")))
50
51 return m.EncodeBytes()
52 }
53
54 // Check that there is no error
55 func check(err error) {
56 if err != nil {
57 panic(err)
58 }
59 }
60
61 func main() {
62 request, err := makeRequest()
63 check(err)
64
65 resp, err := http.Post(uri, goipp.ContentType, bytes.NewBuffer(request))
66 check(err)
67
68 var respMsg goipp.Message
69
70 err = respMsg.Decode(resp.Body)
71 check(err)
72
73 respMsg.Print(os.Stdout, false)
74 }
75 */
76 package goipp